Skip to content

Broken MIR (and diagnostics) using Higher-Rank Trait Bounds and associated types #80956

Closed
@SkiFire13

Description

@SkiFire13

Code

trait Bar {
    type Type;
}
struct Foo<'a>(&'a ());
impl<'a> Bar for Foo<'a> {
    type Type = ();
}

fn func<'a>(_: <Foo<'a> as Bar>::Type) {}
fn assert_is_func<A>(_: fn(A)) {}

fn test() where for<'a> <Foo<'a> as Bar>::Type: Sized {
    assert_is_func(func);
}

Playground link

Meta

rustc --version --verbose:

rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-pc-windows-msvc
release: 1.49.0

Error output

warning: Error finalizing incremental compilation session directory `\\?\G:\WorkSpace\rust-playground\target\debug\incremental\rust_playground-13rqwjq2lprvw\s-fuvapvoonl-1e5eb07-working`: Impossibile trovare il file specificato. (os error 2)

warning: 4 warnings emitted

error: internal compiler error: broken MIR in DefId(0:16 ~ rust_playground[48a5]::test) (Terminator { source_info: SourceInfo { span: src\lib.rs:13:5: 13:25 (#0), scope: scope[0] }, kind: _1 = assert_is_func::<<Foo<'_> as 
Bar>::Type>(move _2) -> [return: bb1, unwind: bb2] }): bad arg #0 (fn(()) <- for<'r> fn(<Foo<'r> as Bar>::Type)): NoSolution
  --> src\lib.rs:13:20
   |
13 |     assert_is_func(func);
   |                    ^^^^
   |
   = note: delayed at compiler\rustc_mir\src\borrow_check\type_check\mod.rs:253:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler\rustc_errors\src\lib.rs:974:13
stack backtrace:
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 (e1884a8e3 2020-12-29) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --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 `rust-playground`

To learn more, run the command again with --verbose.

Strangely the backtrace is empty (I got the error output section with RUST_BACKTRACE=1). Should I report that bug separately?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-borrow-checkerArea: The borrow checkerA-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions