Skip to content

Commit ad57597

Browse files
Rollup merge of rust-lang#62523 - pnkfelix:delay-bug-to-resolve-issue-62203-ice, r=varkor
Delay bug to resolve HRTB ICE Fix rust-lang#62203
2 parents 52e9e44 + 837fe7b commit ad57597

File tree

3 files changed

+82
-9
lines changed

3 files changed

+82
-9
lines changed

src/librustc/infer/lexical_region_resolve/mod.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -764,16 +764,17 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
764764
}
765765
}
766766

767-
span_bug!(
767+
// Errors in earlier passes can yield error variables without
768+
// resolution errors here; delay ICE in favor of those errors.
769+
self.tcx().sess.delay_span_bug(
768770
self.var_infos[node_idx].origin.span(),
769-
"collect_error_for_expanding_node() could not find \
770-
error for var {:?} in universe {:?}, lower_bounds={:#?}, \
771-
upper_bounds={:#?}",
772-
node_idx,
773-
node_universe,
774-
lower_bounds,
775-
upper_bounds
776-
);
771+
&format!("collect_error_for_expanding_node() could not find \
772+
error for var {:?} in universe {:?}, lower_bounds={:#?}, \
773+
upper_bounds={:#?}",
774+
node_idx,
775+
node_universe,
776+
lower_bounds,
777+
upper_bounds));
777778
}
778779

779780
fn collect_concrete_regions(
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
trait T0<'a, A> {
2+
type O;
3+
}
4+
5+
struct L<T> {
6+
f: T,
7+
}
8+
9+
// explicitly named variants of what one would normally denote by the
10+
// unit type `()`. Why do this? So that we can differentiate them in
11+
// the diagnostic output.
12+
struct Unit1;
13+
struct Unit2;
14+
struct Unit3;
15+
struct Unit4;
16+
17+
impl<'a, A, T> T0<'a, A> for L<T>
18+
where
19+
T: FnMut(A) -> Unit3,
20+
{
21+
type O = T::Output;
22+
}
23+
24+
trait T1: for<'r> Ty<'r> {
25+
fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1
26+
where
27+
F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>,
28+
{
29+
unimplemented!();
30+
}
31+
}
32+
33+
trait Ty<'a> {
34+
type V;
35+
}
36+
37+
fn main() {
38+
let v = Unit2.m(
39+
//~^ ERROR type mismatch
40+
//~| ERROR type mismatch
41+
L {
42+
f : |x| { drop(x); Unit4 }
43+
});
44+
}
45+
46+
impl<'a> Ty<'a> for Unit2 {
47+
type V = &'a u8;
48+
}
49+
50+
impl T1 for Unit2 {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (<Unit2 as Ty<'r>>::V,)>>::O == <_ as Ty<'r>>::V`
2+
--> $DIR/issue-62203-hrtb-ice.rs:38:19
3+
|
4+
LL | let v = Unit2.m(
5+
| ^ expected struct `Unit4`, found associated type
6+
|
7+
= note: expected type `Unit4`
8+
found type `<_ as Ty<'_>>::V`
9+
10+
error[E0271]: type mismatch resolving `<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as std::ops::FnOnce<((&u8,),)>>::Output == Unit3`
11+
--> $DIR/issue-62203-hrtb-ice.rs:38:19
12+
|
13+
LL | let v = Unit2.m(
14+
| ^ expected struct `Unit4`, found struct `Unit3`
15+
|
16+
= note: expected type `Unit4`
17+
found type `Unit3`
18+
= note: required because of the requirements on the impl of `for<'r> T0<'r, (<Unit2 as Ty<'r>>::V,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>`
19+
20+
error: aborting due to 2 previous errors
21+
22+
For more information about this error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)