Rust: ICE: type_of.rs:115:26: unexpected anon const res PrimTy(Uint(Usize)) in path

Created on 16 Oct 2020  路  7Comments  路  Source: rust-lang/rust

Code

fn main() {
    let x: isize<isize>;
    let x: i8<isize>;
    let x: i16<isize>;
    let x: i32<isize>;
    let x: i64<isize>;
    let x: usize<main>;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
    let x;
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (e160e5cb8 2020-10-14)

binary: rustc

commit-hash: e160e5cb80652bc2afe74cb3affbe35b74243ea9

commit-date: 2020-10-14

host: x86_64-unknown-linux-gnu

release: 1.49.0-nightly

LLVM version: 11.0

Error output


error[E0109]: type arguments are not allowed for this type
 --> reduced_mutant.rs:2:18
  |
2 |     let x: isize<isize>;
  |                  ^^^^^ type argument not allowed

error[E0109]: type arguments are not allowed for this type
 --> reduced_mutant.rs:3:15
  |
3 |     let x: i8<isize>;
  |               ^^^^^ type argument not allowed

error[E0109]: type arguments are not allowed for this type
 --> reduced_mutant.rs:4:16
  |
4 |     let x: i16<isize>;
  |                ^^^^^ type argument not allowed

error[E0109]: type arguments are not allowed for this type
 --> reduced_mutant.rs:5:16
  |
5 |     let x: i32<isize>;
  |                ^^^^^ type argument not allowed

error[E0109]: type arguments are not allowed for this type
 --> reduced_mutant.rs:6:16
  |
6 |     let x: i64<isize>;
  |                ^^^^^ type argument not allowed

error[E0109]: const arguments are not allowed for this type
 --> reduced_mutant.rs:7:18
  |
7 |     let x: usize<main>;
  |                  ^^^^ const argument not allowed

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<Any>', /rustc/dd7fc54ebdca419ad9d3ab1e9f5ed14e770768ea/compiler/rustc_errors/src/lib.rs:891: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.49.0-nightly (dd7fc54eb 2020-10-15) running on x86_64-unknown-linux-gnu

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0109`.


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<Any>', /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::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::opt_const_param_of>::compute
  10: rustc_query_system::dep_graph::graph::DepGraph<K>::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::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  15: rustc_query_system::dep_graph::graph::DepGraph<K>::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::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  21: rustc_query_system::dep_graph::graph::DepGraph<K>::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::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::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::<impl rustc_interface::interface::Compiler>::enter
  32: rustc_span::with_source_map
  33: scoped_tls::ScopedKey<T>::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`.


A-typesystem C-bug I-ICE P-medium T-compiler regression-from-stable-to-stable

All 7 comments

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>;
}


bisected with cargo-bisect-rustc v0.5.2

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

cargo bisect-rustc 2020-07-01 --end 2020-08-01 --preserve --regress=ice --without-cargo -- check 

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.

Was this page helpful?
0 / 5 - 0 ratings