Closed
Description
Code
#[derive(Debug, Clone, Copy)]
struct Foo<T>{
value: T
}
impl<T: Copy + std::ops::AddAssign, R: Into<Foo<T>>> std::ops::AddAssign<R>
for Foo<T>
{
fn add_assign(&mut self, rhs: R)
{
let rhs = rhs.into();
self.value+=rhs.value
}
}
impl<T: Copy + std::ops::AddAssign, R: Into<Foo<T>>> std::ops::AddAssign<R>
for &mut Foo<T>
{
fn add_assign(&mut self, rhs: R)
{
let rhs = rhs.into();
self.value+=rhs.value
}
}
impl<T> From<&Self> for Foo<T>
where
T: Copy
{
#[inline]
#[must_use]
fn from(value: &Self) -> Self
{
Foo{value: value.value}
}
}
fn main(){
let mut left = Foo{value:1};
let right = Foo{value:1};
left += right;
(&mut left) += &right;
}
Meta
rustc --version --verbose
:
rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-unknown-linux-gnu
release: 1.63.0
LLVM version: 14.0.5
Error output
RUST_BACKTRACE=full cargo run
Compiling test_ref_ops v0.1.0 (/tmp/test_ref_ops)
warning: Error finalizing incremental compilation session directory `/tmp/test_ref_ops/target/debug/incremental/test_ref_ops-3s18srsj0fhdf/s-gd7b1v07dk-1anujo-working`: No such file or directory (os error 2)
error: internal compiler error: no errors encountered even though `delay_span_bug` issued
error: internal compiler error[E0067]: invalid left-hand side of assignment
--> src/main.rs:42:17
|
42 | (&mut left) += &right;
| ----------- ^^
| |
| cannot assign to this expression
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1425:13
stack backtrace:
0: 0x7f038a89e18d - std::backtrace_rs::backtrace::libunwind::trace::h8217d0a8f3fd2f41
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f038a89e18d - std::backtrace_rs::backtrace::trace_unsynchronized::h308103876b3af410
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f038a89e18d - std::sys_common::backtrace::_print_fmt::hc208018c6153605e
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:66:5
3: 0x7f038a89e18d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf89a7ed694dfb585
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:45:22
4: 0x7f038a8f9f7c - core::fmt::write::h21038c1382fe4264
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:1197:17
5: 0x7f038a88f8a1 - std::io::Write::write_fmt::h7dbb1c9a3c254aef
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/mod.rs:1672:15
6: 0x7f038a8a0e55 - std::sys_common::backtrace::_print::h4e8889719c9ddeb8
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:48:5
7: 0x7f038a8a0e55 - std::sys_common::backtrace::print::h1506fe2cb3022667
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:35:9
8: 0x7f038a8a0e55 - std::panicking::default_hook::{{closure}}::hd9d7ce2a8a782440
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:295:22
9: 0x7f038a8a0b76 - std::panicking::default_hook::h5b16ec25444b1b5d
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:314:9
10: 0x7f038b0feb54 - rustc_driver[e01eec72899701d3]::DEFAULT_HOOK::{closure#0}::{closure#0}
11: 0x7f038a8a152a - std::panicking::rust_panic_with_hook::hb0138cb6e6fea3e4
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:702:17
12: 0x7f038c2baa91 - std[f9ee9c7d4fd68eda]::panicking::begin_panic::<rustc_errors[b2e8492a1747ee42]::ExplicitBug>::{closure#0}
13: 0x7f038c2b8036 - std[f9ee9c7d4fd68eda]::sys_common::backtrace::__rust_end_short_backtrace::<std[f9ee9c7d4fd68eda]::panicking::begin_panic<rustc_errors[b2e8492a1747ee42]::ExplicitBug>::{closure#0}, !>
14: 0x7f038c2c7806 - std[f9ee9c7d4fd68eda]::panicking::begin_panic::<rustc_errors[b2e8492a1747ee42]::ExplicitBug>
15: 0x7f038c2c4ad6 - std[f9ee9c7d4fd68eda]::panic::panic_any::<rustc_errors[b2e8492a1747ee42]::ExplicitBug>
16: 0x7f038db7ecec - <rustc_errors[b2e8492a1747ee42]::HandlerInner as core[3edb0f9afb6adb32]::ops::drop::Drop>::drop
17: 0x7f038d2a9348 - core[3edb0f9afb6adb32]::ptr::drop_in_place::<rustc_session[72c90254a58d88d1]::parse::ParseSess>
18: 0x7f038d2ac2e3 - <alloc[59e4fb8ddcfb913c]::rc::Rc<rustc_session[72c90254a58d88d1]::session::Session> as core[3edb0f9afb6adb32]::ops::drop::Drop>::drop
19: 0x7f038d2ab6bd - core[3edb0f9afb6adb32]::ptr::drop_in_place::<rustc_interface[be6c6c80f2cd8cf2]::interface::Compiler>
20: 0x7f038d2a8c54 - rustc_span[fb9cf5df1e5e5539]::with_source_map::<core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>, rustc_interface[be6c6c80f2cd8cf2]::interface::create_compiler_and_run<core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>, rustc_driver[e01eec72899701d3]::run_compiler::{closure#1}>::{closure#1}>
21: 0x7f038d2b0302 - <scoped_tls[134a193f706323ee]::ScopedKey<rustc_span[fb9cf5df1e5e5539]::SessionGlobals>>::set::<rustc_interface[be6c6c80f2cd8cf2]::interface::run_compiler<core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>, rustc_driver[e01eec72899701d3]::run_compiler::{closure#1}>::{closure#0}, core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>>
22: 0x7f038d2d399f - std[f9ee9c7d4fd68eda]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[be6c6c80f2cd8cf2]::util::run_in_thread_pool_with_globals<rustc_interface[be6c6c80f2cd8cf2]::interface::run_compiler<core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>, rustc_driver[e01eec72899701d3]::run_compiler::{closure#1}>::{closure#0}, core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>>::{closure#0}, core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>>
23: 0x7f038d2c5529 - <<std[f9ee9c7d4fd68eda]::thread::Builder>::spawn_unchecked_<rustc_interface[be6c6c80f2cd8cf2]::util::run_in_thread_pool_with_globals<rustc_interface[be6c6c80f2cd8cf2]::interface::run_compiler<core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>, rustc_driver[e01eec72899701d3]::run_compiler::{closure#1}>::{closure#0}, core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>>::{closure#0}, core[3edb0f9afb6adb32]::result::Result<(), rustc_errors[b2e8492a1747ee42]::ErrorGuaranteed>>::{closure#1} as core[3edb0f9afb6adb32]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
24: 0x7f038a8ab463 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1680342795a2dc08
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/boxed.rs:1951:9
25: 0x7f038a8ab463 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h45204a69827b0e83
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/boxed.rs:1951:9
26: 0x7f038a8ab463 - std::sys::unix::thread::Thread::new::thread_start::h5d4e11bbda4161c8
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/thread.rs:108:17
27: 0x7f038a686b27 - start_thread
at ./nptl/./nptl/pthread_create.c:435:8
28: 0x7f038a70978c - __GI___clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
29: 0x0 - <unknown>
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.63.0 (4b91a6ea7 2022-08-08) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
warning: `test_ref_ops` (bin "test_ref_ops") generated 1 warning
error: could not compile `test_ref_ops`; 1 warning emitted