Skip to content

internal compiler error: asked to compute variance for wrong kind of item #114327

New issue

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

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

Already on GitHub? # to your account

Closed
iamanonymouscs opened this issue Aug 1, 2023 · 3 comments
Closed
Labels
C-bug Category: This is a bug. F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-internal-features This issue requires the use of internal features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@iamanonymouscs
Copy link

Code

#![feature(rustc_attrs)]

#[rustc_variance]
trait MyTrait { }

fn main() { }

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (db7ff98a7 2023-07-31)
binary: rustc
commit-hash: db7ff98a72f3e742b641f9cb16d0e8c285e87e9b
commit-date: 2023-07-31
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Error output

error: internal compiler error: compiler/rustc_hir_analysis/src/variance/mod.rs:66:5: asked to compute variance for wrong kind of item
 --> 4.rs:4:1
  |
4 | trait MyTrait { }
  | ^^^^^^^^^^^^^
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/compiler/rustc_errors/src/lib.rs:989:33
stack backtrace:
   0:     0x7f7928fa34bc - std::backtrace_rs::backtrace::libunwind::trace::h00560e9152510f67
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7928fa34bc - std::backtrace_rs::backtrace::trace_unsynchronized::h0f27c3665dd0a867
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7928fa34bc - std::sys_common::backtrace::_print_fmt::h5dba0ff3e06fa698
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f7928fa34bc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4debeea1996f535b
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7929009bac - core::fmt::rt::Argument::fmt::h1e53d9bbf5a265dd
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/core/src/fmt/rt.rs:138:9
   5:     0x7f7929009bac - core::fmt::write::hcb86202702aeaf68
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f7928f95b1e - std::io::Write::write_fmt::h6b056feb2ab827f8
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/io/mod.rs:1714:15
   7:     0x7f7928fa32a5 - std::sys_common::backtrace::_print::h63c494f55c85c02e
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f7928fa32a5 - std::sys_common::backtrace::print::h0d84953923cd4383
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f7928fa63fa - std::panicking::panic_hook_with_disk_dump::{{closure}}::h0ded106e3e100970
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/panicking.rs:278:22
  10:     0x7f7928fa6093 - std::panicking::panic_hook_with_disk_dump::h80545efc2b457190
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/panicking.rs:312:9
  11:     0x7f792c24a2e9 - rustc_driver_impl[953ac255d00f3c7f]::install_ice_hook::{closure#0}
  12:     0x7f7928fa6ca0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h005d394de554c94e
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/alloc/src/boxed.rs:2021:9
  13:     0x7f7928fa6ca0 - std::panicking::rust_panic_with_hook::ha35d072680b6716b
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/panicking.rs:733:13
  14:     0x7f792c3d3761 - std[cfe24ee53075a1e5]::panicking::begin_panic::<rustc_errors[b1a6789dfd2ebe34]::ExplicitBug>::{closure#0}
  15:     0x7f792c3d3286 - std[cfe24ee53075a1e5]::sys_common::backtrace::__rust_end_short_backtrace::<std[cfe24ee53075a1e5]::panicking::begin_panic<rustc_errors[b1a6789dfd2ebe34]::ExplicitBug>::{closure#0}, !>
  16:     0x7f792c3db476 - std[cfe24ee53075a1e5]::panicking::begin_panic::<rustc_errors[b1a6789dfd2ebe34]::ExplicitBug>
  17:     0x7f792c36d6ee - <rustc_errors[b1a6789dfd2ebe34]::HandlerInner>::span_bug::<rustc_span[c85fb125fe1c027]::span_encoding::Span, alloc[9d71a00e6f43b08]::string::String>
  18:     0x7f792c36d49f - <rustc_errors[b1a6789dfd2ebe34]::Handler>::span_bug::<rustc_span[c85fb125fe1c027]::span_encoding::Span, alloc[9d71a00e6f43b08]::string::String>
  19:     0x7f792c3e3616 - rustc_middle[23eac342ec155d27]::util::bug::opt_span_bug_fmt::<rustc_span[c85fb125fe1c027]::span_encoding::Span>::{closure#0}
  20:     0x7f792c3e364a - rustc_middle[23eac342ec155d27]::ty::context::tls::with_opt::<rustc_middle[23eac342ec155d27]::util::bug::opt_span_bug_fmt<rustc_span[c85fb125fe1c027]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f792c3e30b8 - rustc_middle[23eac342ec155d27]::ty::context::tls::with_context_opt::<rustc_middle[23eac342ec155d27]::ty::context::tls::with_opt<rustc_middle[23eac342ec155d27]::util::bug::opt_span_bug_fmt<rustc_span[c85fb125fe1c027]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f792c3e3094 - rustc_middle[23eac342ec155d27]::util::bug::span_bug_fmt::<rustc_span[c85fb125fe1c027]::span_encoding::Span>
  23:     0x7f792ad40cfa - rustc_hir_analysis[2c6ebfa0ec54105a]::variance::variances_of
  24:     0x7f792a26c233 - rustc_query_impl[c1c3c70d39a20423]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c1c3c70d39a20423]::query_impl::variances_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 16usize]>>
  25:     0x7f792a26c1f5 - <rustc_query_impl[c1c3c70d39a20423]::query_impl::variances_of::dynamic_query::{closure#2} as core[24a2ba61524efef7]::ops::function::FnOnce<(rustc_middle[23eac342ec155d27]::ty::context::TyCtxt, rustc_span[c85fb125fe1c027]::def_id::DefId)>>::call_once
  26:     0x7f792a2f9bf4 - rustc_query_system[85489b7677581133]::query::plumbing::try_execute_query::<rustc_query_impl[c1c3c70d39a20423]::DynamicConfig<rustc_query_system[85489b7677581133]::query::caches::DefaultCache<rustc_span[c85fb125fe1c027]::def_id::DefId, rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[c1c3c70d39a20423]::plumbing::QueryCtxt, false>
  27:     0x7f792bbcb263 - rustc_query_impl[c1c3c70d39a20423]::query_impl::variances_of::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f792a5e7ec5 - rustc_middle[23eac342ec155d27]::query::plumbing::query_get_at::<rustc_query_system[85489b7677581133]::query::caches::DefaultCache<rustc_span[c85fb125fe1c027]::def_id::DefId, rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 16usize]>>>
  29:     0x7f792c3ae195 - rustc_hir_analysis[2c6ebfa0ec54105a]::variance::test::test_variance
  30:     0x7f792b6fdea6 - rustc_hir_analysis[2c6ebfa0ec54105a]::check_crate
  31:     0x7f792b6f698a - rustc_interface[22a5bdce7fd6e981]::passes::analysis
  32:     0x7f792b74ac3a - rustc_query_impl[c1c3c70d39a20423]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c1c3c70d39a20423]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7f792b74ac29 - <rustc_query_impl[c1c3c70d39a20423]::query_impl::analysis::dynamic_query::{closure#2} as core[24a2ba61524efef7]::ops::function::FnOnce<(rustc_middle[23eac342ec155d27]::ty::context::TyCtxt, ())>>::call_once
  34:     0x7f792b8eefa8 - rustc_query_system[85489b7677581133]::query::plumbing::try_execute_query::<rustc_query_impl[c1c3c70d39a20423]::DynamicConfig<rustc_query_system[85489b7677581133]::query::caches::SingleCache<rustc_middle[23eac342ec155d27]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c1c3c70d39a20423]::plumbing::QueryCtxt, false>
  35:     0x7f792b8eed37 - rustc_query_impl[c1c3c70d39a20423]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f792b4c69a5 - <rustc_middle[23eac342ec155d27]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[953ac255d00f3c7f]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>
  37:     0x7f792b4c5fd2 - <rustc_interface[22a5bdce7fd6e981]::interface::Compiler>::enter::<rustc_driver_impl[953ac255d00f3c7f]::run_compiler::{closure#1}::{closure#2}, core[24a2ba61524efef7]::result::Result<core[24a2ba61524efef7]::option::Option<rustc_interface[22a5bdce7fd6e981]::queries::Linker>, rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>
  38:     0x7f792b4bf0a8 - std[cfe24ee53075a1e5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[22a5bdce7fd6e981]::util::run_in_thread_pool_with_globals<rustc_interface[22a5bdce7fd6e981]::interface::run_compiler<core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>, rustc_driver_impl[953ac255d00f3c7f]::run_compiler::{closure#1}>::{closure#0}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>
  39:     0x7f792b4be82e - <<std[cfe24ee53075a1e5]::thread::Builder>::spawn_unchecked_<rustc_interface[22a5bdce7fd6e981]::util::run_in_thread_pool_with_globals<rustc_interface[22a5bdce7fd6e981]::interface::run_compiler<core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>, rustc_driver_impl[953ac255d00f3c7f]::run_compiler::{closure#1}>::{closure#0}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[24a2ba61524efef7]::result::Result<(), rustc_span[c85fb125fe1c027]::ErrorGuaranteed>>::{closure#1} as core[24a2ba61524efef7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7f7928fb1445 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h021e65daf5fb4ee0
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/alloc/src/boxed.rs:2007:9
  41:     0x7f7928fb1445 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7dda744b120f2954
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/alloc/src/boxed.rs:2007:9
  42:     0x7f7928fb1445 - std::sys::unix::thread::Thread::new::thread_start::hcffeb1067f9b6dfb
                               at /rustc/db7ff98a72f3e742b641f9cb16d0e8c285e87e9b/library/std/src/sys/unix/thread.rs:108:17
  43:     0x7f7928e71609 - start_thread
  44:     0x7f7928d96133 - clone
  45:                0x0 - <unknown>

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: please attach the file at `/home/rustc-ice-2023-08-01T05:01:24.302713465Z-243.txt` to your bug report

query stack during panic:
#0 [variances_of] computing the variances of `MyTrait`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@iamanonymouscs iamanonymouscs 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 Aug 1, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 1, 2023
@fmease
Copy link
Member

fmease commented Aug 1, 2023

Thanks for your report. However, internal features like rustc_attrs generally don't come with any guarantees and thus not much effort is taken to catch misuses. Hence I wouldn't consider such an ICE to be a bug.

@rustbot label F-rustc_attrs requires-internal-features -needs-triage

@rustbot rustbot added F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. requires-internal-features This issue requires the use of internal features. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 1, 2023
@matthiaskrgr
Copy link
Member

duplicate of #79699

@compiler-errors
Copy link
Member

Yeah, rustc_attrs have no guarantees that they will not ICE if they are misused.

@compiler-errors compiler-errors closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-internal-features This issue requires the use of internal features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants