Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1425:13 #101376

Closed
amarao opened this issue Sep 3, 2022 · 5 comments · Fixed by #101388
Closed

panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1425:13 #101376

amarao opened this issue Sep 3, 2022 · 5 comments · Fixed by #101388
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@amarao
Copy link

amarao commented Sep 3, 2022

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
@amarao amarao added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 3, 2022
@amarao
Copy link
Author

amarao commented Sep 3, 2022

(update, I've reproduced it on smaller example)

@steffahn
Copy link
Member

steffahn commented Sep 3, 2022

Error -> ICE
regression in 1.63 @rustbot label regression-from-stable-to-stable

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 3, 2022
@QuineDot
Copy link

QuineDot commented Sep 3, 2022

Reduced example (stable, nightly, beta).

use std::ops::AddAssign;
struct Foo;

impl AddAssign<()> for Foo {
    fn add_assign(&mut self, _: ()) {}
}

impl AddAssign<()> for &mut Foo {
    fn add_assign(&mut self, _: ()) {}
}

fn main() {
    (&mut Foo) += ();
}

There's no ICE on 1.62.

@steffahn
Copy link
Member

steffahn commented Sep 3, 2022

searched nightlies: from nightly-2022-05-01 to nightly-2022-07-01
regressed nightly: nightly-2022-05-19
searched commit range: 4c5f6e6...cd282d7
regressed commit: a084b7a

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo-bisect-rustc --access github --regress ice --start 2022-05-01 --end 2022-07-01 -vv

Regresses in rollup #97135, most likely #94639, cc @compiler-errors

@compiler-errors
Copy link
Member

@rustbot claim

@bors bors closed this as completed in dd35e2f Sep 4, 2022
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
6 participants