Skip to content

Internal compiler error when using vec![] inside of an async match statement (rustc 1.54.0) #88778

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

Closed
Bauxitedev opened this issue Sep 9, 2021 · 6 comments
Assignees
Labels
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

@Bauxitedev
Copy link

Bauxitedev commented Sep 9, 2021

This code triggers an internal compiler error on rustc 1.54.0:

use anyhow;

async fn main2() {
    loop {
        let pending: Result<Vec<()>, anyhow::Error> = Ok(vec![]);

        match pending {
            Ok(vec![]) => {} 
            Err(e) => {},
        }
    }
}

Try it on the Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fba71555b1f83a0975e3722e514826ae

The error is:

error: arbitrary expressions aren't allowed in patterns
 --> src/lib.rs:8:16
  |
8 |             Ok(vec![]) => {} 
  |                ^^^^^^
  |
  = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: compiler/rustc_mir_build/src/thir/pattern/mod.rs:559:22: not a literal: Expr { hir_id: HirId { owner: DefId(0:6 ~ playground[319e]::main2), local_id: 34 }, kind: Call(Expr { hir_id: HirId { owner: DefId(0:6 ~ playground[319e]::main2), local_id: 33 }, kind: Path(TypeRelative(Ty { hir_id: HirId { owner: DefId(0:6 ~ playground[319e]::main2), local_id: 31 }, kind: Path(Resolved(None, Path { span: /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/macros.rs:45:36: 45:52 (#5), res: Def(Struct, DefId(5:6773 ~ alloc[df14]::vec::Vec)), segments: [PathSegment { ident: $crate#5, hir_id: Some(HirId { owner: DefId(0:6 ~ playground[319e]::main2), local_id: 28 }), res: Some(Err), args: None, infer_args: true }, PathSegment { ident: vec#5, hir_id: Some(HirId { owner: DefId(0:6 ~ playground[319e]::main2), local_id: 29 }), res: Some(Def(Mod, DefId(5:5996 ~ alloc[df14]::vec))), args: None, infer_args: true }, PathSegment { ident: Vec#5, hir_id: Some(HirId { owner: DefId(0:6 ~ playground[319e]::main2), local_id: 30 }), res: Some(Err), args: None, infer_args: true }] })), span: /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/macros.rs:45:36: 45:52 (#5) }, PathSegment { ident: new#5, hir_id: Some(HirId { owner: DefId(0:6 ~ playground[319e]::main2), local_id: 32 }), res: Some(Err), args: None, infer_args: true })), span: /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/macros.rs:45:36: 45:57 (#5) }, []), span: /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/macros.rs:45:36: 45:59 (#5) }
 --> src/lib.rs:8:16
  |
8 |             Ok(vec![]) => {} 
  |                ^^^^^^
  |
  = note: this error: internal compiler error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/compiler/rustc_errors/src/lib.rs:953: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.54.0 (a178d0322 2021-07-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 --crate-type lib

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

query stack during panic:
#0 [thir_body] building THIR for `main2::{closure#0}`
#1 [mir_built] building MIR for `main2::{closure#0}`
end of query stack
error: aborting due to 2 previous errors

error: could not compile `playground`

To learn more, run the command again with --verbose.
@Noble-Mushtak
Copy link
Contributor

I tried making a more minimal example for this ICE and got it down to this (here's the playground):

async fn main2() {
    match vec![()] {
        vec![] => {},
        _ => {}
    }
}

@rylev
Copy link
Member

rylev commented Sep 10, 2021

@rustbot claim

@hellow554
Copy link
Contributor

hellow554 commented Sep 10, 2021

@rustbot modify labels: I-ICE C-Bug T-compiler

@Bauxitedev please use the correct issue template next time, thanks :)

@rustbot rustbot 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 Sep 10, 2021
@Bauxitedev
Copy link
Author

Bauxitedev commented Sep 10, 2021

@hellow554 I clicked the GitHub link rustc printed in my terminal (Alacritty) to report this issue, but the resulting issue body was blank, so I was under the impression I had to come up with a body myself. Apparently it stripped away the &template=ice.md part of the URL, which explains why 🤷

@hellow554
Copy link
Contributor

That seems to be "a problem" with alacritty. But I'm afraid there's nothing we could do here (apart from using a short domain... 🙄)
Anyway, thank you for reporting this! I really do much appreciate it.

@Alexendoo
Copy link
Member

Fixed by #92080

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

No branches or pull requests

7 participants