remove leak-check from project

This commit is contained in:
Niko Matsakis 2020-05-22 18:16:28 +00:00
parent 70cf33fcca
commit 6873a76f2c
13 changed files with 134 additions and 89 deletions

View file

@ -149,13 +149,12 @@ pub fn poly_project_and_unify_type<'cx, 'tcx>(
debug!("poly_project_and_unify_type(obligation={:?})", obligation); debug!("poly_project_and_unify_type(obligation={:?})", obligation);
let infcx = selcx.infcx(); let infcx = selcx.infcx();
infcx.commit_if_ok(|snapshot| { infcx.commit_if_ok(|_snapshot| {
let (placeholder_predicate, _) = let (placeholder_predicate, _) =
infcx.replace_bound_vars_with_placeholders(&obligation.predicate); infcx.replace_bound_vars_with_placeholders(&obligation.predicate);
let placeholder_obligation = obligation.with(placeholder_predicate); let placeholder_obligation = obligation.with(placeholder_predicate);
let result = project_and_unify_type(selcx, &placeholder_obligation)?; let result = project_and_unify_type(selcx, &placeholder_obligation)?;
infcx.leak_check(false, snapshot).map_err(|err| MismatchedProjectionTypes { err })?;
Ok(result) Ok(result)
}) })
} }

View file

@ -94,12 +94,14 @@ pub fn call_bar() {
pub fn call_tuple_one() { pub fn call_tuple_one() {
tuple_one::<Tuple>(); tuple_one::<Tuple>();
//~^ ERROR type mismatch //~^ ERROR implementation of `TheTrait` is not general enough
//~| ERROR implementation of `TheTrait` is not general enough
} }
pub fn call_tuple_two() { pub fn call_tuple_two() {
tuple_two::<Tuple>(); tuple_two::<Tuple>();
//~^ ERROR type mismatch //~^ ERROR implementation of `TheTrait` is not general enough
//~| ERROR implementation of `TheTrait` is not general enough
} }
pub fn call_tuple_three() { pub fn call_tuple_three() {

View file

@ -28,32 +28,72 @@ LL | bar::<IntStruct>();
= note: expected reference `&usize` = note: expected reference `&usize`
found reference `&isize` found reference `&isize`
error[E0271]: type mismatch resolving `for<'x, 'y> <Tuple as TheTrait<(&'x isize, &'y isize)>>::A == &'x isize` error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5 --> $DIR/associated-types-eq-hr.rs:96:5
| |
LL | fn tuple_one<T>() LL | / pub trait TheTrait<T> {
| --------- required by a bound in this LL | | type A;
LL | where LL | |
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>, LL | | fn get(&self, t: T) -> Self::A;
| ------------- required by this bound in `tuple_one` LL | | }
| |_- trait `TheTrait` defined here
... ...
LL | tuple_one::<Tuple>(); LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
error[E0271]: type mismatch resolving `for<'x, 'y> <Tuple as TheTrait<(&'x isize, &'y isize)>>::A == &'y isize`
--> $DIR/associated-types-eq-hr.rs:101:5
| |
LL | fn tuple_two<T>() = note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
| --------- required by a bound in this = note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
LL | where
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>,
| ------------- required by this bound in `tuple_two`
...
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'y, found concrete lifetime
error: implementation of `TheTrait` is not general enough error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:110:5 --> $DIR/associated-types-eq-hr.rs:96:5
|
LL | / pub trait TheTrait<T> {
LL | | type A;
LL | |
LL | | fn get(&self, t: T) -> Self::A;
LL | | }
| |_- trait `TheTrait` defined here
...
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:102:5
|
LL | / pub trait TheTrait<T> {
LL | | type A;
LL | |
LL | | fn get(&self, t: T) -> Self::A;
LL | | }
| |_- trait `TheTrait` defined here
...
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:102:5
|
LL | / pub trait TheTrait<T> {
LL | | type A;
LL | |
LL | | fn get(&self, t: T) -> Self::A;
LL | | }
| |_- trait `TheTrait` defined here
...
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:112:5
| |
LL | / pub trait TheTrait<T> { LL | / pub trait TheTrait<T> {
LL | | type A; LL | | type A;
@ -68,6 +108,6 @@ LL | tuple_four::<Tuple>();
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... = note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` = note: ...but `Tuple` actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
error: aborting due to 5 previous errors error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0271`. For more information about this error, try `rustc --explain E0271`.

View file

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

View file

@ -23,5 +23,5 @@ fn foo<U, T>(_t: T)
#[rustc_error] #[rustc_error]
fn main() { //[good]~ ERROR fatal error triggered by #[rustc_error] fn main() { //[good]~ ERROR fatal error triggered by #[rustc_error]
foo(()); foo(());
//[bad]~^ ERROR type mismatch //[bad]~^ ERROR mismatched types
} }

View file

@ -7,5 +7,9 @@ fn main() {
fn baz<F: Fn(*mut &u32)>(_: F) {} fn baz<F: Fn(*mut &u32)>(_: F) {}
fn _test<'a>(f: fn(*mut &'a u32)) { fn _test<'a>(f: fn(*mut &'a u32)) {
baz(f); //~ ERROR type mismatch baz(f);
//~^ ERROR mismatched types
//~| ERROR mismatched types
//~| ERROR mismatched types
//~| ERROR mismatched types
} }

View file

@ -22,16 +22,43 @@ LL | a.iter().map(|_: (u16, u16)| 45);
| | | |
| expected signature of `fn(&(u32, u32)) -> _` | expected signature of `fn(&(u32, u32)) -> _`
error[E0271]: type mismatch resolving `for<'r> <fn(*mut &'a u32) as std::ops::FnOnce<(*mut &'r u32,)>>::Output == ()` error[E0308]: mismatched types
--> $DIR/closure-arg-type-mismatch.rs:10:5 --> $DIR/closure-arg-type-mismatch.rs:10:5
| |
LL | fn baz<F: Fn(*mut &u32)>(_: F) {}
| ------------- required by this bound in `baz`
LL | fn _test<'a>(f: fn(*mut &'a u32)) {
LL | baz(f); LL | baz(f);
| ^^^ expected bound lifetime parameter, found concrete lifetime | ^^^ one type is more general than the other
|
= note: expected type `for<'r> std::ops::Fn<(*mut &'r u32,)>`
found type `std::ops::Fn<(*mut &'a u32,)>`
error: aborting due to 4 previous errors error[E0308]: mismatched types
--> $DIR/closure-arg-type-mismatch.rs:10:5
|
LL | baz(f);
| ^^^ one type is more general than the other
|
= note: expected type `std::ops::FnOnce<(*mut &u32,)>`
found type `std::ops::FnOnce<(*mut &'a u32,)>`
Some errors have detailed explanations: E0271, E0631. error[E0308]: mismatched types
For more information about an error, try `rustc --explain E0271`. --> $DIR/closure-arg-type-mismatch.rs:10:5
|
LL | baz(f);
| ^^^ one type is more general than the other
|
= note: expected type `for<'r> std::ops::Fn<(*mut &'r u32,)>`
found type `std::ops::Fn<(*mut &'a u32,)>`
error[E0308]: mismatched types
--> $DIR/closure-arg-type-mismatch.rs:10:5
|
LL | baz(f);
| ^^^ one type is more general than the other
|
= note: expected type `std::ops::FnOnce<(*mut &u32,)>`
found type `std::ops::FnOnce<(*mut &'a u32,)>`
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0308, E0631.
For more information about an error, try `rustc --explain E0308`.

View file

@ -5,5 +5,5 @@ impl<T: Fn(&())> Foo for T {}
fn baz<T: Foo>(_: T) {} fn baz<T: Foo>(_: T) {}
fn main() { fn main() {
baz(|_| ()); //~ ERROR type mismatch baz(|_| ()); //~ ERROR mismatched types
} }

View file

@ -1,14 +1,12 @@
error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/closure-mismatch.rs:8:9: 8:15] as std::ops::FnOnce<(&'r (),)>>::Output == ()` error[E0308]: mismatched types
--> $DIR/closure-mismatch.rs:8:5 --> $DIR/closure-mismatch.rs:8:5
| |
LL | fn baz<T: Foo>(_: T) {}
| --- required by this bound in `baz`
...
LL | baz(|_| ()); LL | baz(|_| ());
| ^^^ expected bound lifetime parameter, found concrete lifetime | ^^^ one type is more general than the other
| |
= note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:8:9: 8:15]` = note: expected type `for<'r> std::ops::Fn<(&'r (),)>`
found type `std::ops::Fn<(&(),)>`
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0271`. For more information about this error, try `rustc --explain E0308`.

View file

@ -11,19 +11,18 @@ static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 =
struct SomeStruct<'x, 'y, 'z: 'x> { struct SomeStruct<'x, 'y, 'z: 'x> {
foo: &'x Foo<'z>, foo: &'x Foo<'z>,
bar: &'x Bar<'z>, bar: &'x Bar<'z>,
f: &'y dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Bar<'b>, f: &'y dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Foo<'b>,
} }
fn id<T>(t: T) -> T { fn id<T>(t: T) -> T {
t t
} }
static SOME_STRUCT: &SomeStruct = SomeStruct { static SOME_STRUCT: &SomeStruct = &SomeStruct {
//~^ ERROR mismatched types
foo: &Foo { bools: &[false, true] }, foo: &Foo { bools: &[false, true] },
bar: &Bar { bools: &[true, true] }, bar: &Bar { bools: &[true, true] },
f: &id, f: &id,
//~^ ERROR type mismatch resolving //~^ ERROR mismatched types
}; };
// very simple test for a 'static static with default lifetime // very simple test for a 'static static with default lifetime

View file

@ -1,35 +1,12 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/rfc1623.rs:21:35 --> $DIR/rfc1623.rs:24:8
|
LL | static SOME_STRUCT: &SomeStruct = SomeStruct {
| ___________________________________^
LL | |
LL | | foo: &Foo { bools: &[false, true] },
LL | | bar: &Bar { bools: &[true, true] },
LL | | f: &id,
LL | |
LL | | };
| |_^ expected `&SomeStruct<'static, 'static, 'static>`, found struct `SomeStruct`
|
help: consider borrowing here
|
LL | static SOME_STRUCT: &SomeStruct = &SomeStruct {
LL |
LL | foo: &Foo { bools: &[false, true] },
LL | bar: &Bar { bools: &[true, true] },
LL | f: &id,
LL |
...
error[E0271]: type mismatch resolving `for<'a, 'b> <fn(&Foo<'_>) -> &Foo<'_> {id::<&Foo<'_>>} as std::ops::FnOnce<(&'a Foo<'b>,)>>::Output == &'a Foo<'b>`
--> $DIR/rfc1623.rs:25:8
| |
LL | f: &id, LL | f: &id,
| ^^^ expected bound lifetime parameter 'a, found concrete lifetime | ^^^ one type is more general than the other
| |
= note: required for the cast to the object type `dyn for<'a, 'b> std::ops::Fn(&'a Foo<'b>) -> &'a Foo<'b>` = note: expected type `std::ops::FnOnce<(&'a Foo<'b>,)>`
found type `std::ops::FnOnce<(&Foo<'_>,)>`
error: aborting due to 2 previous errors error: aborting due to previous error
Some errors have detailed explanations: E0271, E0308. For more information about this error, try `rustc --explain E0308`.
For more information about an error, try `rustc --explain E0271`.

View file

@ -15,7 +15,7 @@ struct X;
impl Foo for X { impl Foo for X {
type Bar = impl Baz<Self, Self>; type Bar = impl Baz<Self, Self>;
//~^ ERROR type mismatch resolving //~^ ERROR mismatched types
fn bar(&self) -> Self::Bar { fn bar(&self) -> Self::Bar {
|x| x |x| x

View file

@ -1,11 +1,12 @@
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` error[E0308]: mismatched types
--> $DIR/issue-57611-trait-alias.rs:17:16 --> $DIR/issue-57611-trait-alias.rs:17:16
| |
LL | type Bar = impl Baz<Self, Self>; LL | type Bar = impl Baz<Self, Self>;
| ^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime | ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
| |
= note: the return type of a function must have a statically known size = note: expected type `std::ops::FnOnce<(&X,)>`
found type `std::ops::FnOnce<(&X,)>`
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0271`. For more information about this error, try `rustc --explain E0308`.