Skip to content

ICE: Returning impl Trait with placeholder type parameter #67995

Closed
@riptl

Description

@riptl

Hope this isn't a duplicate.

EDIT: Updated example, removing async/await

Minimal Example

fn main() {
    evil();
}

trait Trait<T> {}

fn evil() -> impl Trait<_> {}

Workaround

Avoid placeholders.
fn evil() -> impl Trait<()> {

Meta

rustc 1.42.0-nightly (859764425 2020-01-07) running on x86_64-unknown-linux-gnu

EDIT: No ICE on stable Rust 1.40.0, build fails with error E0121 at fn evil() ....

Compiler Log

Expand
    Checking crash_test v0.1.0 (/home/richie/prj/crash_test)
error: internal compiler error: bad placeholder type
 --> src/main.rs:7:25
  |
7 | fn evil() -> impl Trait<_> {}
  |                         ^

error: internal compiler error: errors selecting obligation during MIR typeck: [FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<() as Trait<[type error]>>)), depth=0),Ambiguity)]

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:347:17
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.42.0-nightly (859764425 2020-01-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

error: could not compile `crash_test`.

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

Activity

added
C-bugCategory: This is a bug.
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.
on Jan 8, 2020
added
E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
on Jan 9, 2020
pnkfelix

pnkfelix commented on Jan 9, 2020

@pnkfelix
Member

triage: P-high, removing I-nominated label

lqd

lqd commented on Jan 9, 2020

@lqd
Member

bisected to 71bb0ff from #67597 cc @estebank

removed
E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
on Jan 9, 2020
riptl

riptl commented on Jan 9, 2020

@riptl
Author

Turns out it's not async/await related. It occurs when returning any impl Trait from a function that has placeholder type parameters.

Simplified example in updated issue description, see above.

changed the title [-]ICE: Future with placeholder, returning async closure[/-] [+]ICE: Returning impl Trait with placeholder type parameter[/+] on Jan 9, 2020

9 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @pnkfelix@lqd@estebank@jonas-schievink@riptl

    Issue actions

      ICE: Returning impl Trait with placeholder type parameter · Issue #67995 · rust-lang/rust