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_alias_impl_trait: panic in a destructor during cleanup #129099

Open
matthiaskrgr opened this issue Aug 14, 2024 · 2 comments · May be fixed by #129244
Open

ICE: type_alias_impl_trait: panic in a destructor during cleanup #129099

matthiaskrgr opened this issue Aug 14, 2024 · 2 comments · May be fixed by #129244
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

#![feature(type_alias_impl_trait)]

trait Trait {
    type Gat<'lt>;
}

fn dyn_hoops<T: Trait>(_: T) -> *const dyn for<'b> Iterator<Item = impl Sized + Captures<'a>> {
    loop {}
}

mod typeck {
    use super::*;
    type Opaque = impl Sized;
    fn define() -> Option<Opaque> {
        let _: Opaque = dyn_hoops::<u8>(0);
        None
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (80eb5a8e9 2024-08-13)
binary: rustc
commit-hash: 80eb5a8e910e5185d47cdefe3732d839c78a5e7e
commit-date: 2024-08-13
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Error output

error[E0261]: use of undeclared lifetime name `'a`
 --> a.rs:7:90
  |
7 | fn dyn_hoops<T: Trait>(_: T) -> *const dyn for<'b> Iterator<Item = impl Sized + Captures<'a>> {
  |                                                                                          ^^ undeclared lifetime
  |
  = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'a` lifetime
  |
7 | fn dyn_hoops<T: Trait>(_: T) -> *const dyn for<'b> Iterator<Item = impl Sized + for<'a> Captures<'a>> {
  |                                                                                 +++++++
help: consider making the bound lifetime-generic with a new `'a` lifetime
  |
7 | fn dyn_hoops<T: Trait>(_: T) -> *const dyn for<'a, 'b> Iterator<Item = impl Sized + Captures<'a>> {
  |                                                +++
help: consider introducing lifetime `'a` here
  |
7 | fn dyn_hoops<'a, T: Trait>(_: T) -> *const dyn for<'b> Iterator<Item = impl Sized + Captures<'a>> {
  |              +++

error[E0405]: cannot find trait `Captures` in this scope
 --> a.rs:7:81
  |
7 | fn dyn_hoops<T: Trait>(_: T) -> *const dyn for<'b> Iterator<Item = impl Sized + Captures<'a>> {
  |                                                                                 ^^^^^^^^ not found in this scope
Backtrace

thread 'rustc' panicked at core/src/panicking.rs:229:5:
panic in a destructor during cleanup

error: 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: please make sure that you have updated to the latest nightly

note: please attach the file at `/tmp/im/rustc-ice-2024-08-14T16_23_00-896091.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `typeck::define`
#1 [type_of_opaque] computing type of opaque `typeck::Opaque::{opaque#0}`
#2 [type_of] computing type of `typeck::Opaque::{opaque#0}`
#3 [check_well_formed] checking that `typeck::Opaque::{opaque#0}` is well-formed
#4 [check_mod_type_wf] checking that types are well-formed in module `typeck`
#5 [analysis] running analysis passes on this crate
end of query stack
thread caused non-unwinding panic. aborting.
[1]    896091 IOT instruction  RUST_BACKTRACE=full rustc a.rs

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Aug 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 14, 2024
@matthiaskrgr matthiaskrgr added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 14, 2024
@matthiaskrgr
Copy link
Member Author

Hmm this bisects to #125001 cc @compiler-errors

@matthiaskrgr
Copy link
Member Author

bit smaller

#![feature(type_alias_impl_trait)]

fn dyn_hoops<T: Sized>() -> dyn for<'a> Iterator<Item = impl Captures<'a>> {
    loop {}
}

pub fn main() {
    type Opaque = impl Sized;
    fn define() -> Opaque {
        let x: Opaque = dyn_hoops::<()>(0);
        x
    }
}

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Aug 16, 2024
@cjgillot cjgillot linked a pull request Aug 18, 2024 that will close this issue
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 22, 2024
Make opaque types regular HIR nodes

Having opaque types as HIR owner introduces all sorts of complications. This PR proposes to make them regular HIR nodes instead.

I haven't gone through all the test changes yet, so there may be a few surprises.

Many thanks to `@camelid` for the first draft.
Fixes rust-lang#129023

Fixes rust-lang#129099
Fixes rust-lang#125843
Fixes rust-lang#119716
Fixes rust-lang#121422
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. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants