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

ICE: #[rustc_variance] on trait: asked to compute variance for wrong kind of item #79699

Closed
matthiaskrgr opened this issue Dec 4, 2020 · 11 comments
Labels
C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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

@matthiaskrgr
Copy link
Member

Code

#![feature(rustc_attrs)]

#[rustc_variance]
trait Tr { }

fn main() { }

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (e9dd18ca7 2020-12-04)
binary: rustc
commit-hash: e9dd18ca749801a19d85bfb424ae12011a8ff894
commit-date: 2020-12-04
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Error output

error: internal compiler error: compiler/rustc_typeck/src/variance/mod.rs:45:9: asked to compute variance for wrong kind of item
 --> ./src/test/compile-fail/variance-region-bounds.rs:4:1
  |
4 | trait Tr { }
  | ^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<Any>', /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/compiler/rustc_errors/src/lib.rs:904:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.50.0-nightly (e9dd18ca7 2020-12-04) running on x86_64-unknown-linux-gnu

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

Backtrace

error: internal compiler error: compiler/rustc_typeck/src/variance/mod.rs:45:9: asked to compute variance for wrong kind of item
 --> ./src/test/compile-fail/variance-region-bounds.rs:4:1
  |
4 | trait Tr { }
  | ^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<Any>', /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/compiler/rustc_errors/src/lib.rs:904:9
stack backtrace:
   0:     0x7f90f0b2b990 - std::backtrace_rs::backtrace::libunwind::trace::h746c3e9529d524bc
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f90f0b2b990 - std::backtrace_rs::backtrace::trace_unsynchronized::h86340908ff889faa
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f90f0b2b990 - std::sys_common::backtrace::_print_fmt::h43f85f9b18230404
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f90f0b2b990 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc132ae1a5b5aa7cd
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f90f0b9f58c - core::fmt::write::hdf023a0036d2a25f
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/core/src/fmt/mod.rs:1078:17
   5:     0x7f90f0b1d462 - std::io::Write::write_fmt::h8580846154bcb66a
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/io/mod.rs:1519:15
   6:     0x7f90f0b2f615 - std::sys_common::backtrace::_print::h7ee55fed88d107a3
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f90f0b2f615 - std::sys_common::backtrace::print::h54a7d3e52a524177
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f90f0b2f615 - std::panicking::default_hook::{{closure}}::h60921e857bf55a40
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/panicking.rs:208:50
   9:     0x7f90f0b2f16a - std::panicking::default_hook::hf0f9afb1017317fc
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/panicking.rs:225:9
  10:     0x7f90f13c4948 - rustc_driver::report_ice::hff78d76a39ffbb86
  11:     0x7f90f0b2ff16 - std::panicking::rust_panic_with_hook::h8d66bf42b407aaea
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/panicking.rs:595:17
  12:     0x7f90f205ec3d - std::panicking::begin_panic::{{closure}}::h54eeb46bac46db82
  13:     0x7f90f205eb86 - std::sys_common::backtrace::__rust_end_short_backtrace::h4e2b24765319763c
  14:     0x7f90f1f40f1f - std::panicking::begin_panic::hc2016e83d046c641
  15:     0x7f90f204441c - rustc_errors::HandlerInner::span_bug::h8e6533b92ab43aa3
  16:     0x7f90f20446d0 - rustc_errors::Handler::span_bug::h572b00fe05637c58
  17:     0x7f90f211e554 - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::h5cb28236637f8e39
  18:     0x7f90f211e14b - rustc_middle::ty::context::tls::with_opt::{{closure}}::h4b587d06910badc4
  19:     0x7f90f211e0f2 - rustc_middle::ty::context::tls::with_opt::h1de5816033aded9d
  20:     0x7f90f211e453 - rustc_middle::util::bug::opt_span_bug_fmt::hfae2ed8f53b5e93e
  21:     0x7f90f211e417 - rustc_middle::util::bug::span_bug_fmt::h5fd16dadd4aa27be
  22:     0x7f90f20775e7 - rustc_typeck::variance::variances_of::{{closure}}::h20f743f215738ce1
  23:     0x7f90f207739a - rustc_typeck::variance::variances_of::h57ac03785ddd37d0
  24:     0x7f90f1f302f2 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::variances_of>::compute::h29ccb15266121033
  25:     0x7f90f200c065 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h45e1bc6044779c4d
  26:     0x7f90f202beb4 - rustc_data_structures::stack::ensure_sufficient_stack::he988aaa7327e6398
  27:     0x7f90f21a71f4 - rustc_query_system::query::plumbing::get_query_impl::hbcf2f924d8608ce6
  28:     0x7f90f1f57fb3 - <rustc_typeck::variance::test::VarianceTest as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::he7d71188a6857160
  29:     0x7f90f209b646 - rustc_hir::hir::Crate::visit_all_item_likes::hea439839e1e6c838
  30:     0x7f90f2078a91 - rustc_typeck::check_crate::hab874d5f99f602e6
  31:     0x7f90f1624642 - rustc_interface::passes::analysis::h34f9b972d8af6f3d
  32:     0x7f90f1380f7b - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::h95ff81a8a73eaff3
  33:     0x7f90f140f486 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task::h05a5aa3f40ff3b2d
  34:     0x7f90f1422686 - rustc_data_structures::stack::ensure_sufficient_stack::h371083fbc17898bc
  35:     0x7f90f13aecb4 - rustc_query_system::query::plumbing::get_query_impl::hcc63ca689fa3c69b
  36:     0x7f90f138321b - rustc_interface::passes::QueryContext::enter::h2071e0a8631ee0e4
  37:     0x7f90f1420045 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hd899306a06575d0c
  38:     0x7f90f13eddf7 - rustc_span::with_source_map::ha4e07ff263d0dc1d
  39:     0x7f90f141bdec - scoped_tls::ScopedKey<T>::set::h39c0aa543118d3f3
  40:     0x7f90f1423296 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1e5aa72fb9cd6d86
  41:     0x7f90f138afca - core::ops::function::FnOnce::call_once{{vtable.shim}}::hc793837e985b77ce
  42:     0x7f90f0b3f99a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hea1090dbdcecbf5a
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/alloc/src/boxed.rs:1327:9
  43:     0x7f90f0b3f99a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8d5723d3912bd325
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/alloc/src/boxed.rs:1327:9
  44:     0x7f90f0b3f99a - std::sys::unix::thread::Thread::new::thread_start::hc17a425ca2995724
                               at /rustc/e9dd18ca749801a19d85bfb424ae12011a8ff894/library/std/src/sys/unix/thread.rs:71:17
  45:     0x7f90f0a353e9 - start_thread
  46:     0x7f90f0952293 - __GI___clone
  47:                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.50.0-nightly (e9dd18ca7 2020-12-04) running on x86_64-unknown-linux-gnu

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

