Rollup merge of #72493 - nikomatsakis:move-leak-check, r=matthewjasper

move leak-check to during coherence, candidate eval

Implementation of MCP https://github.com/rust-lang/compiler-team/issues/295.

I'd like to do a crater run on this.

Note to @rust-lang/lang: This PR is a breaking change (bugfix). It causes tests like the following to go from a future-compatibility warning #56105 to a hard error:

```rust
trait Trait {}
impl Trait for for<'a, 'b> fn(&'a u32, &'b u32) {}
impl Trait for for<'c> fn(&'c u32, &'c u32) {} // now rejected, used to warn
```

I am not aware of any instances of this code in the wild, but that is why we are doing a crater run. The reason for this change is that those two types are, in fact, the same type, and hence the two impls are overlapping.

There will still be impls that trigger #56105 after this lands, however -- I hope that we will eventually just accept those impls without warning, for the most part. One example of such an impl is this pattern, which is used by wasm-bindgen and other crates as well:

```rust
trait Trait {}
impl<T> Trait for fn(&T) { }
impl<T> Trait for fn(T) { } // still accepted, but warns
```
This commit is contained in:
Manish Goregaokar 2020-06-23 00:33:52 -07:00 committed by GitHub
commit 903823c59b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
135 changed files with 2143 additions and 1250 deletions

View file

@ -0,0 +1,33 @@
error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
--> $DIR/associated-types-eq-hr.rs:87:5
|
LL | fn foo<T>()
| --- required by a bound in this
LL | where
LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>,
| ------------- required by this bound in `foo`
...
LL | foo::<UintStruct>();
| ^^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
|
= note: expected reference `&isize`
found reference `&usize`
error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
--> $DIR/associated-types-eq-hr.rs:91:5
|
LL | fn bar<T>()
| --- required by a bound in this
LL | where
LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>,
| ------------- required by this bound in `bar`
...
LL | bar::<IntStruct>();
| ^^^^^^^^^^^^^^^^ expected `usize`, found `isize`
|
= note: expected reference `&usize`
found reference `&isize`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0271`.

View file

@ -7,7 +7,7 @@ pub trait TheTrait<T> {
}
struct IntStruct {
x: isize
x: isize,
}
impl<'a> TheTrait<&'a isize> for IntStruct {
@ -19,7 +19,7 @@ impl<'a> TheTrait<&'a isize> for IntStruct {
}
struct UintStruct {
x: isize
x: isize,
}
impl<'a> TheTrait<&'a isize> for UintStruct {
@ -30,8 +30,7 @@ impl<'a> TheTrait<&'a isize> for UintStruct {
}
}
struct Tuple {
}
struct Tuple {}
impl<'a> TheTrait<(&'a isize, &'a isize)> for Tuple {
type A = &'a isize;
@ -42,37 +41,43 @@ impl<'a> TheTrait<(&'a isize, &'a isize)> for Tuple {
}
fn foo<T>()
where T : for<'x> TheTrait<&'x isize, A = &'x isize>
where
T: for<'x> TheTrait<&'x isize, A = &'x isize>,
{
// ok for IntStruct, but not UintStruct
}
fn bar<T>()
where T : for<'x> TheTrait<&'x isize, A = &'x usize>
where
T: for<'x> TheTrait<&'x isize, A = &'x usize>,
{
// ok for UintStruct, but not IntStruct
}
fn tuple_one<T>()
where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>
where
T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>,
{
// not ok for tuple, two lifetimes and we pick first
}
fn tuple_two<T>()
where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>
where
T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>,
{
// not ok for tuple, two lifetimes and we pick second
}
fn tuple_three<T>()
where T : for<'x> TheTrait<(&'x isize, &'x isize), A = &'x isize>
where
T: for<'x> TheTrait<(&'x isize, &'x isize), A = &'x isize>,
{
// ok for tuple
}
fn tuple_four<T>()
where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)>
where
T: for<'x, 'y> TheTrait<(&'x isize, &'y isize)>,
{
// not ok for tuple, two lifetimes, and lifetime matching is invariant
}
@ -89,14 +94,14 @@ pub fn call_bar() {
pub fn call_tuple_one() {
tuple_one::<Tuple>();
//~^ ERROR not satisfied
//~| 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 not satisfied
//~| ERROR type mismatch
//~^ ERROR implementation of `TheTrait` is not general enough
//~| ERROR implementation of `TheTrait` is not general enough
}
pub fn call_tuple_three() {
@ -105,7 +110,7 @@ pub fn call_tuple_three() {
pub fn call_tuple_four() {
tuple_four::<Tuple>();
//~^ ERROR not satisfied
//~^ ERROR implementation of `TheTrait` is not general enough
}
fn main() { }
fn main() {}

View file

@ -1,10 +1,11 @@
error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
--> $DIR/associated-types-eq-hr.rs:82:5
--> $DIR/associated-types-eq-hr.rs:87:5
|
LL | fn foo<T>()
| --- required by a bound in this
LL | where T : for<'x> TheTrait<&'x isize, A = &'x isize>
| ------------- required by this bound in `foo`
LL | where
LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>,
| ------------- required by this bound in `foo`
...
LL | foo::<UintStruct>();
| ^^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
@ -13,12 +14,13 @@ LL | foo::<UintStruct>();
found reference `&usize`
error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
--> $DIR/associated-types-eq-hr.rs:86:5
--> $DIR/associated-types-eq-hr.rs:91:5
|
LL | fn bar<T>()
| --- required by a bound in this
LL | where T : for<'x> TheTrait<&'x isize, A = &'x usize>
| ------------- required by this bound in `bar`
LL | where
LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>,
| ------------- required by this bound in `bar`
...
LL | bar::<IntStruct>();
| ^^^^^^^^^^^^^^^^ expected `usize`, found `isize`
@ -26,71 +28,86 @@ LL | bar::<IntStruct>();
= note: expected reference `&usize`
found reference `&isize`
error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied
--> $DIR/associated-types-eq-hr.rs:91:17
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 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>();
| ^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple`
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= help: the following implementations were found:
<Tuple as TheTrait<(&'a isize, &'a isize)>>
= 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 == &'x isize`
--> $DIR/associated-types-eq-hr.rs:91:5
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 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[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied
--> $DIR/associated-types-eq-hr.rs:97:17
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:102:5
|
LL | fn tuple_two<T>()
| --------- required by a bound in this
LL | where 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>();
| ^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple`
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= help: the following implementations were found:
<Tuple as TheTrait<(&'a isize, &'a isize)>>
= 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:97:5
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:102:5
|
LL | fn tuple_two<T>()
| --------- required by a bound in this
LL | where 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 'x, found concrete lifetime
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[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied
--> $DIR/associated-types-eq-hr.rs:107:18
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:112:5
|
LL | fn tuple_four<T>()
| ---------- required by a bound in this
LL | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)>
| ------------------------------------------- required by this bound in `tuple_four`
LL | / pub trait TheTrait<T> {
LL | | type A;
LL | |
LL | | fn get(&self, t: T) -> Self::A;
LL | | }
| |_- trait `TheTrait` defined here
...
LL | tuple_four::<Tuple>();
| ^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple`
LL | tuple_four::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= help: the following implementations were found:
<Tuple as TheTrait<(&'a isize, &'a isize)>>
= 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 7 previous errors
Some errors have detailed explanations: E0271, E0277.
For more information about an error, try `rustc --explain E0271`.
For more information about this error, try `rustc --explain E0271`.

View file

@ -1,26 +1,26 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:55:4
--> $DIR/project-fn-ret-invariant.rs:56:5
|
LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | (a, b)
| ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
LL | (a, b)
| ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
|
= help: consider adding the following bound: `'a: 'b`
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:55:4
--> $DIR/project-fn-ret-invariant.rs:56:5
|
LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | (a, b)
| ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
LL | (a, b)
| ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
|
= help: consider adding the following bound: `'b: 'a`

View file

@ -1,23 +1,23 @@
error[E0623]: lifetime mismatch
--> $DIR/project-fn-ret-invariant.rs:53:21
--> $DIR/project-fn-ret-invariant.rs:54:22
|
LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -------- --------------------
| |
| this parameter and the return type are declared with different lifetimes...
LL | let a = bar(foo, y);
| ^ ...but data from `x` is returned here
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -------- --------------------
| |
| this parameter and the return type are declared with different lifetimes...
LL | let a = bar(foo, y);
| ^ ...but data from `x` is returned here
error[E0623]: lifetime mismatch
--> $DIR/project-fn-ret-invariant.rs:54:21
--> $DIR/project-fn-ret-invariant.rs:56:9
|
LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -------- --------------------
| |
| this parameter and the return type are declared with different lifetimes...
LL | let a = bar(foo, y);
LL | let b = bar(foo, x);
| ^ ...but data from `y` is returned here
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -------- --------------------
| |
| this parameter and the return type are declared with different lifetimes...
...
LL | (a, b)
| ^ ...but data from `x` is returned here
error: aborting due to 2 previous errors

View file

@ -1,8 +1,8 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/project-fn-ret-invariant.rs:59:1
--> $DIR/project-fn-ret-invariant.rs:60:1
|
LL | fn main() { }
| ^^^^^^^^^^^^^
LL | fn main() {}
| ^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -1,26 +1,26 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:38:12
--> $DIR/project-fn-ret-invariant.rs:39:13
|
LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | let f = foo; // <-- No consistent type can be inferred for `f` here.
LL | let a = bar(f, x);
| ^^^^^^^^^ argument requires that `'a` must outlive `'b`
LL | let f = foo; // <-- No consistent type can be inferred for `f` here.
LL | let a = bar(f, x);
| ^^^^^^^^^ argument requires that `'a` must outlive `'b`
|
= help: consider adding the following bound: `'a: 'b`
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:39:12
--> $DIR/project-fn-ret-invariant.rs:40:13
|
LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | let b = bar(f, y);
| ^^^^^^^^^ argument requires that `'b` must outlive `'a`
LL | let b = bar(f, y);
| ^^^^^^^^^ argument requires that `'b` must outlive `'a`
|
= help: consider adding the following bound: `'b: 'a`

View file

@ -1,13 +1,13 @@
error[E0623]: lifetime mismatch
--> $DIR/project-fn-ret-invariant.rs:39:19
--> $DIR/project-fn-ret-invariant.rs:40:20
|
LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -------- --------------------
| |
| this parameter and the return type are declared with different lifetimes...
LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -------- --------------------
| |
| this parameter and the return type are declared with different lifetimes...
...
LL | let b = bar(f, y);
| ^ ...but data from `x` is returned here
LL | let b = bar(f, y);
| ^ ...but data from `x` is returned here
error: aborting due to previous error

View file

@ -1,60 +1,61 @@
#![feature(unboxed_closures)]
#![feature(rustc_attrs)]
// Test for projection cache. We should be able to project distinct
// lifetimes from `foo` as we reinstantiate it multiple times, but not
// if we do it just once. In this variant, the region `'a` is used in
// an invariant position, which affects the results.
// revisions: ok oneuse transmute krisskross
#![allow(dead_code, unused_variables)]
use std::marker::PhantomData;
struct Type<'a> {
// Invariant
data: PhantomData<fn(&'a u32) -> &'a u32>
data: PhantomData<fn(&'a u32) -> &'a u32>,
}
fn foo<'a>() -> Type<'a> { loop { } }
fn foo<'a>() -> Type<'a> {
loop {}
}
fn bar<T>(t: T, x: T::Output) -> T::Output
where T: FnOnce<()>
where
T: FnOnce<()>,
{
t()
}
#[cfg(ok)] // two instantiations: OK
fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
let a = bar(foo, x);
let b = bar(foo, y);
(a, b)
}
#[cfg(oneuse)] // one instantiation: BAD
fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
let f = foo; // <-- No consistent type can be inferred for `f` here.
let a = bar(f, x);
let b = bar(f, y); //[oneuse]~ ERROR lifetime mismatch [E0623]
(a, b)
fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
let f = foo; // <-- No consistent type can be inferred for `f` here.
let a = bar(f, x);
let b = bar(f, y); //[oneuse]~ ERROR lifetime mismatch [E0623]
(a, b)
}
#[cfg(transmute)] // one instantiations: BAD
fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
// Cannot instantiate `foo` with any lifetime other than `'a`,
// since it is provided as input.
fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> {
// Cannot instantiate `foo` with any lifetime other than `'a`,
// since it is provided as input.
bar(foo, x) //[transmute]~ ERROR E0495
bar(foo, x) //[transmute]~ ERROR E0495
}
#[cfg(krisskross)] // two instantiations, mixing and matching: BAD
fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
let a = bar(foo, y); //[krisskross]~ ERROR E0623
let b = bar(foo, x); //[krisskross]~ ERROR E0623
(a, b)
fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
let a = bar(foo, y); //[krisskross]~ ERROR E0623
let b = bar(foo, x);
(a, b) //[krisskross]~ ERROR E0623
}
#[rustc_error]
fn main() { }
fn main() {}
//[ok]~^ ERROR fatal error triggered by #[rustc_error]

View file

@ -1,11 +1,11 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:48:4
--> $DIR/project-fn-ret-invariant.rs:49:5
|
LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> {
| -- lifetime `'a` defined here
...
LL | bar(foo, x)
| ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
LL | bar(foo, x)
| ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
|
= help: consider replacing `'a` with `'static`

View file

@ -1,27 +1,27 @@
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/project-fn-ret-invariant.rs:48:4
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/project-fn-ret-invariant.rs:49:9
|
LL | bar(foo, x)
| ^^^^^^^^^^^
LL | bar(foo, x)
| ^^^
|
note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 44:8...
--> $DIR/project-fn-ret-invariant.rs:44:8
note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 45:8...
--> $DIR/project-fn-ret-invariant.rs:45:8
|
LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> {
| ^^
note: ...so that the expression is assignable
--> $DIR/project-fn-ret-invariant.rs:48:13
--> $DIR/project-fn-ret-invariant.rs:49:14
|
LL | bar(foo, x)
| ^
LL | bar(foo, x)
| ^
= note: expected `Type<'_>`
found `Type<'a>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the expression is assignable
--> $DIR/project-fn-ret-invariant.rs:48:4
--> $DIR/project-fn-ret-invariant.rs:49:5
|
LL | bar(foo, x)
| ^^^^^^^^^^^
LL | bar(foo, x)
| ^^^^^^^^^^^
= note: expected `Type<'static>`
found `Type<'_>`

View file

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/higher-ranked-projection.rs:25:5
|
LL | foo(());
| ^^^^^^^
error: aborting due to previous error

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
|
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`.

View file

@ -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
}

View file

@ -1,42 +1,43 @@
error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:30:5
error: lifetime may not live long enough
--> $DIR/expect-fn-supply-fn.rs:16:49
|
LL | fn with_closure_expecting_fn_with_free_region<F>(_: F)
| ------------------------------------------ required by a bound in this
LL | where F: for<'a> FnOnce(fn(&'a u32), &i32)
| ------------------------- required by this bound in `with_closure_expecting_fn_with_free_region`
LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
| -- lifetime `'x` defined here
...
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
| ^
| |
| has type `fn(&'1 u32)`
| requires that `'1` must outlive `'x`
error: lifetime may not live long enough
--> $DIR/expect-fn-supply-fn.rs:16:49
|
LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
| -- lifetime `'x` defined here
...
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
| ^ requires that `'x` must outlive `'static`
|
= help: consider replacing `'x` with `'static`
error: higher-ranked subtype error
--> $DIR/expect-fn-supply-fn.rs:32:49
|
LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _`
| |
| expected signature of `fn(fn(&'a u32), &i32) -> _`
| ^
error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:37:5
error: higher-ranked subtype error
--> $DIR/expect-fn-supply-fn.rs:39:50
|
LL | fn with_closure_expecting_fn_with_bound_region<F>(_: F)
| ------------------------------------------- required by a bound in this
LL | where F: FnOnce(fn(&u32), &i32)
| ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region`
...
LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _`
| |
| expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
| ^
error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:46:5
error: higher-ranked subtype error
--> $DIR/expect-fn-supply-fn.rs:48:50
|
LL | fn with_closure_expecting_fn_with_bound_region<F>(_: F)
| ------------------------------------------- required by a bound in this
LL | where F: FnOnce(fn(&u32), &i32)
| ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region`
...
LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
| |
| expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
| ^
error: aborting due to 3 previous errors
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0631`.

View file

@ -1,10 +1,12 @@
fn with_closure_expecting_fn_with_free_region<F>(_: F)
where F: for<'a> FnOnce(fn(&'a u32), &i32)
where
F: for<'a> FnOnce(fn(&'a u32), &i32),
{
}
fn with_closure_expecting_fn_with_bound_region<F>(_: F)
where F: FnOnce(fn(&u32), &i32)
where
F: FnOnce(fn(&u32), &i32),
{
}
@ -28,14 +30,14 @@ fn expect_free_supply_bound() {
// Here, we are given a function whose region is bound at closure level,
// but we expect one bound in the argument. Error results.
with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
//~^ ERROR type mismatch
//~^ ERROR mismatched types
}
fn expect_bound_supply_free_from_fn<'x>(x: &'x u32) {
// Here, we are given a `fn(&u32)` but we expect a `fn(&'x
// u32)`. In principle, this could be ok, but we demand equality.
with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
//~^ ERROR type mismatch
//~^ ERROR mismatched types
}
fn expect_bound_supply_free_from_closure() {
@ -44,7 +46,7 @@ fn expect_bound_supply_free_from_closure() {
// the argument level.
type Foo<'a> = fn(&'a u32);
with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
//~^ ERROR type mismatch
//~^ ERROR mismatched types
});
}
@ -52,8 +54,7 @@ fn expect_bound_supply_bound<'x>(x: &'x u32) {
// No error in this case. The supplied type supplies the bound
// regions, and hence we are able to figure out the type of `y`
// from the expected type
with_closure_expecting_fn_with_bound_region(|x: for<'z> fn(&'z u32), y| {
});
with_closure_expecting_fn_with_bound_region(|x: for<'z> fn(&'z u32), y| {});
}
fn main() { }
fn main() {}

View file

@ -1,81 +1,68 @@
error[E0308]: mismatched types
--> $DIR/expect-fn-supply-fn.rs:14:52
--> $DIR/expect-fn-supply-fn.rs:16:52
|
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
| ^^^^^^^^^^^ lifetime mismatch
|
= note: expected fn pointer `fn(&u32)`
found fn pointer `fn(&'x u32)`
note: the anonymous lifetime #2 defined on the body at 14:48...
--> $DIR/expect-fn-supply-fn.rs:14:48
note: the anonymous lifetime #2 defined on the body at 16:48...
--> $DIR/expect-fn-supply-fn.rs:16:48
|
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
| ^^^^^^^^^^^^^^^^^^^^^^
note: ...does not necessarily outlive the lifetime `'x` as defined on the function body at 11:36
--> $DIR/expect-fn-supply-fn.rs:11:36
note: ...does not necessarily outlive the lifetime `'x` as defined on the function body at 13:36
--> $DIR/expect-fn-supply-fn.rs:13:36
|
LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
| ^^
error[E0308]: mismatched types
--> $DIR/expect-fn-supply-fn.rs:14:52
--> $DIR/expect-fn-supply-fn.rs:16:52
|
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
| ^^^^^^^^^^^ lifetime mismatch
|
= note: expected fn pointer `fn(&u32)`
found fn pointer `fn(&'x u32)`
note: the lifetime `'x` as defined on the function body at 11:36...
--> $DIR/expect-fn-supply-fn.rs:11:36
note: the lifetime `'x` as defined on the function body at 13:36...
--> $DIR/expect-fn-supply-fn.rs:13:36
|
LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
| ^^
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 14:48
--> $DIR/expect-fn-supply-fn.rs:14:48
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 16:48
--> $DIR/expect-fn-supply-fn.rs:16:48
|
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
| ^^^^^^^^^^^^^^^^^^^^^^
error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:30:5
error[E0308]: mismatched types
--> $DIR/expect-fn-supply-fn.rs:32:52
|
LL | fn with_closure_expecting_fn_with_free_region<F>(_: F)
| ------------------------------------------ required by a bound in this
LL | where F: for<'a> FnOnce(fn(&'a u32), &i32)
| ------------------------- required by this bound in `with_closure_expecting_fn_with_free_region`
...
LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _`
| |
| expected signature of `fn(fn(&'a u32), &i32) -> _`
error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:37:5
| ^^^^^^^^ one type is more general than the other
|
= note: expected fn pointer `fn(&u32)`
found fn pointer `for<'r> fn(&'r u32)`
error[E0308]: mismatched types
--> $DIR/expect-fn-supply-fn.rs:39:53
|
LL | fn with_closure_expecting_fn_with_bound_region<F>(_: F)
| ------------------------------------------- required by a bound in this
LL | where F: FnOnce(fn(&u32), &i32)
| ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region`
...
LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _`
| |
| expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:46:5
| ^^^^^^^^^^^ one type is more general than the other
|
= note: expected fn pointer `for<'r> fn(&'r u32)`
found fn pointer `fn(&'x u32)`
error[E0308]: mismatched types
--> $DIR/expect-fn-supply-fn.rs:48:53
|
LL | fn with_closure_expecting_fn_with_bound_region<F>(_: F)
| ------------------------------------------- required by a bound in this
LL | where F: FnOnce(fn(&u32), &i32)
| ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region`
...
LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
| |
| expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
| ^^^^^^^ one type is more general than the other
|
= note: expected fn pointer `for<'r> fn(&'r u32)`
found fn pointer `fn(&u32)`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0308, E0631.
For more information about an error, try `rustc --explain E0308`.
For more information about this error, try `rustc --explain E0308`.

View file

@ -7,7 +7,6 @@ impl<'g> T<'g> for u32 {
}
fn main() {
(&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
(&|_| ()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
//~^ ERROR: type mismatch in closure arguments
//~| ERROR: type mismatch resolving
}

View file

@ -1,23 +1,14 @@
error[E0631]: type mismatch in closure arguments
--> $DIR/issue-41366.rs:10:5
|
LL | (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
| ^^-----^
LL | (&|_| ()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
| ^^------^
| | |
| | found signature of `fn(_) -> _`
| expected signature of `for<'x> fn(<u32 as T<'x>>::V) -> _`
| | found signature of `fn(u16) -> _`
| expected signature of `fn(<u32 as T<'x>>::V) -> _`
|
= note: required for the cast to the object type `dyn for<'x> std::ops::Fn(<u32 as T<'x>>::V)`
error[E0271]: type mismatch resolving `for<'x> <[closure@$DIR/issue-41366.rs:10:7: 10:12] as std::ops::FnOnce<(<u32 as T<'x>>::V,)>>::Output == ()`
--> $DIR/issue-41366.rs:10:5
|
LL | (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
| ^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime
|
= note: required for the cast to the object type `dyn for<'x> std::ops::Fn(<u32 as T<'x>>::V)`
error: aborting due to previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.
For more information about this error, try `rustc --explain E0631`.

View file

@ -0,0 +1,26 @@
// Test that impls for these two types are considered ovelapping:
//
// * `for<'r> fn(fn(&'r u32))`
// * `fn(fn(&'a u32)` where `'a` is free
//
// This is because, for `'a = 'static`, the two types overlap.
// Effectively for them to be equal to you get:
//
// * `for<'r> fn(fn(&'r u32)) <: fn(fn(&'static u32))`
// * true if `exists<'r> { 'r: 'static }` (obviously true)
// * `fn(fn(&'static u32)) <: for<'r> fn(fn(&'r u32))`
// * true if `forall<'r> { 'static: 'r }` (also true)
trait Trait {}
impl Trait for for<'r> fn(fn(&'r ())) {}
impl<'a> Trait for fn(fn(&'a ())) {}
//~^ ERROR conflicting implementations
//
// Note in particular that we do NOT get a future-compatibility warning
// here. This is because the new leak-check proposed in [MCP 295] does not
// "error" when these two types are equated.
//
// [MCP 295]: https://github.com/rust-lang/compiler-team/issues/295
fn main() {}

View file

@ -0,0 +1,13 @@
error[E0119]: conflicting implementations of trait `Trait` for type `for<'r> fn(fn(&'r ()))`:
--> $DIR/coherence-fn-covariant-bound-vs-static.rs:17:1
|
LL | impl Trait for for<'r> fn(fn(&'r ())) {}
| ------------------------------------- first implementation here
LL | impl<'a> Trait for fn(fn(&'a ())) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'r> fn(fn(&'r ()))`
|
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View file

@ -0,0 +1,26 @@
// Test that our leak-check is not smart enough to take implied bounds
// into account (yet). Here we have two types that look like they
// should not be equivalent, but because of the rules on implied
// bounds we ought to know that, in fact, `'a = 'b` must always hold,
// and hence they are.
//
// Rustc can't figure this out and hence it accepts the impls but
// gives a future-compatibility warning (because we'd like to make
// this an error someday).
//
// Note that while we would like to make this a hard error, we also
// give the same warning for `coherence-wasm-bindgen.rs`, which ought
// to be accepted.
#![deny(coherence_leak_check)]
trait Trait {}
impl Trait for for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32 {}
impl Trait for for<'c> fn(&'c &'c u32, &'c &'c u32) -> &'c u32 {
//~^ ERROR conflicting implementations
//~| WARNING this was previously accepted by the compiler
}
fn main() {}

View file

@ -0,0 +1,20 @@
error: conflicting implementations of trait `Trait` for type `for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32`:
--> $DIR/coherence-fn-implied-bounds.rs:21:1
|
LL | impl Trait for for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32 {}
| ------------------------------------------------------------------ first implementation here
LL |
LL | impl Trait for for<'c> fn(&'c &'c u32, &'c &'c u32) -> &'c u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32`
|
note: the lint level is defined here
--> $DIR/coherence-fn-implied-bounds.rs:15:9
|
LL | #![deny(coherence_leak_check)]
| ^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
error: aborting due to previous error

View file

@ -0,0 +1,25 @@
// Test that we consider these two types completely equal:
//
// * `for<'a, 'b> fn(&'a u32, &'b u32)`
// * `for<'c> fn(&'c u32, &'c u32)`
//
// For a long time we considered these to be distinct types. But in fact they
// are equivalent, if you work through the implications of subtyping -- this is
// because:
//
// * `'c` can be the intersection of `'a` and `'b` (and there is always an intersection)
// * `'a` and `'b` can both be equal to `'c`
trait Trait {}
impl Trait for for<'a, 'b> fn(&'a u32, &'b u32) {}
impl Trait for for<'c> fn(&'c u32, &'c u32) {
//~^ ERROR conflicting implementations
//
// Note in particular that we do NOT get a future-compatibility warning
// here. This is because the new leak-check proposed in [MCP 295] does not
// "error" when these two types are equated.
//
// [MCP 295]: https://github.com/rust-lang/compiler-team/issues/295
}
fn main() {}

View file

