Closed chengniansun closed 4 years ago
Reduced:
fn main() {
let x: usize<main>;
}
This doesn't ICE on 1.46.
@rustbot modify labels: +regression-from-stable-to-stable
We decided to label this P-medium
as it's unlikely to be hit, it used to be an error in a previous release. Also, it's very esoteric code. Link to Zulip stream.
Line triggered the ICE: https://github.com/rust-lang/rust/blob/95b4a4f0eee935f9e0c80b0ceef34866bcb72ca3/compiler/rustc_typeck/src/collect/type_of.rs#L115-L120
Regressed in #74113, cc @lcnr fyi
Note that the snippet doesn't have to contain main
:
fn foo() {
let x: usize<foo>;
}
Will look into this in a few weeks so I am claiming this for now so I don't forget.
@rustbot claim
If anyone else wants to work on this before that feel free to do so, don't have much time rn
The solution might be as simple as merging the linked match arm with the previous error one, making this a delay_span_bug and ignoring it.
I just saw this issue and thought the same thing. I'm testing the fix now.
Code
Meta
rustc --version --verbose
:Error output
Backtrace
``` error: internal compiler error: compiler/rustc_typeck/src/collect/type_of.rs:115:26: unexpected anon const res PrimTy(Uint(Usize)) in path: Path { span: reduced_mutant.rs:7:12: 7:23 (#0), res: PrimTy(Uint(Usize)), segments: [PathSegment { ident: usize#0, hir_id: Some(HirId { owner: DefId(0:3 ~ reduced_mutant[317d]::main), local_id: 57 }), res: Some(Err), args: Some(GenericArgs { args: [Const(ConstArg { value: AnonConst { hir_id: HirId { owner: DefId(0:3 ~ reduced_mutant[317d]::main), local_id: 54 }, body: BodyId { hir_id: HirId { owner: DefId(0:3 ~ reduced_mutant[317d]::main), local_id: 56 } } }, span: reduced_mutant.rs:7:18: 7:22 (#0) })], bindings: [], parenthesized: false }), infer_args: false }] } thread 'rustc' panicked at 'Box', /rustc/dd7fc54ebdca419ad9d3ab1e9f5ed14e770768ea/compiler/rustc_errors/src/lib.rs:891:9
stack backtrace:
0: std::panicking::begin_panic
1: rustc_errors::HandlerInner::span_bug
2: rustc_errors::Handler::span_bug
3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
4: rustc_middle::ty::context::tls::with_opt::{{closure}}
5: rustc_middle::ty::context::tls::with_opt
6: rustc_middle::util::bug::opt_span_bug_fmt
7: rustc_middle::util::bug::span_bug_fmt
8: rustc_typeck::collect::type_of::opt_const_param_of
9: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::opt_const_param_of>::compute
10: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl
11: rustc_data_structures::stack::ensure_sufficient_stack
12: rustc_query_system::query::plumbing::get_query_impl
13: rustc_typeck::check::typeck
14: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::typeck>::compute
15: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl
16: rustc_data_structures::stack::ensure_sufficient_stack
17: rustc_query_system::query::plumbing::get_query_impl
18: rustc_query_system::query::plumbing::ensure_query_impl
19: rustc_typeck::check::typeck_item_bodies
20: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
21: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl
22: rustc_data_structures::stack::ensure_sufficient_stack
23: rustc_query_system::query::plumbing::get_query_impl
24: rustc_typeck::check_crate
25: rustc_interface::passes::analysis
26: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::analysis>::compute
27: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl
28: rustc_data_structures::stack::ensure_sufficient_stack
29: rustc_query_system::query::plumbing::get_query_impl
30: rustc_interface::passes::QueryContext::enter
31: rustc_interface::queries::::enter
32: rustc_span::with_source_map
33: scoped_tls::ScopedKey::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.49.0-nightly (dd7fc54eb 2020-10-15) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [opt_const_param_of] computing the optional const parameter of `main::{constant#0}`
#1 [typeck] type-checking `main::{constant#0}`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0109`.
```