Skip to content

ICE: Returning impl Trait with placeholder type parameter #67995

@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. 

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

No branches or pull requests

Issue actions