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

Enum with const generic generates "'no errors encountered even though delay_span_bug issued" #87542

Closed
dignifiedquire opened this issue Jul 28, 2021 · 0 comments · Fixed by #87854
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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.

Comments

@dignifiedquire
Copy link

Code

pub enum Foo<const A: usize> {
    Bar,
    Baz([(); A]),
}


fn main() {
    // Cannot infer type for 9
    // let x = Foo::Bar::<9>;
    // Compiler error 
    let x = Foo::Bar::<9usize>;
}

Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=555bd63340732916af008758d6acedff

Meta

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17) running on x86_64-unknown-linux-gnu

Error output

   Compiling playground v0.0.1 (/playground)
warning: unused variable: `x`
  --> src/main.rs:11:9
   |
11 |     let x = Foo::Bar::<9usize>;
   |         ^ help: if this is intentional, prefix it with an underscore: `_x`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

error: internal compiler error: unexpected const parent in type_of_def_id(): Expr(Expr { hir_id: HirId { owner: DefId(0:11 ~ playground[21c2]::main), local_id: 5 }, kind: Path(Resolved(None, Path { span: src/main.rs:11:13: 11:31 (#0), res: Def(Ctor(Variant, Const), DefId(0:6 ~ playground[21c2]::Foo::Bar::{constructor#0})), segments: [PathSegment { ident: Foo#0, hir_id: Some(HirId { owner: DefId(0:11 ~ playground[21c2]::main), local_id: 1 }), res: Some(Def(Enum, DefId(0:3 ~ playground[21c2]::Foo))), args: None, infer_args: true }, PathSegment { ident: Bar#0, hir_id: Some(HirId { owner: DefId(0:11 ~ playground[21c2]::main), local_id: 4 }), res: Some(Err), args: Some(GenericArgs { args: [Const(ConstArg { value: AnonConst { hir_id: HirId { owner: DefId(0:11 ~ playground[21c2]::main), local_id: 2 }, body: BodyId { hir_id: HirId { owner: DefId(0:11 ~ playground[21c2]::main), local_id: 3 } } }, span: src/main.rs:11:24: 11:30 (#0) })], bindings: [], parenthesized: false }), infer_args: false }] })), span: src/main.rs:11:13: 11:31 (#0) })
  |
  = note: delayed at compiler/rustc_typeck/src/collect/type_of.rs:474:26

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/compiler/rustc_trait_selection/src/opaque_types.rs:1007:32

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_typeck/src/check/coercion.rs:154:49

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_mir_build/src/build/mod.rs:747:18

error: internal compiler error: mir_const_qualif: MIR had errors
  --> src/main.rs:11:24
   |
11 |     let x = Foo::Bar::<9usize>;
   |                        ^^^^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/mod.rs:237:18

error: internal compiler error: PromoteTemps: MIR had errors
  --> src/main.rs:11:24
   |
11 |     let x = Foo::Bar::<9usize>;
   |                        ^^^^^^
   |
   = note: delayed at compiler/rustc_mir/src/transform/promote_consts.rs:55:22

error: internal compiler error: broken MIR in DefId(0:12 ~ playground[21c2]::main::{constant#0}) ("return type"): bad type [type error]
  --> src/main.rs:11:24
   |
11 |     let x = Foo::Bar::<9usize>;
   |                        ^^^^^^
   |
   = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:252:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:721:20

error: internal compiler error: broken MIR in DefId(0:12 ~ playground[21c2]::main::{constant#0}) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src/main.rs:11:24: 11:30 (#0), scope: scope[0] } }): bad type [type error]
  --> src/main.rs:11:24
   |
11 |     let x = Foo::Bar::<9usize>;
   |                        ^^^^^^
   |
   = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:252:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1018:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.53.0 (53cb7b09b 2021-06-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `playground`

To learn more, run the command again with --verbose.
@dignifiedquire dignifiedquire 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 Jul 28, 2021
@BoxyUwU BoxyUwU added the A-const-generics Area: const generics (parameters and arguments) label Jul 28, 2021
@BoxyUwU BoxyUwU self-assigned this Aug 7, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 10, 2021
correctly handle enum variants in `opt_const_param_of`

Fixes rust-lang#87542

`opt_const_param_of` was returning `None` for args on an enum variant `Enum::Variant::<10>` because we called `generics_of` on the enum variant which has no generics.

r? ```@oli-obk```
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 10, 2021
correctly handle enum variants in `opt_const_param_of`

Fixes rust-lang#87542

`opt_const_param_of` was returning `None` for args on an enum variant `Enum::Variant::<10>` because we called `generics_of` on the enum variant which has no generics.

r? ````@oli-obk````
@bors bors closed this as completed in 6c92656 Aug 11, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants