Skip to content

Commit

Permalink
remove leak-check from project
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Jun 22, 2020
1 parent 70cf33f commit 6873a76
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 87 deletions.
3 changes: 1 addition & 2 deletions src/librustc_trait_selection/traits/project.rs
Expand Up @@ -149,13 +149,12 @@ pub fn poly_project_and_unify_type<'cx, 'tcx>(
debug!("poly_project_and_unify_type(obligation={:?})", obligation);

let infcx = selcx.infcx();
infcx.commit_if_ok(|snapshot| {
infcx.commit_if_ok(|_snapshot| {
let (placeholder_predicate, _) =
infcx.replace_bound_vars_with_placeholders(&obligation.predicate);

let placeholder_obligation = obligation.with(placeholder_predicate);
let result = project_and_unify_type(selcx, &placeholder_obligation)?;
infcx.leak_check(false, snapshot).map_err(|err| MismatchedProjectionTypes { err })?;
Ok(result)
})
}
Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/associated-types/associated-types-eq-hr.rs
Expand Up @@ -94,12 +94,14 @@ pub fn call_bar() {

pub fn call_tuple_one() {
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() {
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() {
Expand Down
78 changes: 59 additions & 19 deletions src/test/ui/associated-types/associated-types-eq-hr.stderr
Expand Up @@ -28,32 +28,72 @@ LL | bar::<IntStruct>();
= note: expected reference `&usize`
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
|
LL | fn tuple_one<T>()
| --------- required by a bound in this
LL | where
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>,
| ------------- required by this bound in `tuple_one`
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>();
| ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime
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[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
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5
|
LL | fn tuple_two<T>()
| --------- required by a bound in this
LL | where
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>,
| ------------- required by this bound in `tuple_two`
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>();
| ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'y, found concrete lifetime
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:110:5
--> $DIR/associated-types-eq-hr.rs:112:5
|
LL | / pub trait TheTrait<T> {
LL | | type A;
Expand All @@ -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: ...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`.
14 changes: 6 additions & 8 deletions src/test/ui/associated-types/higher-ranked-projection.bad.stderr
@@ -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
|
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(());
| ^^^ 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

For more information about this error, try `rustc --explain E0271`.
For more information about this error, try `rustc --explain E0308`.
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/higher-ranked-projection.rs
Expand Up @@ -23,5 +23,5 @@ fn foo<U, T>(_t: T)
#[rustc_error]
fn main() { //[good]~ ERROR fatal error triggered by #[rustc_error]
foo(());
//[bad]~^ ERROR type mismatch
//[bad]~^ ERROR mismatched types
}
6 changes: 5 additions & 1 deletion src/test/ui/mismatched_types/closure-arg-type-mismatch.rs
Expand Up @@ -7,5 +7,9 @@ fn main() {

fn baz<F: Fn(*mut &u32)>(_: F) {}
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
}
43 changes: 35 additions & 8 deletions src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr
Expand Up @@ -22,16 +22,43 @@ LL | a.iter().map(|_: (u16, u16)| 45);
| |
| 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
|
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);
| ^^^ 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[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[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 `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 4 previous errors
error: aborting due to 7 previous errors

Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.
Some errors have detailed explanations: E0308, E0631.
For more information about an error, try `rustc --explain E0308`.
2 changes: 1 addition & 1 deletion src/test/ui/mismatched_types/closure-mismatch.rs
Expand Up @@ -5,5 +5,5 @@ impl<T: Fn(&())> Foo for T {}
fn baz<T: Foo>(_: T) {}

fn main() {
baz(|_| ()); //~ ERROR type mismatch
baz(|_| ()); //~ ERROR mismatched types
}
12 changes: 5 additions & 7 deletions src/test/ui/mismatched_types/closure-mismatch.stderr
@@ -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
|
LL | fn baz<T: Foo>(_: T) {}
| --- required by this bound in `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

For more information about this error, try `rustc --explain E0271`.
For more information about this error, try `rustc --explain E0308`.
7 changes: 3 additions & 4 deletions src/test/ui/rfc1623.rs
Expand Up @@ -11,19 +11,18 @@ static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 =
struct SomeStruct<'x, 'y, 'z: 'x> {
foo: &'x Foo<'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 {
t
}

static SOME_STRUCT: &SomeStruct = SomeStruct {
//~^ ERROR mismatched types
static SOME_STRUCT: &SomeStruct = &SomeStruct {
foo: &Foo { bools: &[false, true] },
bar: &Bar { bools: &[true, true] },
f: &id,
//~^ ERROR type mismatch resolving
//~^ ERROR mismatched types
};

// very simple test for a 'static static with default lifetime
Expand Down
35 changes: 6 additions & 29 deletions src/test/ui/rfc1623.stderr
@@ -1,35 +1,12 @@
error[E0308]: mismatched types
--> $DIR/rfc1623.rs:21:35
|
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
--> $DIR/rfc1623.rs:24:8
|
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 an error, try `rustc --explain E0271`.
For more information about this error, try `rustc --explain E0308`.
Expand Up @@ -15,7 +15,7 @@ struct X;

impl Foo for X {
type Bar = impl Baz<Self, Self>;
//~^ ERROR type mismatch resolving
//~^ ERROR mismatched types

fn bar(&self) -> Self::Bar {
|x| x
Expand Down
@@ -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
|
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

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

0 comments on commit 6873a76

Please sign in to comment.