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

ICE: Returning impl Trait with placeholder type parameter #67995

Closed
riptl opened this issue Jan 8, 2020 · 3 comments · Fixed by #68071
Closed

ICE: Returning impl Trait with placeholder type parameter #67995

riptl opened this issue Jan 8, 2020 · 3 comments · Fixed by #68071
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@riptl
Copy link

riptl commented Jan 8, 2020

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.
@csmoe csmoe added A-async-await Area: Async & Await 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 Jan 8, 2020
@jonas-schievink jonas-schievink added I-nominated regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Jan 8, 2020
@pnkfelix pnkfelix added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jan 9, 2020
@pnkfelix
Copy link
Member

pnkfelix commented Jan 9, 2020

triage: P-high, removing I-nominated label

@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels Jan 9, 2020
@lqd
Copy link
Member

lqd commented Jan 9, 2020

bisected to 71bb0ff from #67597 cc @estebank

@lqd lqd removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jan 9, 2020
@riptl
Copy link
Author

riptl commented Jan 9, 2020

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.

@riptl riptl changed the title ICE: Future with placeholder, returning async closure ICE: Returning impl Trait with placeholder type parameter Jan 9, 2020
@JohnTitor JohnTitor removed the A-async-await Area: Async & Await label Jan 9, 2020
@estebank estebank self-assigned this Jan 9, 2020
Centril added a commit to Centril/rust that referenced this issue Jan 10, 2020
Extend support of `_` in type parameters

 - Account for `impl Trait<_>`.
 - Provide a reasonable `Span` for empty `Generics` in `impl`s.
 - Account for `fn foo<_>(_: _) {}` to suggest `fn foo<T>(_: T) {}`.
 - Fix rust-lang#67995. Follow up to rust-lang#67597.
Centril added a commit to Centril/rust that referenced this issue Jan 10, 2020
Extend support of `_` in type parameters

 - Account for `impl Trait<_>`.
 - Provide a reasonable `Span` for empty `Generics` in `impl`s.
 - Account for `fn foo<_>(_: _) {}` to suggest `fn foo<T>(_: T) {}`.
 - Fix rust-lang#67995. Follow up to rust-lang#67597.
@bors bors closed this as completed in c751961 Jan 10, 2020
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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants