Skip to content

ICE on HRTB #62203

Closed
Closed
@SeeSpring

Description

@SeeSpring

The following code results in an ICE on stable, beta, and nightly

#![feature(fn_traits)]
#![feature(unboxed_closures)]

trait T0<'a, A> {
    type O;
}

struct L<T> {
    f: T,
}

impl<'a, A, T> T0<'a, A> for L<T>
where
    T: FnMut<A>,
{
    type O = T::Output;
}   

trait T1: for<'r> Ty<'r> {
    fn m<'a, B: Ty<'a>, F>(&self, f: F) -> ()
    where
        F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>,
    {
        unimplemented!();
    }
}

trait Ty<'a> {
    type V;
}

fn main() {
    let v = ().m(L{ f : |x|{drop(x)} } );
}

impl<'a> Ty<'a> for () {
    type V = &'a u8;
}

impl T1 for () {}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0554]: #![feature] may not be used on the stable release channel
 --> src/main.rs:1:1
  |
1 | #![feature(fn_traits)]
  | ^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: #![feature] may not be used on the stable release channel
 --> src/main.rs:2:1
  |
2 | #![feature(unboxed_closures)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0271]: type mismatch resolving `for<'r> <L<[closure@src/main.rs:33:25: 33:37]> as T0<'r, (<() as Ty<'r>>::V,)>>::O == <_ as Ty<'r>>::V`
  --> src/main.rs:33:16
   |
33 |     let v = ().m(L{ f : |x|{drop(x)} } );
   |                ^ expected (), found associated type
   |
   = note: expected type `()`
              found type `<_ as Ty<'_>>::V`

error: internal compiler error: src/librustc/infer/lexical_region_resolve/mod.rs:632: collect_error_for_expanding_node() could not find error for var '_#5r in universe U8, lower_bounds=[
    RegionAndOrigin(RePlaceholder(Placeholder { universe: U7, name: BrNamed(crate0:DefIndex(1:20), 'r) }),Subtype(TypeTrace(ObligationCause { span: src/main.rs:33:16: 33:17, body_id: HirId { owner: DefIndex(0:12), local_id: 22 }, code: ImplDerivedObligation(DerivedObligationCause { parent_trait_ref: Binder(<L<[closure@src/main.rs:33:25: 33:37]> as T0<'r, (<() as Ty<'r>>::V,)>>), parent_code: MiscObligation }) }))),
    RegionAndOrigin(RePlaceholder(Placeholder { universe: U7, name: BrNamed(crate0:DefIndex(1:20), 'r) }),Subtype(TypeTrace(ObligationCause { span: src/main.rs:33:16: 33:17, body_id: HirId { owner: DefIndex(0:12), local_id: 22 }, code: ImplDerivedObligation(DerivedObligationCause { parent_trait_ref: Binder(<L<[closure@src/main.rs:33:25: 33:37]> as T0<'r, (<() as Ty<'r>>::V,)>>), parent_code: MiscObligation }) }))),
], upper_bounds=[
    RegionAndOrigin(RePlaceholder(Placeholder { universe: U7, name: BrNamed(crate0:DefIndex(1:20), 'r) }),Subtype(TypeTrace(ObligationCause { span: src/main.rs:33:16: 33:17, body_id: HirId { owner: DefIndex(0:12), local_id: 22 }, code: ImplDerivedObligation(DerivedObligationCause { parent_trait_ref: Binder(<L<[closure@src/main.rs:33:25: 33:37]> as T0<'r, (<() as Ty<'r>>::V,)>>), parent_code: MiscObligation }) }))),
    RegionAndOrigin(RePlaceholder(Placeholder { universe: U7, name: BrNamed(crate0:DefIndex(1:20), 'r) }),Subtype(TypeTrace(ObligationCause { span: src/main.rs:33:16: 33:17, body_id: HirId { owner: DefIndex(0:12), local_id: 22 }, code: ImplDerivedObligation(DerivedObligationCause { parent_trait_ref: Binder(<L<[closure@src/main.rs:33:25: 33:37]> as T0<'r, (<() as Ty<'r>>::V,)>>), parent_code: MiscObligation }) }))),
]
  --> src/main.rs:33:16
   |
33 |     let v = ().m(L{ f : |x|{drop(x)} } );
   |                ^

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:570:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to 4 previous errors

Some errors occurred: E0271, E0554.
For more information about an error, try `rustc --explain E0271`.

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.35.0 (3c235d560 2019-05-20) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

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

error: Could not compile `playground`.

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

Metadata

Metadata

Assignees

Labels

A-trait-systemArea: Trait systemC-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-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions