Skip to content

Commit 4f968f1

Browse files
authored
Rollup merge of #163271 - lcnr:add-leak-check-test, r=lqd
add a leak check test it's jank r? types
2 parents f43cc4d + 288a941 commit 4f968f1

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0283]: type annotations needed
2+
--> $DIR/constraint-from-nested-projection.rs:31:5
3+
|
4+
LL | pick::<(), _>();
5+
| ^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `pick`
6+
|
7+
note: multiple `impl`s satisfying `(): Pick<_>` found
8+
--> $DIR/constraint-from-nested-projection.rs:25:1
9+
|
10+
LL | impl<T: for<'a> RequiresProject<'a>> Pick<u32> for T {}
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
LL | impl<T> Pick<u16> for T {}
13+
| ^^^^^^^^^^^^^^^^^^^^^^^
14+
note: required by a bound in `pick`
15+
--> $DIR/constraint-from-nested-projection.rs:28:12
16+
|
17+
LL | fn pick<T: Pick<U>, U>() {}
18+
| ^^^^^^^ required by this bound in `pick`
19+
20+
error: aborting due to 1 previous error
21+
22+
For more information about this error, try `rustc --explain E0283`.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//@ revisions: old next
2+
//@[next] compile-flags: -Znext-solver
3+
//@[old] check-pass
4+
5+
// Evaluate in the old solver does apply constraints from nested `Projection` obligations,
6+
// as they can constrain otherwise unconstrained inference variables. This also allows
7+
// `Projection` goals to otherwise influence its parent obligation by returning constraints
8+
// from matching the impl header.
9+
//
10+
// The new solver entirely ignores region constraints from nested goals in the leak check.
11+
// This is the one case where the the implementation of the new solver will actually weaken
12+
// the leak check.
13+
14+
trait ProjectStatic<'a> {
15+
type Assoc;
16+
}
17+
impl ProjectStatic<'static> for () {
18+
type Assoc = u32;
19+
}
20+
21+
trait RequiresProject<'a> {}
22+
impl<'a, T: ProjectStatic<'a, Assoc = u32>> RequiresProject<'a> for T {}
23+
24+
trait Pick<T> {}
25+
impl<T: for<'a> RequiresProject<'a>> Pick<u32> for T {}
26+
impl<T> Pick<u16> for T {}
27+
28+
fn pick<T: Pick<U>, U>() {}
29+
30+
fn main() {
31+
pick::<(), _>();
32+
//[next]~^ ERROR: type annotations needed
33+
}

0 commit comments

Comments
 (0)