@matthiaskrgr matthiaskrgr 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 Dec 4, 2020
@jonas-schievink jonas-schievink added the F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. label Dec 4, 2020
@matthiaskrgr
Copy link
Member Author

The ICE happens on stable as well, for some reason.
( I do get a '#![feature]' may not be used on the stable release channel warning though)
Versions as early as 1.44 crash, I didn't dig any further.

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Dec 4, 2020

@rustbot modify labels to +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 Dec 4, 2020
@camelid camelid added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Dec 4, 2020
@camelid
Copy link
Member

camelid commented Dec 4, 2020

rustbot added a commit to rustbot/glacier that referenced this issue Dec 4, 2020
@camelid camelid added the requires-nightly This issue requires a nightly compiler in some way. label Dec 4, 2020
@Stupremee Stupremee removed the requires-nightly This issue requires a nightly compiler in some way. label Dec 4, 2020
camelid added a commit to rust-lang/glacier that referenced this issue Dec 4, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 4, 2020
@camelid
Copy link
Member

camelid commented Dec 4, 2020

@Stupremee Why did you remove requires-nightly? I know that the ICE occurs on stable, but you need the feature flag (and thus nightly) to actually use it.

@camelid camelid added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 4, 2020
@camelid
Copy link
Member

camelid commented Dec 4, 2020

Assigning P-medium and removing I-prioritize as discussed in the prioritization working group.

@Stupremee
Copy link
Member

@Stupremee Why did you remove requires-nightly? I know that the ICE occurs on stable, but you need the feature flag (and thus nightly) to actually use it.

To reproduce the ICE you don't need nightly and thus I thought it's wrong. Correct me if I'm misunderstanding the requires-nightly label

@camelid
Copy link
Member

camelid commented Dec 4, 2020

TMK, we use requires-nightly if it requires a nightly feature. I guess what I'm saying is: you can produce on stable, but it doesn't affect stable code because to actually use the code you need to be on nightly. But I think it's fine to be more cautious in this case and not use requires-nightly. So it's fine :)

@chengniansun
Copy link

A duplicate.

#![feature(rustc_attrs)]
#[rustc_variance]
impl Words {}

@smmalis37
Copy link
Contributor

Bisected:


Regression in nightly-2018-09-10


found 8 bors merge commits in the specified range
commit[0] 2018-09-08UTC: Auto merge of #53909 - mikhail-m1:53643, r=nikomatsakis
commit[1] 2018-09-09UTC: Auto merge of #53949 - estebank:unclosed-delim, r=nikomatsakis
commit[2] 2018-09-09UTC: Auto merge of #53960 - estebank:issue-51303, r=nagisa
commit[3] 2018-09-09UTC: Auto merge of #53988 - eddyb:issue-53770, r=petrochenkov
commit[4] 2018-09-09UTC: Auto merge of #53998 - eddyb:issue-53728, r=oli-obk
commit[5] 2018-09-09UTC: Auto merge of #53902 - dtolnay:group, r=petrochenkov
commit[6] 2018-09-09UTC: Auto merge of #54057 - matthiaskrgr:stabilize-edition-plus-clippy, r=Mark-Simulacrum
commit[7] 2018-09-09UTC: Auto merge of #53778 - petrochenkov:shadrelax2, r=nikomatsakis
ERROR: no commits between 0198a1e and 2d4e34c within last 167 days

@chengniansun
Copy link

Another duplicate.

#![feature(rustc_attrs)]
#[rustc_variance]
const GOO: Cake;

@cjgillot
Copy link
Contributor

cjgillot commented Dec 3, 2022

rustc_variance is a rustc internal debugging tool. Closing as WONTFIX.

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. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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
Development

No branches or pull requests

9 participants