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

type_alias_impl_trait delay_span_bug when type parameter is associated type with non-static lifetime #78450

Closed
samlich opened this issue Oct 27, 2020 · 5 comments · Fixed by #85755
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@samlich
Copy link
Contributor

samlich commented Oct 27, 2020

Code

Minimized: #78450 (comment)

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=adadd0c395d648144fff80bd295c2a5e

#![feature(min_type_alias_impl_trait)]
#![feature(type_alias_impl_trait)]
#![no_std]

pub trait AssociatedImpl {
    type ImplTrait;

    fn f() -> Self::ImplTrait;
}

trait DynTrait<'a> {}

struct S<T>(T);
struct S2<T>(T);
struct S3<T>(T);

trait Associated {
    type A;
}

// ICE
impl<'a, T: Associated<A = dyn DynTrait<'a>>> AssociatedImpl for S<T> {
    type ImplTrait = impl core::future::Future<Output = ()>;

    fn f() -> Self::ImplTrait {
        async { () }
    }
}

// Ok
impl<'a, T: Associated<A = dyn DynTrait<'a>>> AssociatedImpl for S2<T> {
    type ImplTrait = core::future::Ready<()>;

    fn f() -> Self::ImplTrait {
        core::future::ready(())
    }
}

// Ok
impl<T> AssociatedImpl for S3<T> {
    type ImplTrait = core::future::Ready<()>;

    fn f() -> Self::ImplTrait {
        core::future::ready(())
    }
}

also occurs for

struct Lifetime<'a>(&'a ());
impl<'a, T: Associated<A = Lifetime<'a>>> AssociatedImpl for S<T> {
    type ImplTrait = impl core::future::Future<Output = ()>;

    fn f() -> Self::ImplTrait {
        async { () }
    }
}

but not

impl<T: Associated<A = Lifetime<'static>>> AssociatedImpl for S<T> {
    type ImplTrait = impl core::future::Future<Output = ()>;

    fn f() -> Self::ImplTrait {
        async { () }
    }
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (ffa2e7ae8 2020-10-24)
binary: rustc
commit-hash: ffa2e7ae8fbf9badc035740db949b9dae271c29f
commit-date: 2020-10-24
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0

also on Rust Playground rustc 1.49.0-nightly (fd542592f 2020-10-26) running on x86_64-unknown-linux-gnu

Error output

warning: Error finalizing incremental compilation session directory `/home/s/.cargo_target/debug/incremental/delay_span_bug-3ai9aikhnzrep/s-fsib370ap2-1x1a11v-working`: No such file or directory (os error 2)

warning: 1 warning emitted

error: internal compiler error: unexpected concrete region in borrowck: ReEarlyBound(0, 'a)
  --> src/lib.rs:24:5
   |
24 | /     fn f() -> Self::ImplTrait {
25 | |         async { () }
26 | |     }
   | |_____^
   |
   = note: delayed at compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs:85:44

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:961: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.49.0-nightly (ffa2e7ae8 2020-10-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C link-arg=-fuse-ld=lld --crate-type lib

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

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

Caused by:
  process didn't exit successfully: `rustc --crate-name delay_span_bug --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=94e47d36116a0b96 -C extra-filename=-94e47d36116a0b96 --out-dir /home/s/.cargo_target/debug/deps -C incremental=/home/s/.cargo_target/debug/incremental -L dependency=/home/s/.cargo_target/debug/deps -C link-arg=-fuse-ld=lld` (exit code: 101)
Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:961:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/ffa2e7ae8fbf9badc035740db949b9dae271c29f/library/std/src/panicking.rs:483:5
   1: std::panicking::begin_panic_fmt
             at /rustc/ffa2e7ae8fbf9badc035740db949b9dae271c29f/library/std/src/panicking.rs:437:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place
   7: rustc_span::with_source_map
   8: rustc_interface::interface::create_compiler_and_run
   9: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.49.0-nightly (ffa2e7ae8 2020-10-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C link-arg=-fuse-ld=lld --crate-type lib

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

query stack during panic:
end of query stack

@samlich samlich 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 27, 2020
@jonas-schievink jonas-schievink added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. labels Oct 27, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 28, 2020
@samlich
Copy link
Contributor Author

samlich commented Oct 30, 2020

Somehow I missed that this does not require async. Also crashes withtype ImplTrait = impl core::fmt::Debug; and returning ().

@oli-obk
Copy link
Contributor

oli-obk commented Feb 18, 2021

minimized:

#![feature(min_type_alias_impl_trait)]
#![feature(type_alias_impl_trait)]
#![no_std]

pub trait AssociatedImpl {
    type ImplTrait;

    fn f() -> Self::ImplTrait;
}

struct S<T>(T);

trait Associated {
    type A;
}

// ICE
impl<'a, T: Associated<A = &'a ()>> AssociatedImpl for S<T> {
    type ImplTrait = impl core::fmt::Debug;

    fn f() -> Self::ImplTrait {
        ()
    }
}

@nikomatsakis
Copy link
Contributor

updated example that fails -- the minimization no longer ICEs for me

@nikomatsakis
Copy link
Contributor

minimized to just the ICE code -- this sure looks like a dup of #83190

@spastorino spastorino self-assigned this Jun 15, 2021
@spastorino
Copy link
Member

After a discussion with Niko about this and assigning to myself we saw that there's already a PR. Unassigning myself then :).

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)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

6 participants