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: type_of.rs:115:26: unexpected anon const res PrimTy(Uint(Usize)) in path #78005

Closed
chengniansun opened this issue Oct 16, 2020 · 7 comments · Fixed by #78089
Closed

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

chengniansun opened this issue Oct 16, 2020 · 7 comments · Fixed by #78089
Assignees
Labels
A-typesystem Area: The type system C-bug Category: This is a bug. 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

@chengniansun
Copy link

chengniansun commented Oct 16, 2020

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`.

@chengniansun chengniansun 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 Oct 16, 2020
@chengniansun chengniansun changed the title ICE: 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 }] } ICE: type_of.rs:115:26: unexpected anon const res PrimTy(Uint(Usize)) in path Oct 16, 2020
@SNCPlay42
Copy link
Contributor

Reduced:

fn main() {
    let x: usize<main>;
}

@SNCPlay42
Copy link
Contributor

This doesn't ICE on 1.46.

@rustbot modify labels: +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 Oct 16, 2020
@hameerabbasi
Copy link
Contributor

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.

@hameerabbasi hameerabbasi added the P-medium Medium priority label Oct 16, 2020
@tesuji
Copy link
Contributor

tesuji commented Oct 16, 2020

Line triggered the ICE:

_ => span_bug!(
DUMMY_SP,
"unexpected anon const res {:?} in path: {:?}",
res,
path,
),

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 

@JohnTitor JohnTitor removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 16, 2020
@jyn514 jyn514 added the A-typesystem Area: The type system label Oct 16, 2020
@lcnr
Copy link
Contributor

lcnr commented Oct 16, 2020

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

@estebank
Copy link
Contributor

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.

@varkor
Copy link
Member

varkor commented Oct 18, 2020

I just saw this issue and thought the same thing. I'm testing the fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system C-bug Category: This is a bug. 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

Successfully merging a pull request may close this issue.

10 participants