@ -0,0 +1,13 @@
error[E0119]: conflicting implementations of trait `Trait` for type `for<'a, 'b> fn(&'a u32, &'b u32)`:
--> $DIR/coherence-fn-inputs.rs:15:1
|
LL | impl Trait for for<'a, 'b> fn(&'a u32, &'b u32) {}
| ----------------------------------------------- first implementation here
LL | impl Trait for for<'c> fn(&'c u32, &'c u32) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u32, &'b u32)`
|
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.

View file

@ -0,0 +1,21 @@
// Capture a coherence pattern from wasm-bindgen that we discovered as part of
// future-compatibility warning #56105. This pattern currently receives a lint
// warning but we probably want to support it long term.
//
// Key distinction: we are implementing once for `A` (take ownership) and one
// for `&A` (borrow).
//
// c.f. #56105
#![deny(coherence_leak_check)]
trait TheTrait {}
impl<'a> TheTrait for fn(&'a u8) {}
impl TheTrait for fn(&u8) {
//~^ ERROR conflicting implementations of trait
//~| WARNING this was previously accepted by the compiler
}
fn main() {}

View file

@ -0,0 +1,20 @@
error: conflicting implementations of trait `TheTrait` for type `fn(&u8)`:
--> $DIR/coherence-free-vs-bound-region.rs:16:1
|
LL | impl<'a> TheTrait for fn(&'a u8) {}
| -------------------------------- first implementation here
LL |
LL | impl TheTrait for fn(&u8) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `fn(&u8)`
|
note: the lint level is defined here
--> $DIR/coherence-free-vs-bound-region.rs:10:9
|
LL | #![deny(coherence_leak_check)]
| ^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
error: aborting due to previous error

View file

@ -0,0 +1,37 @@
// Capture a coherence pattern from wasm-bindgen that we discovered as part of
// future-compatibility warning #56105. This pattern currently receives a lint
// warning but we probably want to support it long term.
//
// Key distinction: we are implementing once for `A` (take ownership) and one
// for `&A` (borrow).
//
// c.f. #56105
#![deny(coherence_leak_check)]
trait IntoWasmAbi {
fn some_method(&self) {}
}
trait FromWasmAbi {}
trait RefFromWasmAbi {}
trait ReturnWasmAbi {}
impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn Fn(A) -> R + 'b)
where
A: FromWasmAbi,
R: ReturnWasmAbi,
{
}
// Explicitly writing the bound lifetime.
impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn for<'x> Fn(&'x A) -> R + 'b)
where
A: RefFromWasmAbi,
R: ReturnWasmAbi,
{
//~^^^^^ ERROR conflicting implementation
//~| WARNING this was previously accepted
}
fn main() {}

View file

@ -0,0 +1,32 @@
error: conflicting implementations of trait `IntoWasmAbi` for type `&dyn std::ops::Fn(&_) -> _`:
--> $DIR/coherence-wasm-bindgen.rs:28:1
|
LL | / impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn Fn(A) -> R + 'b)
LL | | where
LL | | A: FromWasmAbi,
LL | | R: ReturnWasmAbi,
LL | | {
LL | | }
| |_- first implementation here
...
LL | / impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn for<'x> Fn(&'x A) -> R + 'b)
LL | | where
LL | | A: RefFromWasmAbi,
LL | | R: ReturnWasmAbi,
... |
LL | |
LL | | }
| |_^ conflicting implementation for `&dyn std::ops::Fn(&_) -> _`
|
note: the lint level is defined here
--> $DIR/coherence-wasm-bindgen.rs:10:9
|
LL | #![deny(coherence_leak_check)]
| ^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: downstream crates may implement trait `FromWasmAbi` for type `&_`
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
error: aborting due to previous error

View file

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/resume-arg-late-bound.rs:15:5
|
LL | test(gen);
| ^^^^^^^^^
error: aborting due to previous error

View file

@ -13,5 +13,6 @@ fn main() {
*arg = true;
};
test(gen);
//~^ ERROR type mismatch in function arguments
//~^ ERROR mismatched types
//~| ERROR mismatched types
}

View file

@ -1,15 +1,21 @@
error[E0631]: type mismatch in function arguments
--> $DIR/resume-arg-late-bound.rs:15:10
error[E0308]: mismatched types
--> $DIR/resume-arg-late-bound.rs:15:5
|
LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {}
| ------------------------------- required by this bound in `test`
...
LL | test(gen);
| ^^^
| |
| expected signature of `for<'a> fn(&'a mut bool) -> _`
| found signature of `fn(&mut bool) -> _`
| ^^^^ one type is more general than the other
|
= note: expected type `for<'a> std::ops::Generator<&'a mut bool>`
found type `std::ops::Generator<&mut bool>`
error: aborting due to previous error
error[E0308]: mismatched types
--> $DIR/resume-arg-late-bound.rs:15:5
|
LL | test(gen);
| ^^^^ one type is more general than the other
|
= note: expected type `for<'a> std::ops::Generator<&'a mut bool>`
found type `std::ops::Generator<&mut bool>`
For more information about this error, try `rustc --explain E0631`.
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,14 @@
error: higher-ranked subtype error
--> $DIR/hr-subtype.rs:45:13
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32,
LL | | for<'a> fn(&'a u32, &'a u32) -> &'a u32) }
| |_____________________________________________- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -1,12 +1,12 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
--> $DIR/hr-subtype.rs:45:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
| ^^^^^^^^^^^ one type is more general than the other
...
LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32,
LL | | for<'a> fn(&'a u32, &'a u32) -> &'a u32) }
| |_________________________________________________________________________________________- in this macro invocation
LL | | for<'a> fn(&'a u32, &'a u32) -> &'a u32) }
| |_____________________________________________- in this macro invocation
|
= note: expected enum `std::option::Option<for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32>`
found enum `std::option::Option<for<'a> fn(&'a u32, &'a u32) -> &'a u32>`

View file

@ -1,17 +1,14 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:102:1
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
...
LL | / check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32),
LL | | for<'a> fn(&'a u32, &'a u32)) }
| |__________________________________________________________________- in this macro invocation
|
= note: expected enum `std::option::Option<for<'a, 'b> fn(&'a u32, &'b u32)>`
found enum `std::option::Option<for<'a> fn(&'a u32, &'a u32)>`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
LL | / fn main() {
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,11 +1,11 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:102:1
|
LL | / fn main() {
LL | |
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^

View file

@ -1,11 +1,11 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:102:1
|
LL | / fn main() {
LL | |
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^

View file

@ -0,0 +1,14 @@
error: higher-ranked subtype error
--> $DIR/hr-subtype.rs:45:13
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
LL | | fn(&'x u32)) }
| |______________- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -1,12 +1,12 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
--> $DIR/hr-subtype.rs:45:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
| ^^^^^^^^^^^ one type is more general than the other
...
LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
LL | | fn(&'x u32)) }
| |___________________________________________- in this macro invocation
LL | | fn(&'x u32)) }
| |______________- in this macro invocation
|
= note: expected enum `std::option::Option<for<'a> fn(&'a u32)>`
found enum `std::option::Option<fn(&'x u32)>`

View file

@ -1,17 +1,14 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:102:1
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
...
LL | / check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>),
LL | | for<'a> fn(Co<'a>, Co<'a>)) }
| |______________________________________________________________________- in this macro invocation
|
= note: expected enum `std::option::Option<for<'a, 'b> fn(Co<'a>, Co<'b>)>`
found enum `std::option::Option<for<'a> fn(Co<'a>, Co<'a>)>`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
LL | / fn main() {
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,17 +1,14 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:102:1
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
...
LL | / check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>,
LL | | for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) }
| |______________________________________________________________________________________- in this macro invocation
|
= note: expected enum `std::option::Option<for<'a, 'b> fn(Co<'a>, Co<'b>) -> Contra<'a>>`
found enum `std::option::Option<for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>>`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
LL | / fn main() {
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,11 +1,11 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:102:1
|
LL | / fn main() {
LL | |
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^

View file

@ -1,17 +1,14 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:102:1
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
...
LL | / check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>,
LL | | for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) }
| |______________________________________________________________________________________________- in this macro invocation
|
= note: expected enum `std::option::Option<for<'a, 'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>>`
found enum `std::option::Option<for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>>`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
LL | / fn main() {
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,26 @@
error: higher-ranked subtype error
--> $DIR/hr-subtype.rs:45:13
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
LL | | for<'a> fn(Inv<'a>, Inv<'a>)) }
| |__________________________________- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: higher-ranked subtype error
--> $DIR/hr-subtype.rs:45:13
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
LL | | for<'a> fn(Inv<'a>, Inv<'a>)) }
| |__________________________________- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors

View file

@ -1,12 +1,12 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
--> $DIR/hr-subtype.rs:45:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
| ^^^^^^^^^^^ one type is more general than the other
...
LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
LL | | for<'a> fn(Inv<'a>, Inv<'a>)) }
| |__________________________________________________________________________- in this macro invocation
LL | | for<'a> fn(Inv<'a>, Inv<'a>)) }
| |__________________________________- in this macro invocation
|
= note: expected enum `std::option::Option<for<'a, 'b> fn(Inv<'a>, Inv<'b>)>`
found enum `std::option::Option<for<'a> fn(Inv<'a>, Inv<'a>)>`

View file

@ -1,11 +1,11 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:102:1
|
LL | / fn main() {
LL | |
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^

View file

@ -1,33 +1,33 @@
error: lifetime may not live long enough
--> $DIR/hr-subtype.rs:33:13
--> $DIR/hr-subtype.rs:39:13
|
LL | fn subtype<'x,'y:'x,'z:'y>() {
| -- -- lifetime `'y` defined here
LL | fn subtype<'x, 'y: 'x, 'z: 'y>() {
| -- -- lifetime `'y` defined here
| |
| lifetime `'x` defined here
LL | gimme::<$t2>(None::<$t1>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
LL | | fn(Inv<'y>)) }
| |______________- in this macro invocation
|
= help: consider adding the following bound: `'x: 'y`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: lifetime may not live long enough
--> $DIR/hr-subtype.rs:39:13
--> $DIR/hr-subtype.rs:45:13
|
LL | fn supertype<'x,'y:'x,'z:'y>() {
| -- -- lifetime `'y` defined here
LL | fn supertype<'x, 'y: 'x, 'z: 'y>() {
| -- -- lifetime `'y` defined here
| |
| lifetime `'x` defined here
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
LL | | fn(Inv<'y>)) }
| |______________- in this macro invocation
|
= help: consider adding the following bound: `'x: 'y`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

View file

@ -1,65 +1,65 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:33:26
--> $DIR/hr-subtype.rs:39:26
|
LL | gimme::<$t2>(None::<$t1>);
| ^^^^^^^^^^^ lifetime mismatch
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
LL | | fn(Inv<'y>)) }
| |______________- in this macro invocation
|
= note: expected enum `std::option::Option<fn(Inv<'y>)>`
found enum `std::option::Option<fn(Inv<'x>)>`
note: the lifetime `'x` as defined on the function body at 32:20...
--> $DIR/hr-subtype.rs:32:20
note: the lifetime `'x` as defined on the function body at 38:20...
--> $DIR/hr-subtype.rs:38:20
|
LL | fn subtype<'x,'y:'x,'z:'y>() {
LL | fn subtype<'x, 'y: 'x, 'z: 'y>() {
| ^^
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
note: ...does not necessarily outlive the lifetime `'y` as defined on the function body at 32:23
--> $DIR/hr-subtype.rs:32:23
LL | | fn(Inv<'y>)) }
| |______________- in this macro invocation
note: ...does not necessarily outlive the lifetime `'y` as defined on the function body at 38:24
--> $DIR/hr-subtype.rs:38:24
|
LL | fn subtype<'x,'y:'x,'z:'y>() {
| ^^
LL | fn subtype<'x, 'y: 'x, 'z: 'y>() {
| ^^
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
LL | | fn(Inv<'y>)) }
| |______________- in this macro invocation
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
--> $DIR/hr-subtype.rs:45:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ lifetime mismatch
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
LL | | fn(Inv<'y>)) }
| |______________- in this macro invocation
|
= note: expected enum `std::option::Option<fn(Inv<'x>)>`
found enum `std::option::Option<fn(Inv<'y>)>`
note: the lifetime `'x` as defined on the function body at 38:22...
--> $DIR/hr-subtype.rs:38:22
note: the lifetime `'x` as defined on the function body at 44:22...
--> $DIR/hr-subtype.rs:44:22
|
LL | fn supertype<'x,'y:'x,'z:'y>() {
LL | fn supertype<'x, 'y: 'x, 'z: 'y>() {
| ^^
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
note: ...does not necessarily outlive the lifetime `'y` as defined on the function body at 38:25
--> $DIR/hr-subtype.rs:38:25
LL | | fn(Inv<'y>)) }
| |______________- in this macro invocation
note: ...does not necessarily outlive the lifetime `'y` as defined on the function body at 44:26
--> $DIR/hr-subtype.rs:44:26
|
LL | fn supertype<'x,'y:'x,'z:'y>() {
| ^^
LL | fn supertype<'x, 'y: 'x, 'z: 'y>() {
| ^^
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
LL | | fn(Inv<'y>)) }
| |______________- in this macro invocation
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors

View file

@ -1,11 +1,11 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:102:1
|
LL | / fn main() {
LL | |
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^

View file

@ -1,16 +1,16 @@
error: lifetime may not live long enough
--> $DIR/hr-subtype.rs:39:13
--> $DIR/hr-subtype.rs:45:13
|
LL | fn supertype<'x,'y:'x,'z:'y>() {
| -- -- lifetime `'y` defined here
LL | fn supertype<'x, 'y: 'x, 'z: 'y>() {
| -- -- lifetime `'y` defined here
| |
| lifetime `'x` defined here
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
...
LL | / check! { free_x_vs_free_y: (fn(&'x u32),
LL | | fn(&'y u32)) }
| |__________________________________________- in this macro invocation
LL | | fn(&'y u32)) }
| |______________- in this macro invocation
|
= help: consider adding the following bound: `'x: 'y`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

View file

@ -1,33 +1,33 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
--> $DIR/hr-subtype.rs:45:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ lifetime mismatch
...
LL | / check! { free_x_vs_free_y: (fn(&'x u32),
LL | | fn(&'y u32)) }
| |__________________________________________- in this macro invocation
LL | | fn(&'y u32)) }
| |______________- in this macro invocation
|
= note: expected enum `std::option::Option<fn(&'x u32)>`
found enum `std::option::Option<fn(&'y u32)>`
note: the lifetime `'x` as defined on the function body at 38:22...
--> $DIR/hr-subtype.rs:38:22
note: the lifetime `'x` as defined on the function body at 44:22...
--> $DIR/hr-subtype.rs:44:22
|
LL | fn supertype<'x,'y:'x,'z:'y>() {
LL | fn supertype<'x, 'y: 'x, 'z: 'y>() {
| ^^
...
LL | / check! { free_x_vs_free_y: (fn(&'x u32),
LL | | fn(&'y u32)) }
| |__________________________________________- in this macro invocation
note: ...does not necessarily outlive the lifetime `'y` as defined on the function body at 38:25
--> $DIR/hr-subtype.rs:38:25
LL | | fn(&'y u32)) }
| |______________- in this macro invocation
note: ...does not necessarily outlive the lifetime `'y` as defined on the function body at 44:26
--> $DIR/hr-subtype.rs:44:26
|
LL | fn supertype<'x,'y:'x,'z:'y>() {
| ^^
LL | fn supertype<'x, 'y: 'x, 'z: 'y>() {
| ^^
...
LL | / check! { free_x_vs_free_y: (fn(&'x u32),
LL | | fn(&'y u32)) }
| |__________________________________________- in this macro invocation
LL | | fn(&'y u32)) }
| |______________- in this macro invocation
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -18,60 +18,62 @@
// revisions: bound_inv_a_b_vs_bound_inv_a
// revisions: bound_a_b_ret_a_vs_bound_a_ret_a
fn gimme<T>(_: Option<T>) { }
fn gimme<T>(_: Option<T>) {}
struct Inv<'a> { x: *mut &'a u32 }
struct Inv<'a> {
x: *mut &'a u32,
}
struct Co<'a> { x: fn(&'a u32) }
struct Co<'a> {
x: fn(&'a u32),
}
struct Contra<'a> { x: &'a u32 }
struct Contra<'a> {
x: &'a u32,
}
macro_rules! check {
($rev:ident: ($t1:ty, $t2:ty)) => {
#[cfg($rev)]
fn subtype<'x,'y:'x,'z:'y>() {
fn subtype<'x, 'y: 'x, 'z: 'y>() {
gimme::<$t2>(None::<$t1>);
//[free_inv_x_vs_free_inv_y]~^ ERROR
}
#[cfg($rev)]
fn supertype<'x,'y:'x,'z:'y>() {
fn supertype<'x, 'y: 'x, 'z: 'y>() {
gimme::<$t1>(None::<$t2>);
//[bound_a_vs_free_x]~^ ERROR
//[free_x_vs_free_y]~^^ ERROR
//[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR
//[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^ ERROR
//[free_inv_x_vs_free_inv_y]~^^^^^ ERROR
//[bound_a_b_vs_bound_a]~^^^^^^ ERROR mismatched types
//[bound_co_a_co_b_ret_contra_a]~^^^^^^^ ERROR
//[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^ ERROR
//[bound_co_a_b_vs_bound_co_a]~^^^^^^^^^ ERROR
}
}
};
}
// If both have bound regions, they are equivalent, regardless of
// variant.
check! { bound_a_vs_bound_a: (for<'a> fn(&'a u32),
for<'a> fn(&'a u32)) }
for<'a> fn(&'a u32)) }
check! { bound_a_vs_bound_b: (for<'a> fn(&'a u32),
for<'b> fn(&'b u32)) }
for<'b> fn(&'b u32)) }
check! { bound_inv_a_vs_bound_inv_b: (for<'a> fn(Inv<'a>),
for<'b> fn(Inv<'b>)) }
for<'b> fn(Inv<'b>)) }
check! { bound_co_a_vs_bound_co_b: (for<'a> fn(Co<'a>),
for<'b> fn(Co<'b>)) }
for<'b> fn(Co<'b>)) }
// Bound is a subtype of free.
check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
fn(&'x u32)) }
fn(&'x u32)) }
// Two free regions are relatable if subtyping holds.
check! { free_x_vs_free_x: (fn(&'x u32),
fn(&'x u32)) }
fn(&'x u32)) }
check! { free_x_vs_free_y: (fn(&'x u32),
fn(&'y u32)) }
fn(&'y u32)) }
check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
fn(Inv<'y>)) }
fn(Inv<'y>)) }
// Somewhat surprisingly, a fn taking two distinct bound lifetimes and
// a fn taking one bound lifetime can be interchangeable, but only if
@ -82,25 +84,29 @@ check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
// intersection;
// - if we are contravariant, then 'a can be inferred to 'static.
check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32),
for<'a> fn(&'a u32, &'a u32)) }
for<'a> fn(&'a u32, &'a u32)) }
check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>),
for<'a> fn(Co<'a>, Co<'a>)) }
for<'a> fn(Co<'a>, Co<'a>)) }
check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>,
for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) }
for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) }
check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>,
for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) }
for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) }
// If we make those lifetimes invariant, then the two types are not interchangeable.
check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
for<'a> fn(Inv<'a>, Inv<'a>)) }
for<'a> fn(Inv<'a>, Inv<'a>)) }
check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32,
for<'a> fn(&'a u32, &'a u32) -> &'a u32) }
for<'a> fn(&'a u32, &'a u32) -> &'a u32) }
#[rustc_error]
fn main() {
//[bound_a_vs_bound_a]~^ ERROR fatal error triggered by #[rustc_error]
//[bound_a_vs_bound_b]~^^ ERROR fatal error triggered by #[rustc_error]
//[bound_inv_a_vs_bound_inv_b]~^^^ ERROR fatal error triggered by #[rustc_error]
//[bound_co_a_vs_bound_co_b]~^^^^ ERROR fatal error triggered by #[rustc_error]
//[free_x_vs_free_x]~^^^^^ ERROR fatal error triggered by #[rustc_error]
//[bound_a_vs_bound_a]~^ ERROR fatal error triggered by #[rustc_error]
//[bound_a_vs_bound_b]~^^ ERROR fatal error triggered by #[rustc_error]
//[bound_inv_a_vs_bound_inv_b]~^^^ ERROR fatal error triggered by #[rustc_error]
//[bound_co_a_vs_bound_co_b]~^^^^ ERROR fatal error triggered by #[rustc_error]
//[free_x_vs_free_x]~^^^^^ ERROR fatal error triggered by #[rustc_error]
//[bound_co_a_b_vs_bound_co_a]~^^^^^^ ERROR
//[bound_co_a_co_b_ret_contra_a]~^^^^^^^ ERROR
//[bound_a_b_vs_bound_a]~^^^^^^^^ ERROR
//[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR
}

View file

@ -0,0 +1,13 @@
// check-pass
fn make<T>() -> T {
panic!()
}
fn take<T>(x: T) {}
fn main() {
let x: for<'a> fn(&'a u32) -> _ = make();
let y: &'static u32 = x(&22);
take::<for<'b> fn(&'b u32) -> &'b u32>(x);
}

View file

@ -0,0 +1,14 @@
error: higher-ranked subtype error
--> $DIR/hrtb-conflate-regions.rs:27:10
|
LL | fn b() { want_foo2::<SomeStruct>(); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/hrtb-conflate-regions.rs:27:10
|
LL | fn b() { want_foo2::<SomeStruct>(); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -1,17 +1,16 @@
error[E0277]: the trait bound `for<'a, 'b> SomeStruct: Foo<(&'a isize, &'b isize)>` is not satisfied
--> $DIR/hrtb-conflate-regions.rs:27:22
error: implementation of `Foo` is not general enough
--> $DIR/hrtb-conflate-regions.rs:27:10
|
LL | fn want_foo2<T>()
| --------- required by a bound in this
LL | where T : for<'a,'b> Foo<(&'a isize, &'b isize)>
| -------------------------------------- required by this bound in `want_foo2`
LL | / trait Foo<X> {
LL | | fn foo(&self, x: X) { }
LL | | }
| |_- trait `Foo` defined here
...
LL | fn b() { want_foo2::<SomeStruct>(); }
| ^^^^^^^^^^ the trait `for<'a, 'b> Foo<(&'a isize, &'b isize)>` is not implemented for `SomeStruct`
LL | fn b() { want_foo2::<SomeStruct>(); }
| ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
= help: the following implementations were found:
<SomeStruct as Foo<(&'a isize, &'a isize)>>
= note: `SomeStruct` must implement `Foo<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but `SomeStruct` actually implements `Foo<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/hrtb-exists-forall-fn.rs:17:12
|
LL | let _: for<'b> fn(&'b u32) = foo();
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -2,9 +2,7 @@ error[E0308]: mismatched types
--> $DIR/hrtb-exists-forall-fn.rs:17:34
|
LL | let _: for<'b> fn(&'b u32) = foo();
| ------------------- ^^^^^ expected concrete lifetime, found bound lifetime parameter 'b
| |
| expected due to this
| ^^^^^ one type is more general than the other
|
= note: expected fn pointer `for<'b> fn(&'b u32)`
found fn pointer `fn(&u32)`

View file

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5
|
LL | foo::<()>();
| ^^^^^^^^^^^
error: aborting due to previous error

View file

@ -32,5 +32,5 @@ fn main() {
// NB. *However*, the reinstated leak-check gives an error here.
foo::<()>();
//~^ ERROR not satisfied
//~^ ERROR implementation of `Trait` is not general enough
}

View file

@ -1,18 +1,14 @@
error[E0277]: the trait bound `(): Trait<for<'b> fn(&'b u32)>` is not satisfied
--> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:11
error: implementation of `Trait` is not general enough
--> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5
|
LL | fn foo<T>()
| --- required by a bound in this
LL | where
LL | T: Trait<for<'b> fn(&'b u32)>,
| -------------------------- required by this bound in `foo`
LL | trait Trait<T> {}
| ----------------- trait `Trait` defined here
...
LL | foo::<()>();
| ^^ the trait `Trait<for<'b> fn(&'b u32)>` is not implemented for `()`
| ^^^^^^^^^ implementation of `Trait` is not general enough
|
= help: the following implementations were found:
<() as Trait<fn(&'a u32)>>
= note: `()` must implement `Trait<for<'b> fn(&'b u32)>`
= note: ...but `()` actually implements `Trait<fn(&'0 u32)>`, for some specific lifetime `'0`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -2,6 +2,8 @@
//
// In particular, we test this pattern in trait solving, where it is not connected
// to any part of the source code.
//
// check-pass
trait Trait<T> {}
@ -30,9 +32,6 @@ fn main() {
// - `?b: ?a` -- solveable if `?b` is inferred to `'static`
// - So the subtyping check succeeds, somewhat surprisingly.
// This is because we can use `'static`.
//
// NB. *However*, the reinstated leak-check gives an error here.
foo::<()>();
//~^ ERROR not satisfied
}

View file

@ -1,18 +0,0 @@
error[E0277]: the trait bound `(): Trait<for<'b> fn(fn(&'b u32))>` is not satisfied
--> $DIR/hrtb-exists-forall-trait-covariant.rs:36:11
|
LL | fn foo<T>()
| --- required by a bound in this
LL | where
LL | T: Trait<for<'b> fn(fn(&'b u32))>,
| ------------------------------ required by this bound in `foo`
...
LL | foo::<()>();
| ^^ the trait `Trait<for<'b> fn(fn(&'b u32))>` is not implemented for `()`
|
= help: the following implementations were found:
<() as Trait<fn(fn(&'a u32))>>
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5
|
LL | foo::<()>();
| ^^^^^^^^^^^
error: aborting due to previous error

View file

@ -25,5 +25,5 @@ fn main() {
// yielding `fn(&!b u32)`, in a fresh universe U1
// - So we get `?a = !b` but the universe U0 assigned to `?a` cannot name `!b`.
foo::<()>(); //~ ERROR not satisfied
foo::<()>(); //~ ERROR implementation of `Trait` is not general enough
}

View file

@ -1,18 +1,14 @@
error[E0277]: the trait bound `(): Trait<for<'b> fn(std::cell::Cell<&'b u32>)>` is not satisfied
--> $DIR/hrtb-exists-forall-trait-invariant.rs:28:11
error: implementation of `Trait` is not general enough
--> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5
|
LL | fn foo<T>()
| --- required by a bound in this
LL | where
LL | T: Trait<for<'b> fn(Cell<&'b u32>)>,
| -------------------------------- required by this bound in `foo`
LL | trait Trait<T> {}
| ----------------- trait `Trait` defined here
...
LL | foo::<()>();
| ^^ the trait `Trait<for<'b> fn(std::cell::Cell<&'b u32>)>` is not implemented for `()`
| ^^^^^^^^^ implementation of `Trait` is not general enough
|
= help: the following implementations were found:
<() as Trait<fn(std::cell::Cell<&'a u32>)>>
= note: `()` must implement `Trait<for<'b> fn(std::cell::Cell<&'b u32>)>`
= note: ...but `()` actually implements `Trait<fn(std::cell::Cell<&'0 u32>)>`, for some specific lifetime `'0`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,24 @@
error: higher-ranked subtype error
--> $DIR/hrtb-just-for-static.rs:24:5
|
LL | want_hrtb::<StaticInt>()
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: lifetime may not live long enough
--> $DIR/hrtb-just-for-static.rs:30:5
|
LL | fn give_some<'a>() {
| -- lifetime `'a` defined here
LL | want_hrtb::<&'a u32>()
| ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
= help: consider replacing `'a` with `'static`
error: higher-ranked subtype error
--> $DIR/hrtb-just-for-static.rs:30:5
|
LL | want_hrtb::<&'a u32>()
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors

View file

@ -1,31 +1,30 @@
error[E0277]: the trait bound `for<'a> StaticInt: Foo<&'a isize>` is not satisfied
--> $DIR/hrtb-just-for-static.rs:24:17
error: implementation of `Foo` is not general enough
--> $DIR/hrtb-just-for-static.rs:24:5
|
LL | fn want_hrtb<T>()
| --------- required by a bound in this
LL | where T : for<'a> Foo<&'a isize>
| ---------------------- required by this bound in `want_hrtb`
LL | / trait Foo<X> {
LL | | fn foo(&self, x: X) { }
LL | | }
| |_- trait `Foo` defined here
...
LL | want_hrtb::<StaticInt>()
| ^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `StaticInt`
LL | want_hrtb::<StaticInt>()
| ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
= help: the following implementations were found:
<StaticInt as Foo<&'static isize>>
= note: `StaticInt` must implement `Foo<&'0 isize>`, for any lifetime `'0`...
= note: ...but `StaticInt` actually implements `Foo<&'1 isize>`, for some specific lifetime `'1`
error[E0277]: the trait bound `for<'a> &'a u32: Foo<&'a isize>` is not satisfied
--> $DIR/hrtb-just-for-static.rs:30:17
error: implementation of `Foo` is not general enough
--> $DIR/hrtb-just-for-static.rs:30:5
|
LL | fn want_hrtb<T>()
| --------- required by a bound in this
LL | where T : for<'a> Foo<&'a isize>
| ---------------------- required by this bound in `want_hrtb`
LL | / trait Foo<X> {
LL | | fn foo(&self, x: X) { }
LL | | }
| |_- trait `Foo` defined here
...
LL | want_hrtb::<&'a u32>()
| ^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `&'a u32`
LL | want_hrtb::<&'a u32>()
| ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
= help: the following implementations were found:
<&'a u32 as Foo<&'a isize>>
= note: `Foo<&'0 isize>` would have to be implemented for the type `&'a u32`, for any lifetime `'0`...
= note: ...but `Foo<&'1 isize>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,17 +1,43 @@
error: implementation of `Stream` is not general enough
--> $DIR/issue-30786.rs:108:22
error[E0599]: no method named `filterx` found for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>` in the current scope
--> $DIR/issue-30786.rs:128:22
|
LL | / pub trait Stream {
LL | | type Item;
LL | | fn next(self) -> Option<Self::Item>;
LL | | }
| |_- trait `Stream` defined here
LL | pub struct Map<S, F> {
| --------------------
| |
| method `filterx` not found for this
| doesn't satisfy `_: StreamExt`
...
LL | let map = source.map(|x: &_| x);
| ^^^ implementation of `Stream` is not general enough
LL | let filter = map.filterx(|x: &_| true);
| ^^^^^^^ method not found in `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>`
|
= note: `Stream` would have to be implemented for the type `&'0 mut Map<Repeat, [closure@$DIR/issue-30786.rs:108:26: 108:35]>`, for any lifetime `'0`...
= note: ...but `Stream` is actually implemented for the type `&'1 mut Map<Repeat, [closure@$DIR/issue-30786.rs:108:26: 108:35]>`, for some specific lifetime `'1`
= note: the method `filterx` exists but the following trait bounds were not satisfied:
`&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
which is required by `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
`&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
which is required by `&Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
`&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
which is required by `&mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
error: aborting due to previous error
error[E0599]: no method named `countx` found for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` in the current scope
--> $DIR/issue-30786.rs:141:24
|
LL | pub struct Filter<S, F> {
| -----------------------
| |
| method `countx` not found for this
| doesn't satisfy `_: StreamExt`
...
LL | let count = filter.countx();
| ^^^^^^ method not found in `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`
|
= note: the method `countx` exists but the following trait bounds were not satisfied:
`&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
which is required by `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
`&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
which is required by `&Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
`&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
which is required by `&mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0599`.

View file

@ -1,56 +1,43 @@
error: higher-ranked subtype error
--> $DIR/issue-30786.rs:108:15
error[E0599]: no method named `filterx` found for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>` in the current scope
--> $DIR/issue-30786.rs:128:22
|
LL | let map = source.map(|x: &_| x);
| ^^^^^^^^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/issue-30786.rs:114:18
LL | pub struct Map<S, F> {
| --------------------
| |
| method `filterx` not found for this
| doesn't satisfy `_: StreamExt`
...
LL | let filter = map.filterx(|x: &_| true);
| ^^^^^^^ method not found in `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>`
|
LL | let filter = map.filter(|x: &_| true);
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: the method `filterx` exists but the following trait bounds were not satisfied:
`&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
which is required by `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
`&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
which is required by `&Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
`&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
which is required by `&mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
error: higher-ranked subtype error
--> $DIR/issue-30786.rs:114:18
error[E0599]: no method named `countx` found for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` in the current scope
--> $DIR/issue-30786.rs:141:24
|
LL | let filter = map.filter(|x: &_| true);
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/issue-30786.rs:114:18
LL | pub struct Filter<S, F> {
| -----------------------
| |
| method `countx` not found for this
| doesn't satisfy `_: StreamExt`
...
LL | let count = filter.countx();
| ^^^^^^ method not found in `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`
|
LL | let filter = map.filter(|x: &_| true);
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: the method `countx` exists but the following trait bounds were not satisfied:
`&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
which is required by `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
`&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
which is required by `&Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
`&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
which is required by `&mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
error: higher-ranked subtype error
--> $DIR/issue-30786.rs:114:18
|
LL | let filter = map.filter(|x: &_| true);
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/issue-30786.rs:119:17
|
LL | let count = filter.count(); // Assert that we still have a valid stream.
| ^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/issue-30786.rs:119:17
|
LL | let count = filter.count(); // Assert that we still have a valid stream.
| ^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/issue-30786.rs:119:17
|
LL | let count = filter.count(); // Assert that we still have a valid stream.
| ^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/issue-30786.rs:119:17
|
LL | let count = filter.count(); // Assert that we still have a valid stream.
| ^^^^^^^^^^^^^^
error: aborting due to 9 previous errors
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0599`.

View file

@ -16,7 +16,7 @@
//[nll]compile-flags: -Z borrowck=mir
pub trait Stream { //[migrate]~ NOTE trait `Stream` defined here
pub trait Stream {
type Item;
fn next(self) -> Option<Self::Item>;
}
@ -37,8 +37,9 @@ pub struct Map<S, F> {
}
impl<'a, A, F, T> Stream for &'a mut Map<A, F>
where &'a mut A: Stream,
F: FnMut(<&'a mut A as Stream>::Item) -> T,
where
&'a mut A: Stream,
F: FnMut(<&'a mut A as Stream>::Item) -> T,
{
type Item = T;
fn next(self) -> Option<T> {
@ -55,8 +56,9 @@ pub struct Filter<S, F> {
}
impl<'a, A, F, T> Stream for &'a mut Filter<A, F>
where for<'b> &'b mut A: Stream<Item=T>, // <---- BAD
F: FnMut(&T) -> bool,
where
for<'b> &'b mut A: Stream<Item = T>, // <---- BAD
F: FnMut(&T) -> bool,
{
type Item = <&'a mut A as Stream>::Item;
fn next(self) -> Option<Self::Item> {
@ -69,29 +71,29 @@ where for<'b> &'b mut A: Stream<Item=T>, // <---- BAD
}
}
pub trait StreamExt where for<'b> &'b mut Self: Stream {
fn map<F>(self, func: F) -> Map<Self, F>
where Self: Sized,
for<'a> &'a mut Map<Self, F>: Stream,
pub trait StreamExt
where
for<'b> &'b mut Self: Stream,
{
fn mapx<F>(self, func: F) -> Map<Self, F>
where
Self: Sized,
for<'a> &'a mut Map<Self, F>: Stream,
{
Map {
func: func,
stream: self,
}
Map { func: func, stream: self }
}
fn filter<F>(self, func: F) -> Filter<Self, F>
where Self: Sized,
for<'a> &'a mut Filter<Self, F>: Stream,
fn filterx<F>(self, func: F) -> Filter<Self, F>
where
Self: Sized,
for<'a> &'a mut Filter<Self, F>: Stream,
{
Filter {
func: func,
stream: self,
}
Filter { func: func, stream: self }
}
fn count(mut self) -> usize
where Self: Sized,
fn countx(mut self) -> usize
where
Self: Sized,
{
let mut count = 0;
while let Some(_) = self.next() {
@ -101,24 +103,44 @@ pub trait StreamExt where for<'b> &'b mut Self: Stream {
}
}
impl<T> StreamExt for T where for<'a> &'a mut T: Stream { }
impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
fn main() {
let source = Repeat(10);
let map = source.map(|x: &_| x);
//[nll]~^ ERROR higher-ranked subtype error
//[migrate]~^^ ERROR implementation of `Stream` is not general enough
//[migrate]~| NOTE `Stream` would have to be implemented for the type `&'0 mut Map
//[migrate]~| NOTE but `Stream` is actually implemented for the type `&'1
//[migrate]~| NOTE implementation of `Stream` is not general enough
let filter = map.filter(|x: &_| true);
//[nll]~^ ERROR higher-ranked subtype error
//[nll]~| ERROR higher-ranked subtype error
//[nll]~| ERROR higher-ranked subtype error
//[nll]~| ERROR higher-ranked subtype error
let count = filter.count(); // Assert that we still have a valid stream.
//[nll]~^ ERROR higher-ranked subtype error
//[nll]~| ERROR higher-ranked subtype error
//[nll]~| ERROR higher-ranked subtype error
//[nll]~| ERROR higher-ranked subtype error
fn identity<T>(x: &T) -> &T {
x
}
fn variant1() {
let source = Repeat(10);
// Here, the call to `mapx` returns a type `T` to which `StreamExt`
// is not applicable, because `for<'b> &'b mut T: Stream`) doesn't hold.
//
// More concretely, the type `T` is `Map<Repeat, Closure>`, and
// the where clause doesn't hold because the signature of the
// closure gets inferred to a signature like `|&'_ Stream| -> &'_`
// for some specific `'_`, rather than a more generic
// signature.
//
// Why *exactly* we opt for this signature is a bit unclear to me,
// we deduce it somehow from a reuqirement that `Map: Stream` I
// guess.
let map = source.mapx(|x: &_| x);
let filter = map.filterx(|x: &_| true);
//[migrate]~^ ERROR no method named `filterx`
//[nll]~^^ ERROR no method named `filterx`
}
fn variant2() {
let source = Repeat(10);
// Here, we use a function, which is not subject to the vagaries
// of closure signature inference. In this case, we get the error
// on `countx` as, I think, the test originally expected.
let map = source.mapx(identity);
let filter = map.filterx(|x: &_| true);
let count = filter.countx();
//[migrate]~^ ERROR no method named `countx`
//[nll]~^^ ERROR no method named `countx`
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/issue-46989.rs:38:5
|
LL | assert_foo::<fn(&i32)>();
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -28,15 +28,13 @@
//
// holds because 'a can be instantiated to 'empty.
trait Foo {
trait Foo {}
}
impl<A> Foo for fn(A) { }
impl<A> Foo for fn(A) {}
fn assert_foo<T: Foo>() {}
fn main() {
assert_foo::<fn(&i32)>();
//~^ ERROR the trait bound `for<'r> fn(&'r i32): Foo` is not satisfied
//~^ ERROR implementation of `Foo` is not general enough
}

View file

@ -1,15 +1,14 @@
error[E0277]: the trait bound `for<'r> fn(&'r i32): Foo` is not satisfied
--> $DIR/issue-46989.rs:40:18
error: implementation of `Foo` is not general enough
--> $DIR/issue-46989.rs:38:5
|
LL | fn assert_foo<T: Foo>() {}
| --- required by this bound in `assert_foo`
LL | trait Foo {}
| ------------ trait `Foo` defined here
...
LL | assert_foo::<fn(&i32)>();
| ^^^^^^^^ the trait `Foo` is not implemented for `for<'r> fn(&'r i32)`
| ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
= help: the following implementations were found:
<fn(A) as Foo>
= note: `Foo` would have to be implemented for the type `for<'r> fn(&'r i32)`
= note: ...but `Foo` is actually implemented for the type `fn(&'0 i32)`, for some specific lifetime `'0`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/issue-40000.rs:6:9
|
LL | foo(bar);
| ^^^
error: aborting due to previous error

View file

@ -2,10 +2,10 @@ error[E0308]: mismatched types
--> $DIR/issue-40000.rs:6:9
|
LL | foo(bar);
| ^^^ expected concrete lifetime, found bound lifetime parameter
| ^^^ one type is more general than the other
|
= note: expected struct `std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r i32) + 'static)>`
found struct `std::boxed::Box<dyn std::ops::Fn(_)>`
= note: expected trait object `dyn for<'r> std::ops::Fn(&'r i32)`
found trait object `dyn std::ops::Fn(&i32)`
error: aborting due to previous error

View file

@ -9,11 +9,12 @@ impl<'a> Trait<'a> for Type {
}
pub fn break_me<T, F>(f: F)
where T: for<'b> Trait<'b>,
F: for<'b> FnMut(<T as Trait<'b>>::Assoc) {
where
T: for<'b> Trait<'b>,
F: for<'b> FnMut(<T as Trait<'b>>::Assoc),
{
break_me::<Type, fn(_)>;
//~^ ERROR: type mismatch in function arguments
//~| ERROR: type mismatch resolving
}
fn main() {}

View file

@ -1,29 +1,18 @@
error[E0631]: type mismatch in function arguments
--> $DIR/issue-43623.rs:14:5
--> $DIR/issue-43623.rs:16:5
|
LL | pub fn break_me<T, F>(f: F)
| -------- required by a bound in this
LL | where T: for<'b> Trait<'b>,
LL | F: for<'b> FnMut(<T as Trait<'b>>::Assoc) {
| -------------------------------------- required by this bound in `break_me`
...
LL | F: for<'b> FnMut(<T as Trait<'b>>::Assoc),
| ------------------------------ required by this bound in `break_me`
LL | {
LL | break_me::<Type, fn(_)>;
| ^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected signature of `for<'b> fn(<Type as Trait<'b>>::Assoc) -> _`
| found signature of `fn(_) -> _`
| expected signature of `fn(<Type as Trait<'b>>::Assoc) -> _`
| found signature of `fn(()) -> _`
error[E0271]: type mismatch resolving `for<'b> <fn(_) as std::ops::FnOnce<(<Type as Trait<'b>>::Assoc,)>>::Output == ()`
--> $DIR/issue-43623.rs:14:5
|
LL | pub fn break_me<T, F>(f: F)
| -------- required by a bound in this
LL | where T: for<'b> Trait<'b>,
LL | F: for<'b> FnMut(<T as Trait<'b>>::Assoc) {
| ------------------------------ required by this bound in `break_me`
LL | break_me::<Type, fn(_)>;
| ^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'b, found concrete lifetime
error: aborting due to previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.
For more information about this error, try `rustc --explain E0631`.

View file

@ -4,6 +4,8 @@ error[E0599]: no function or associated item named `make_g` found for fn pointer
LL | let x = <fn (&())>::make_g();
| ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())`
|
= note: the method `make_g` exists but the following trait bounds were not satisfied:
`for<'r> fn(&'r ()): X`
= help: items from traits can only be used if the trait is implemented and in scope
note: `X` defines an item `make_g`, perhaps you need to implement it
--> $DIR/issue-57362-2.rs:8:1

View file

@ -7,11 +7,13 @@ impl<'a> Trait<'a> for () {
}
pub fn foo<T, F>(_: T, _: F)
where T: for<'a> Trait<'a>,
F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
where
T: for<'a> Trait<'a>,
F: for<'a> FnMut(<T as Trait<'a>>::Item),
{
}
fn main() {
foo((), drop)
//~^ ERROR type mismatch in function arguments
//~| ERROR type mismatch resolving
}

View file

@ -1,31 +1,18 @@
error[E0631]: type mismatch in function arguments
--> $DIR/issue-60283.rs:14:13
--> $DIR/issue-60283.rs:17:13
|
LL | pub fn foo<T, F>(_: T, _: F)
| --- required by a bound in this
LL | where T: for<'a> Trait<'a>,
LL | F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
| ------------------------------------- required by this bound in `foo`
...
LL | F: for<'a> FnMut(<T as Trait<'a>>::Item),
| ----------------------------- required by this bound in `foo`
...
LL | foo((), drop)
| ^^^^
| |
| expected signature of `for<'a> fn(<() as Trait<'a>>::Item) -> _`
| found signature of `fn(_) -> _`
| expected signature of `fn(<() as Trait<'a>>::Item) -> _`
| found signature of `fn(()) -> _`
error[E0271]: type mismatch resolving `for<'a> <fn(_) {std::mem::drop::<_>} as std::ops::FnOnce<(<() as Trait<'a>>::Item,)>>::Output == ()`
--> $DIR/issue-60283.rs:14:5
|
LL | pub fn foo<T, F>(_: T, _: F)
| --- required by a bound in this
LL | where T: for<'a> Trait<'a>,
LL | F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
| ----------------------------- required by this bound in `foo`
...
LL | foo((), drop)
| ^^^ expected bound lifetime parameter 'a, found concrete lifetime
error: aborting due to previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.
For more information about this error, try `rustc --explain E0631`.

View file

@ -4,23 +4,19 @@
// longer get an error, because we recognize these two types as
// equivalent!
//
// Whoops -- now that we reinstituted the leak-check, we get an error
// again.
// check-pass
fn foo(
x: fn(&u8, &u8),
y: for<'a> fn(&'a u8, &'a u8),
) {
fn foo(x: fn(&u8, &u8), y: for<'a> fn(&'a u8, &'a u8)) {
// The two types above are actually equivalent. With the older
// leak check, though, we didn't consider them as equivalent, and
// hence we gave errors. But now we've fixed that.
let z = match 22 {
0 => x,
_ => y, //~ ERROR `match` arms have incompatible types
_ => y,
};
}
fn bar(
x: fn(&u8, &u8),
y: for<'a> fn(&'a u8, &'a u8),
) {
fn foo_cast(x: fn(&u8, &u8), y: for<'a> fn(&'a u8, &'a u8)) {
let z = match 22 {
// No error with an explicit cast:
0 => x as for<'a> fn(&'a u8, &'a u8),
@ -28,5 +24,4 @@ fn bar(
};
}
fn main() {
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/old-lub-glb-hr-noteq1.rs:11:14
|
LL | _ => y,
| ^
error: aborting due to previous error

View file

@ -0,0 +1,24 @@
// Test taking the LUB of two function types that are not equatable but where one is more
// general than the other. Test the case where the more general type (`x`) is the first
// match arm specifically.
fn foo(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
// The two types above are not equivalent. With the older LUB/GLB
// algorithm, this may have worked (I don't remember), but now it
// doesn't because we require equality.
let z = match 22 {
0 => x,
_ => y, //~ ERROR `match` arms have incompatible types
};
}
fn foo_cast(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
// But we can *upcast* explicitly the type of `x` and figure
// things out:
let z = match 22 {
0 => x as for<'a> fn(&'a u8, &'a u8) -> &'a u8,
_ => y,
};
}
fn main() {}

View file

@ -0,0 +1,18 @@
error[E0308]: `match` arms have incompatible types
--> $DIR/old-lub-glb-hr-noteq1.rs:11:14
|
LL | let z = match 22 {
| _____________-
LL | | 0 => x,
| | - this is found to be of type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
LL | | _ => y,
| | ^ one type is more general than the other
LL | | };
| |_____- `match` arms have incompatible types
|
= note: expected fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
found fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,33 @@
// Test taking the LUB of two function types that are not equatable but where
// one is more general than the other. Test the case where the more general type
// (`x`) is the second match arm specifically.
//
// FIXME(#73154) Skip for compare-mode because the pure NLL checker accepts this
// test. (Note that it still errors in old-lub-glb-hr-noteq1.rs). What happens
// is that, due to the ordering of the match arms, we pick the correct "more
// general" fn type, and we ignore the errors from the non-NLL type checker that
// requires equality. The NLL type checker only requires a subtyping
// relationship, and that holds.
//
// ignore-compare-mode-nll
fn foo(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
// The two types above are not equivalent. With the older LUB/GLB
// algorithm, this may have worked (I don't remember), but now it
// doesn't because we require equality.
let z = match 22 {
0 => y,
_ => x, //~ ERROR `match` arms have incompatible types
};
}
fn foo_cast(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
// But we can *upcast* explicitly the type of `x` and figure
// things out:
let z = match 22 {
0 => x as for<'a> fn(&'a u8, &'a u8) -> &'a u8,
_ => y,
};
}
fn main() {}

View file

@ -0,0 +1,18 @@
error[E0308]: `match` arms have incompatible types
--> $DIR/old-lub-glb-hr-noteq2.rs:20:14
|
LL | let z = match 22 {
| _____________-
LL | | 0 => y,
| | - this is found to be of type `for<'a> fn(&'a u8, &'a u8) -> &'a u8`
LL | | _ => x,
| | ^ one type is more general than the other
LL | | };
| |_____- `match` arms have incompatible types
|
= note: expected fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8`
found fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,18 +0,0 @@
error[E0308]: `match` arms have incompatible types
--> $DIR/old-lub-glb-hr.rs:16:14
|
LL | let z = match 22 {
| _____________-
LL | | 0 => x,
| | - this is found to be of type `for<'r, 's> fn(&'r u8, &'s u8)`
LL | | _ => y,
| | ^ expected bound lifetime parameter, found concrete lifetime
LL | | };
| |_____- `match` arms have incompatible types
|
= note: expected type `for<'r, 's> fn(&'r u8, &'s u8)`
found fn pointer `for<'a> fn(&'a u8, &'a u8)`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,14 @@
error: higher-ranked subtype error
--> $DIR/old-lub-glb-object.rs:10:14
|
LL | _ => y,
| ^
error: higher-ranked subtype error
--> $DIR/old-lub-glb-object.rs:10:14
|
LL | _ => y,
| ^
error: aborting due to 2 previous errors

View file

@ -1,22 +1,17 @@
// Test that we give a note when the old LUB/GLB algorithm would have
// succeeded but the new code (which is stricter) gives an error.
trait Foo<T, U> { }
trait Foo<T, U> {}
fn foo(
x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>,
y: &dyn for<'a> Foo<&'a u8, &'a u8>,
) {
fn foo(x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, y: &dyn for<'a> Foo<&'a u8, &'a u8>) {
let z = match 22 {
//~^ ERROR mismatched types
0 => x,
_ => y, //~ ERROR `match` arms have incompatible types
_ => y,
};
}
fn bar(
x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>,
y: &dyn for<'a> Foo<&'a u8, &'a u8>,
) {
fn bar(x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, y: &dyn for<'a> Foo<&'a u8, &'a u8>) {
// Accepted with explicit case:
let z = match 22 {
0 => x as &dyn for<'a> Foo<&'a u8, &'a u8>,
@ -24,5 +19,4 @@ fn bar(
};
}
fn main() {
}
fn main() {}

View file

@ -1,17 +1,16 @@
error[E0308]: `match` arms have incompatible types
--> $DIR/old-lub-glb-object.rs:12:14
error[E0308]: mismatched types
--> $DIR/old-lub-glb-object.rs:7:13
|
LL | let z = match 22 {
| _____________-
| _____________^
LL | |
LL | | 0 => x,
| | - this is found to be of type `&dyn for<'a, 'b> Foo<&'a u8, &'b u8>`
LL | | _ => y,
| | ^ expected bound lifetime parameter 'a, found concrete lifetime
LL | | };
| |_____- `match` arms have incompatible types
| |_____^ one type is more general than the other
|
= note: expected type `&dyn for<'a, 'b> Foo<&'a u8, &'b u8>`
found reference `&dyn for<'a> Foo<&'a u8, &'a u8>`
= note: expected trait object `dyn for<'a, 'b> Foo<&'a u8, &'b u8>`
found trait object `dyn for<'a> Foo<&'a u8, &'a u8>`
error: aborting due to previous error

View file

@ -0,0 +1,27 @@
error[E0631]: type mismatch in closure arguments
--> $DIR/closure-arg-type-mismatch.rs:3:14
|
LL | a.iter().map(|_: (u32, u32)| 45);
| ^^^ ------------------ found signature of `fn((u32, u32)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
error[E0631]: type mismatch in closure arguments
--> $DIR/closure-arg-type-mismatch.rs:4:14
|
LL | a.iter().map(|_: &(u16, u16)| 45);
| ^^^ ------------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
error[E0631]: type mismatch in closure arguments
--> $DIR/closure-arg-type-mismatch.rs:5:14
|
LL | a.iter().map(|_: (u16, u16)| 45);
| ^^^ ------------------ found signature of `fn((u16, u16)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0631`.

View file

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

View file

@ -22,28 +22,43 @@ LL | a.iter().map(|_: (u16, u16)| 45);
| |
| expected signature of `fn(&(u32, u32)) -> _`
error[E0631]: type mismatch in function arguments
--> $DIR/closure-arg-type-mismatch.rs:10:9
|
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 signature of `for<'r> fn(*mut &'r u32) -> _`
| found signature of `fn(*mut &'a 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: aborting due to 5 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.
For more information about an error, try `rustc --explain E0271`.
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 7 previous errors
Some errors have detailed explanations: E0308, E0631.
For more information about an error, try `rustc --explain E0308`.

View file

@ -0,0 +1,14 @@
error: higher-ranked subtype error
--> $DIR/closure-mismatch.rs:8:5
|
LL | baz(|_| ());
| ^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/closure-mismatch.rs:8:5
|
LL | baz(|_| ());
| ^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

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

View file

@ -1,28 +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[E0631]: type mismatch in closure arguments
--> $DIR/closure-mismatch.rs:8:5
|
LL | fn baz<T: Foo>(_: T) {}
| --- required by this bound in `baz`
...
LL | baz(|_| ());
| ^^^ ------ found signature of `fn(_) -> _`
| |
| expected signature of `for<'r> fn(&'r ()) -> _`
|
= note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:8:9: 8:15]`
error: aborting due to previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/regions-fn-subtyping-return-static-fail.rs:48:5
|
LL | want_G(baz);
| ^^^^^^^^^^^
error: aborting due to previous error

View file

@ -13,11 +13,11 @@ struct S;
// Given 'cx, return 'cx
type F = for<'cx> fn(&'cx S) -> &'cx S;
fn want_F(f: F) { }
fn want_F(f: F) {}
// Given anything, return 'static
type G = for<'cx> fn(&'cx S) -> &'static S;
fn want_G(f: G) { }
fn want_G(f: G) {}
// Should meet both.
fn foo(x: &S) -> &'static S {
@ -25,7 +25,7 @@ fn foo(x: &S) -> &'static S {
}
// Should meet both.
fn bar<'a,'b>(x: &'a S) -> &'b S {
fn bar<'a, 'b>(x: &'a S) -> &'b S {
panic!()
}
@ -37,7 +37,7 @@ fn baz(x: &S) -> &S {
fn supply_F() {
want_F(foo);
want_F(bar); //~ ERROR mismatched types
want_F(bar);
want_F(baz);
}
@ -48,5 +48,4 @@ fn supply_G() {
want_G(baz); //~ ERROR mismatched types
}
pub fn main() {
}
pub fn main() {}

View file

@ -1,21 +1,12 @@
error[E0308]: mismatched types
--> $DIR/regions-fn-subtyping-return-static-fail.rs:40:12
|
LL | want_F(bar);
| ^^^ expected concrete lifetime, found bound lifetime parameter 'cx
|
= note: expected fn pointer `for<'cx> fn(&'cx S) -> &'cx S`
found fn item `for<'a> fn(&'a S) -> &S {bar::<'_>}`
error[E0308]: mismatched types
--> $DIR/regions-fn-subtyping-return-static-fail.rs:48:12
|
LL | want_G(baz);
| ^^^ expected concrete lifetime, found bound lifetime parameter 'cx
| ^^^ one type is more general than the other
|
= note: expected fn pointer `for<'cx> fn(&'cx S) -> &'static S`
found fn item `for<'r> fn(&'r S) -> &'r S {baz}`
found fn pointer `for<'r> fn(&'r S) -> &'r S`
error: aborting due to 2 previous errors
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,14 +1,40 @@
error[E0308]: mismatched types
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43
error: lifetime may not live long enough
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:5
|
LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | // Illegal now because there is no `'b:'a` declaration.
LL | *x = *y;
| ^^^^^^^ assignment requires that `'b` must outlive `'a`
|
= help: consider adding the following bound: `'b: 'a`
error: lifetime may not live long enough
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:14:5
|
LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | a(x, y);
| ^^^^^^^ argument requires that `'b` must outlive `'a`
|
= help: consider adding the following bound: `'b: 'a`
error: higher-ranked subtype error
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12
|
LL | let _: fn(&mut &isize, &mut &isize) = a;
| ---------------------------- ^ expected concrete lifetime, found bound lifetime parameter
| |
| expected due to this
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12
|
= note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)`
found fn item `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}`
LL | let _: fn(&mut &isize, &mut &isize) = a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.

Some files were not shown because too many files have changed in this diff Show more