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 on HRTB #62203

Closed
SeeSpring opened this issue Jun 28, 2019 · 4 comments · Fixed by #62523
Closed

ICE on HRTB #62203

SeeSpring opened this issue Jun 28, 2019 · 4 comments · Fixed by #62523
Assignees
Labels
A-trait-system Area: Trait system 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-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@SeeSpring
Copy link
Contributor

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.

@csmoe csmoe added A-trait-system Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jun 28, 2019
@Centril Centril added I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 28, 2019
@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Jun 28, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Jul 4, 2019

thanks to @Mark-Simulacrum for providing a feature-free reproduction

ICE appears to have been injected between 1.32.0 and 1.33.0. We could obviously use further bisection.

@pnkfelix
Copy link
Member

pnkfelix commented Jul 4, 2019

triage: P-high, removing nomination, marking needs-bisect, and assigning to self.

@pnkfelix pnkfelix self-assigned this Jul 4, 2019
@pnkfelix pnkfelix added E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed I-nominated labels Jul 4, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Jul 9, 2019

ICE was injected between nightly-2019-01-03 (ec19464 2019-01-02) and nightly-2019-01-04 (c0bbc39 2019-01-03).

We did not have many PR's merged in that time frame, just these:

% git log --format=oneline --author=bors ec194646f..c0bbc3927
c0bbc3927e28c22edefe6a1353b5ecc95ea9a104 Auto merge of #55517 - nikomatsakis:universes, r=scalexm
2442823ef572a65092fbc46f6975633f983b50b6 Auto merge of #56507 - nikomatsakis:polonius-integrate, r=MatthewJasper
140936307e692c324815c9640696b3e3f0c7ae78 Auto merge of #57282 - matthewjasper:wellformed-return-ty, r=nikomatsakis

Based on past experience, I'm guessing this is due to the Universes PR #55517.

@pnkfelix pnkfelix removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jul 9, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Jul 9, 2019

I'm going to take a shot at just turning the current span_bug! call into a tcx.sess.delay_span_bug and see where that gets us.

Centril added a commit to Centril/rust that referenced this issue Jul 22, 2019
…-62203-ice, r=varkor

Delay bug to resolve HRTB ICE

Fix rust-lang#62203
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 23, 2019
…-62203-ice, r=varkor

Delay bug to resolve HRTB ICE

Fix rust-lang#62203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system 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-stable Performance or correctness regression from one stable version to another. 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.

5 participants