Skip to content

Commit 572b6e8

Browse files
adwinwhitelcnr
authored andcommitted
assumption-on-binders ICE
1 parent 2b6167d commit 572b6e8

5 files changed

Lines changed: 150 additions & 13 deletions

File tree

compiler/rustc_infer/src/infer/context.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
5050
&self,
5151
u: ty::UniverseIndex,
5252
) -> Option<rustc_type_ir::region_constraint::Assumptions<TyCtxt<'tcx>>> {
53-
self.placeholder_assumptions_for_next_solver.borrow().get(&u).unwrap().as_ref().cloned()
53+
// FIXME(-Zassumptions_on_binders): We should actually make sure that
54+
// we always register placeholder assumptions.
55+
self.placeholder_assumptions_for_next_solver.borrow().get(&u)?.as_ref().cloned()
5456
}
5557

5658
fn get_solver_region_constraint(

tests/ui/assumptions_on_binders/alias_outlives.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ compile-flags: -Znext-solver -Zassumptions-on-binders
22

3+
// FIXME: Eagerly normalizing added goals probably makes the diagnostics worse.
4+
35
// test that a `<T as AliasHaver>::Assoc: '!a_u1` constraint is considered to be satisfied
46
// if there's a `T::Assoc: 'static` assumption in the root universe and if not that it is
57
// an error :)
@@ -20,14 +22,16 @@ where
2022
<T as AliasHaver>::Assoc: 'static,
2123
{
2224
let _: ReqTrait<T::Assoc>;
25+
//~^ ERROR: type annotations needed
2326
}
2427

2528
fn borrowck_env_fail<'a, T: AliasHaver>()
26-
//~^ ERROR: unsatisfied lifetime constraint from -Zassumptions-on-binders
29+
// expected diagnostics: ERROR: unsatisfied lifetime constraint from -Zassumptions-on-binders
2730
where
2831
<T as AliasHaver>::Assoc: 'a,
2932
{
3033
let _: ReqTrait<T::Assoc>;
34+
//~^ ERROR: type annotations needed
3135
}
3236

3337
const REGIONCK_ENV_PASS<'a, T: AliasHaver>: ReqTrait<T::Assoc> = todo!()
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
error: unsatisfied lifetime constraint from -Zassumptions-on-binders :3
2-
--> $DIR/alias_outlives.rs:37:1
2+
--> $DIR/alias_outlives.rs:41:1
33
|
44
LL | const REGIONCK_ENV_FAIL<'a, T: AliasHaver>: ReqTrait<T::Assoc> = todo!()
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: meoow :c
88

9-
error: unsatisfied lifetime constraint from -Zassumptions-on-binders :3
10-
--> $DIR/alias_outlives.rs:25:1
9+
error[E0282]: type annotations needed
10+
--> $DIR/alias_outlives.rs:24:12
1111
|
12-
LL | / fn borrowck_env_fail<'a, T: AliasHaver>()
13-
LL | |
14-
LL | | where
15-
LL | | <T as AliasHaver>::Assoc: 'a,
16-
| |_________________________________^
12+
LL | let _: ReqTrait<T::Assoc>;
13+
| ^^^^^^^^^^^^^^^^^^ cannot infer type for struct `ReqTrait<<T as AliasHaver>::Assoc>`
14+
15+
error[E0282]: type annotations needed
16+
--> $DIR/alias_outlives.rs:33:12
1717
|
18-
= note: meoow :c
18+
LL | let _: ReqTrait<T::Assoc>;
19+
| ^^^^^^^^^^^^^^^^^^ cannot infer type for struct `ReqTrait<<T as AliasHaver>::Assoc>`
1920

20-
error: aborting due to 2 previous errors
21+
error: aborting due to 3 previous errors
2122

23+
For more information about this error, try `rustc --explain E0282`.

tests/ui/assumptions_on_binders/implied_higher_ranked_alias_outlives_assumption.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
//@ compile-flags: -Znext-solver -Zassumptions-on-binders
2-
//@ check-pass
32

43
#![feature(generic_const_items)]
54

5+
// FIXME: This should be `check-pass`. But eagerly normalizing added goals makes
6+
// it fail.
7+
68
// sorry for writing this
79
// - boxy
810

@@ -26,6 +28,7 @@ where
2628

2729
trait InnerBinder<'a, 'b, 'c> {}
2830
impl<'a, 'b, 'c, S> InnerBinder<'a, 'b, 'c> for S
31+
//~^ ERROR: type annotations needed: cannot satisfy `S: InnerBinder<'a, 'b, 'c>`
2932
where
3033
S: Trait<'a, 'b>,
3134
<S as Trait<'a, 'b>>::Assoc: 'c {}
@@ -44,9 +47,12 @@ where
4447
T: for<'a, 'b> Trait<'a, 'b>
4548
{
4649
let _: ReqTrait<'c, T>;
50+
//~^ ERROR: type annotations needed: cannot satisfy `for<'a, 'b> T: InnerBinder<'a, 'b, 'c>`
4751
}
4852

4953
const REGIONCK_ENV<'c, T>: ReqTrait<'c, T> = todo!()
54+
//~^ ERROR: type annotations needed: cannot satisfy `for<'a, 'b> T: InnerBinder<'a, 'b, 'c>`
55+
//~| ERROR: type annotations needed: cannot satisfy `for<'a, 'b> T: InnerBinder<'a, 'b, 'c>`
5056
where
5157
T: for<'a, 'b> Trait<'a, 'b>;
5258

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
error[E0283]: type annotations needed: cannot satisfy `S: InnerBinder<'a, 'b, 'c>`
2+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:30:49
3+
|
4+
LL | impl<'a, 'b, 'c, S> InnerBinder<'a, 'b, 'c> for S
5+
| ^
6+
|
7+
= note: cannot satisfy `S: InnerBinder<'a, 'b, 'c>`
8+
help: the trait `InnerBinder<'a, 'b, 'c>` is not implemented for `S`
9+
but trait `InnerBinder<'_, '_, '_>` is implemented for it
10+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:30:1
11+
|
12+
LL | / impl<'a, 'b, 'c, S> InnerBinder<'a, 'b, 'c> for S
13+
LL | |
14+
LL | | where
15+
LL | | S: Trait<'a, 'b>,
16+
LL | | <S as Trait<'a, 'b>>::Assoc: 'c {}
17+
| |___________________________________^
18+
19+
error[E0283]: type annotations needed: cannot satisfy `for<'a, 'b> T: InnerBinder<'a, 'b, 'c>`
20+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:53:28
21+
|
22+
LL | const REGIONCK_ENV<'c, T>: ReqTrait<'c, T> = todo!()
23+
| ^^^^^^^^^^^^^^^
24+
|
25+
= note: cannot satisfy `for<'a, 'b> T: InnerBinder<'a, 'b, 'c>`
26+
help: the trait `InnerBinder<'a, 'b, 'c>` is not implemented for `T`
27+
but trait `InnerBinder<'_, '_, '_>` is implemented for it
28+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:30:1
29+
|
30+
LL | / impl<'a, 'b, 'c, S> InnerBinder<'a, 'b, 'c> for S
31+
LL | |
32+
LL | | where
33+
LL | | S: Trait<'a, 'b>,
34+
LL | | <S as Trait<'a, 'b>>::Assoc: 'c {}
35+
| |___________________________________^
36+
note: required for `T` to implement `for<'a> OuterBinder<'a, 'c, ImpliedBound<'a, 'c, T>>`
37+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:37:21
38+
|
39+
LL | impl<'a, 'c, T0, S> OuterBinder<'a, 'c, T0> for S
40+
| ^^^^^^^^^^^^^^^^^^^^^^^ ^
41+
LL | where
42+
LL | for<'b> S: InnerBinder<'a, 'b, 'c>, {}
43+
| ----------------------- unsatisfied trait bound introduced here
44+
note: required by a bound in `ReqTrait`
45+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:43:16
46+
|
47+
LL | struct ReqTrait<'c, T>(&'c (), T)
48+
| -------- required by a bound in this struct
49+
LL | where
50+
LL | for<'a> T: OuterBinder<'a, 'c, ImpliedBound<'a, 'c, T>>,;
51+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ReqTrait`
52+
53+
error[E0283]: type annotations needed: cannot satisfy `for<'a, 'b> T: InnerBinder<'a, 'b, 'c>`
54+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:49:12
55+
|
56+
LL | let _: ReqTrait<'c, T>;
57+
| ^^^^^^^^^^^^^^^
58+
|
59+
= note: cannot satisfy `for<'a, 'b> T: InnerBinder<'a, 'b, 'c>`
60+
help: the trait `InnerBinder<'a, 'b, 'c>` is not implemented for `T`
61+
but trait `InnerBinder<'_, '_, '_>` is implemented for it
62+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:30:1
63+
|
64+
LL | / impl<'a, 'b, 'c, S> InnerBinder<'a, 'b, 'c> for S
65+
LL | |
66+
LL | | where
67+
LL | | S: Trait<'a, 'b>,
68+
LL | | <S as Trait<'a, 'b>>::Assoc: 'c {}
69+
| |___________________________________^
70+
note: required for `T` to implement `for<'a> OuterBinder<'a, 'c, ImpliedBound<'a, 'c, T>>`
71+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:37:21
72+
|
73+
LL | impl<'a, 'c, T0, S> OuterBinder<'a, 'c, T0> for S
74+
| ^^^^^^^^^^^^^^^^^^^^^^^ ^
75+
LL | where
76+
LL | for<'b> S: InnerBinder<'a, 'b, 'c>, {}
77+
| ----------------------- unsatisfied trait bound introduced here
78+
note: required by a bound in `ReqTrait`
79+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:43:16
80+
|
81+
LL | struct ReqTrait<'c, T>(&'c (), T)
82+
| -------- required by a bound in this struct
83+
LL | where
84+
LL | for<'a> T: OuterBinder<'a, 'c, ImpliedBound<'a, 'c, T>>,;
85+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ReqTrait`
86+
87+
error[E0283]: type annotations needed: cannot satisfy `for<'a, 'b> T: InnerBinder<'a, 'b, 'c>`
88+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:53:46
89+
|
90+
LL | const REGIONCK_ENV<'c, T>: ReqTrait<'c, T> = todo!()
91+
| ^^^^^^^
92+
|
93+
= note: cannot satisfy `for<'a, 'b> T: InnerBinder<'a, 'b, 'c>`
94+
help: the trait `InnerBinder<'a, 'b, 'c>` is not implemented for `T`
95+
but trait `InnerBinder<'_, '_, '_>` is implemented for it
96+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:30:1
97+
|
98+
LL | / impl<'a, 'b, 'c, S> InnerBinder<'a, 'b, 'c> for S
99+
LL | |
100+
LL | | where
101+
LL | | S: Trait<'a, 'b>,
102+
LL | | <S as Trait<'a, 'b>>::Assoc: 'c {}
103+
| |___________________________________^
104+
note: required for `T` to implement `for<'a> OuterBinder<'a, 'c, ImpliedBound<'a, 'c, T>>`
105+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:37:21
106+
|
107+
LL | impl<'a, 'c, T0, S> OuterBinder<'a, 'c, T0> for S
108+
| ^^^^^^^^^^^^^^^^^^^^^^^ ^
109+
LL | where
110+
LL | for<'b> S: InnerBinder<'a, 'b, 'c>, {}
111+
| ----------------------- unsatisfied trait bound introduced here
112+
note: required by a bound in `ReqTrait`
113+
--> $DIR/implied_higher_ranked_alias_outlives_assumption.rs:43:16
114+
|
115+
LL | struct ReqTrait<'c, T>(&'c (), T)
116+
| -------- required by a bound in this struct
117+
LL | where
118+
LL | for<'a> T: OuterBinder<'a, 'c, ImpliedBound<'a, 'c, T>>,;
119+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ReqTrait`
120+
121+
error: aborting due to 4 previous errors
122+
123+
For more information about this error, try `rustc --explain E0283`.

0 commit comments

Comments
 (0)