Skip to content

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

Closed
@samlich

Description

@samlich

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions