Skip to content

Commit 6873a76

Browse files
committed
remove leak-check from project
1 parent 70cf33f commit 6873a76

13 files changed

+132
-87
lines changed

src/librustc_trait_selection/traits/project.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,12 @@ pub fn poly_project_and_unify_type<'cx, 'tcx>(
149149
debug!("poly_project_and_unify_type(obligation={:?})", obligation);
150150

151151
let infcx = selcx.infcx();
152-
infcx.commit_if_ok(|snapshot| {
152+
infcx.commit_if_ok(|_snapshot| {
153153
let (placeholder_predicate, _) =
154154
infcx.replace_bound_vars_with_placeholders(&obligation.predicate);
155155

156156
let placeholder_obligation = obligation.with(placeholder_predicate);
157157
let result = project_and_unify_type(selcx, &placeholder_obligation)?;
158-
infcx.leak_check(false, snapshot).map_err(|err| MismatchedProjectionTypes { err })?;
159158
Ok(result)
160159
})
161160
}

src/test/ui/associated-types/associated-types-eq-hr.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@ pub fn call_bar() {
9494

9595
pub fn call_tuple_one() {
9696
tuple_one::<Tuple>();
97-
//~^ ERROR type mismatch
97+
//~^ ERROR implementation of `TheTrait` is not general enough
98+
//~| ERROR implementation of `TheTrait` is not general enough
9899
}
99100

100101
pub fn call_tuple_two() {
101102
tuple_two::<Tuple>();
102-
//~^ ERROR type mismatch
103+
//~^ ERROR implementation of `TheTrait` is not general enough
104+
//~| ERROR implementation of `TheTrait` is not general enough
103105
}
104106

105107
pub fn call_tuple_three() {

src/test/ui/associated-types/associated-types-eq-hr.stderr

+59-19
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,72 @@ LL | bar::<IntStruct>();
2828
= note: expected reference `&usize`
2929
found reference `&isize`
3030

31-
error[E0271]: type mismatch resolving `for<'x, 'y> <Tuple as TheTrait<(&'x isize, &'y isize)>>::A == &'x isize`
31+
error: implementation of `TheTrait` is not general enough
3232
--> $DIR/associated-types-eq-hr.rs:96:5
3333
|
34-
LL | fn tuple_one<T>()
35-
| --------- required by a bound in this
36-
LL | where
37-
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>,
38-
| ------------- required by this bound in `tuple_one`
34+
LL | / pub trait TheTrait<T> {
35+
LL | | type A;
36+
LL | |
37+
LL | | fn get(&self, t: T) -> Self::A;
38+
LL | | }
39+
| |_- trait `TheTrait` defined here
3940
...
40-
LL | tuple_one::<Tuple>();
41-
| ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime
41+
LL | tuple_one::<Tuple>();
42+
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
43+
|
44+
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
45+
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
4246

43-
error[E0271]: type mismatch resolving `for<'x, 'y> <Tuple as TheTrait<(&'x isize, &'y isize)>>::A == &'y isize`
44-
--> $DIR/associated-types-eq-hr.rs:101:5
47+
error: implementation of `TheTrait` is not general enough
48+
--> $DIR/associated-types-eq-hr.rs:96:5
4549
|
46-
LL | fn tuple_two<T>()
47-
| --------- required by a bound in this
48-
LL | where
49-
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>,
50-
| ------------- required by this bound in `tuple_two`
50+
LL | / pub trait TheTrait<T> {
51+
LL | | type A;
52+
LL | |
53+
LL | | fn get(&self, t: T) -> Self::A;
54+
LL | | }
55+
| |_- trait `TheTrait` defined here
5156
...
52-
LL | tuple_two::<Tuple>();
53-
| ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'y, found concrete lifetime
57+
LL | tuple_one::<Tuple>();
58+
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
59+
|
60+
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
61+
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
62+
63+
error: implementation of `TheTrait` is not general enough
64+
--> $DIR/associated-types-eq-hr.rs:102:5
65+
|
66+
LL | / pub trait TheTrait<T> {
67+
LL | | type A;
68+
LL | |
69+
LL | | fn get(&self, t: T) -> Self::A;
70+
LL | | }
71+
| |_- trait `TheTrait` defined here
72+
...
73+
LL | tuple_two::<Tuple>();
74+
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
75+
|
76+
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
77+
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
78+
79+
error: implementation of `TheTrait` is not general enough
80+
--> $DIR/associated-types-eq-hr.rs:102:5
81+
|
82+
LL | / pub trait TheTrait<T> {
83+
LL | | type A;
84+
LL | |
85+
LL | | fn get(&self, t: T) -> Self::A;
86+
LL | | }
87+
| |_- trait `TheTrait` defined here
88+
...
89+
LL | tuple_two::<Tuple>();
90+
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
91+
|
92+
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
93+
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
5494

5595
error: implementation of `TheTrait` is not general enough
56-
--> $DIR/associated-types-eq-hr.rs:110:5
96+
--> $DIR/associated-types-eq-hr.rs:112:5
5797
|
5898
LL | / pub trait TheTrait<T> {
5999
LL | | type A;
@@ -68,6 +108,6 @@ LL | tuple_four::<Tuple>();
68108
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
69109
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
70110

71-
error: aborting due to 5 previous errors
111+
error: aborting due to 7 previous errors
72112

73113
For more information about this error, try `rustc --explain E0271`.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
error[E0271]: type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _`
1+
error[E0308]: mismatched types
22
--> $DIR/higher-ranked-projection.rs:25:5
33
|
4-
LL | fn foo<U, T>(_t: T)
5-
| --- required by a bound in this
6-
LL | where for<'a> &'a T: Mirror<Image=U>
7-
| ------- required by this bound in `foo`
8-
...
94
LL | foo(());
10-
| ^^^ expected bound lifetime parameter 'a, found concrete lifetime
5+
| ^^^ one type is more general than the other
6+
|
7+
= note: expected type `&'a ()`
8+
found type `&()`
119

1210
error: aborting due to previous error
1311

14-
For more information about this error, try `rustc --explain E0271`.
12+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/associated-types/higher-ranked-projection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ fn foo<U, T>(_t: T)
2323
#[rustc_error]
2424
fn main() { //[good]~ ERROR fatal error triggered by #[rustc_error]
2525
foo(());
26-
//[bad]~^ ERROR type mismatch
26+
//[bad]~^ ERROR mismatched types
2727
}

src/test/ui/mismatched_types/closure-arg-type-mismatch.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ fn main() {
77

88
fn baz<F: Fn(*mut &u32)>(_: F) {}
99
fn _test<'a>(f: fn(*mut &'a u32)) {
10-
baz(f); //~ ERROR type mismatch
10+
baz(f);
11+
//~^ ERROR mismatched types
12+
//~| ERROR mismatched types
13+
//~| ERROR mismatched types
14+
//~| ERROR mismatched types
1115
}

src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr

+35-8
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,43 @@ LL | a.iter().map(|_: (u16, u16)| 45);
2222
| |
2323
| expected signature of `fn(&(u32, u32)) -> _`
2424

25-
error[E0271]: type mismatch resolving `for<'r> <fn(*mut &'a u32) as std::ops::FnOnce<(*mut &'r u32,)>>::Output == ()`
25+
error[E0308]: mismatched types
2626
--> $DIR/closure-arg-type-mismatch.rs:10:5
2727
|
28-
LL | fn baz<F: Fn(*mut &u32)>(_: F) {}
29-
| ------------- required by this bound in `baz`
30-
LL | fn _test<'a>(f: fn(*mut &'a u32)) {
3128
LL | baz(f);
32-
| ^^^ expected bound lifetime parameter, found concrete lifetime
29+
| ^^^ one type is more general than the other
30+
|
31+
= note: expected type `for<'r> std::ops::Fn<(*mut &'r u32,)>`
32+
found type `std::ops::Fn<(*mut &'a u32,)>`
33+
34+
error[E0308]: mismatched types
35+
--> $DIR/closure-arg-type-mismatch.rs:10:5
36+
|
37+
LL | baz(f);
38+
| ^^^ one type is more general than the other
39+
|
40+
= note: expected type `std::ops::FnOnce<(*mut &u32,)>`
41+
found type `std::ops::FnOnce<(*mut &'a u32,)>`
42+
43+
error[E0308]: mismatched types
44+
--> $DIR/closure-arg-type-mismatch.rs:10:5
45+
|
46+
LL | baz(f);
47+
| ^^^ one type is more general than the other
48+
|
49+
= note: expected type `for<'r> std::ops::Fn<(*mut &'r u32,)>`
50+
found type `std::ops::Fn<(*mut &'a u32,)>`
51+
52+
error[E0308]: mismatched types
53+
--> $DIR/closure-arg-type-mismatch.rs:10:5
54+
|
55+
LL | baz(f);
56+
| ^^^ one type is more general than the other
57+
|
58+
= note: expected type `std::ops::FnOnce<(*mut &u32,)>`
59+
found type `std::ops::FnOnce<(*mut &'a u32,)>`
3360

34-
error: aborting due to 4 previous errors
61+
error: aborting due to 7 previous errors
3562

36-
Some errors have detailed explanations: E0271, E0631.
37-
For more information about an error, try `rustc --explain E0271`.
63+
Some errors have detailed explanations: E0308, E0631.
64+
For more information about an error, try `rustc --explain E0308`.

src/test/ui/mismatched_types/closure-mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ impl<T: Fn(&())> Foo for T {}
55
fn baz<T: Foo>(_: T) {}
66

77
fn main() {
8-
baz(|_| ()); //~ ERROR type mismatch
8+
baz(|_| ()); //~ ERROR mismatched types
99
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/closure-mismatch.rs:8:9: 8:15] as std::ops::FnOnce<(&'r (),)>>::Output == ()`
1+
error[E0308]: mismatched types
22
--> $DIR/closure-mismatch.rs:8:5
33
|
4-
LL | fn baz<T: Foo>(_: T) {}
5-
| --- required by this bound in `baz`
6-
...
74
LL | baz(|_| ());
8-
| ^^^ expected bound lifetime parameter, found concrete lifetime
5+
| ^^^ one type is more general than the other
96
|
10-
= note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:8:9: 8:15]`
7+
= note: expected type `for<'r> std::ops::Fn<(&'r (),)>`
8+
found type `std::ops::Fn<(&(),)>`
119

1210
error: aborting due to previous error
1311

14-
For more information about this error, try `rustc --explain E0271`.
12+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/rfc1623.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@ static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 =
1111
struct SomeStruct<'x, 'y, 'z: 'x> {
1212
foo: &'x Foo<'z>,
1313
bar: &'x Bar<'z>,
14-
f: &'y dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Bar<'b>,
14+
f: &'y dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Foo<'b>,
1515
}
1616

1717
fn id<T>(t: T) -> T {
1818
t
1919
}
2020

21-
static SOME_STRUCT: &SomeStruct = SomeStruct {
22-
//~^ ERROR mismatched types
21+
static SOME_STRUCT: &SomeStruct = &SomeStruct {
2322
foo: &Foo { bools: &[false, true] },
2423
bar: &Bar { bools: &[true, true] },
2524
f: &id,
26-
//~^ ERROR type mismatch resolving
25+
//~^ ERROR mismatched types
2726
};
2827

2928
// very simple test for a 'static static with default lifetime

src/test/ui/rfc1623.stderr

+6-29
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,12 @@
11
error[E0308]: mismatched types
2-
--> $DIR/rfc1623.rs:21:35
3-
|
4-
LL | static SOME_STRUCT: &SomeStruct = SomeStruct {
5-
| ___________________________________^
6-
LL | |
7-
LL | | foo: &Foo { bools: &[false, true] },
8-
LL | | bar: &Bar { bools: &[true, true] },
9-
LL | | f: &id,
10-
LL | |
11-
LL | | };
12-
| |_^ expected `&SomeStruct<'static, 'static, 'static>`, found struct `SomeStruct`
13-
|
14-
help: consider borrowing here
15-
|
16-
LL | static SOME_STRUCT: &SomeStruct = &SomeStruct {
17-
LL |
18-
LL | foo: &Foo { bools: &[false, true] },
19-
LL | bar: &Bar { bools: &[true, true] },
20-
LL | f: &id,
21-
LL |
22-
...
23-
24-
error[E0271]: type mismatch resolving `for<'a, 'b> <fn(&Foo<'_>) -> &Foo<'_> {id::<&Foo<'_>>} as std::ops::FnOnce<(&'a Foo<'b>,)>>::Output == &'a Foo<'b>`
25-
--> $DIR/rfc1623.rs:25:8
2+
--> $DIR/rfc1623.rs:24:8
263
|
274
LL | f: &id,
28-
| ^^^ expected bound lifetime parameter 'a, found concrete lifetime
5+
| ^^^ one type is more general than the other
296
|
30-
= note: required for the cast to the object type `dyn for<'a, 'b> std::ops::Fn(&'a Foo<'b>) -> &'a Foo<'b>`
7+
= note: expected type `std::ops::FnOnce<(&'a Foo<'b>,)>`
8+
found type `std::ops::FnOnce<(&Foo<'_>,)>`
319

32-
error: aborting due to 2 previous errors
10+
error: aborting due to previous error
3311

34-
Some errors have detailed explanations: E0271, E0308.
35-
For more information about an error, try `rustc --explain E0271`.
12+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct X;
1515

1616
impl Foo for X {
1717
type Bar = impl Baz<Self, Self>;
18-
//~^ ERROR type mismatch resolving
18+
//~^ ERROR mismatched types
1919

2020
fn bar(&self) -> Self::Bar {
2121
|x| x
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-57611-trait-alias.rs:21:9: 21:14] as std::ops::FnOnce<(&'r X,)>>::Output == &'r X`
1+
error[E0308]: mismatched types
22
--> $DIR/issue-57611-trait-alias.rs:17:16
33
|
44
LL | type Bar = impl Baz<Self, Self>;
5-
| ^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime
5+
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
66
|
7-
= note: the return type of a function must have a statically known size
7+
= note: expected type `std::ops::FnOnce<(&X,)>`
8+
found type `std::ops::FnOnce<(&X,)>`
89

910
error: aborting due to previous error
1011

11-
For more information about this error, try `rustc --explain E0271`.
12+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)