Rollup merge of #152637 - JohnTitor:issue-65866, r=estebank
Add a note about elided lifetime Fixes rust-lang/rust#65866 r? @estebank
This commit is contained in:
commit
9e38745532
3 changed files with 206 additions and 3 deletions
|
|
@ -0,0 +1,49 @@
|
|||
// Regression test for https://github.com/rust-lang/rust/issues/65866.
|
||||
|
||||
mod plain {
|
||||
struct Foo;
|
||||
|
||||
struct Re<'a> {
|
||||
_data: &'a u16,
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
fn bar(&self, r: &mut Re);
|
||||
//~^ NOTE expected
|
||||
//~| NOTE `Re` here is elided as `Re<'_>`
|
||||
}
|
||||
|
||||
impl Bar for Foo {
|
||||
fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a>) {}
|
||||
//~^ ERROR `impl` item signature doesn't match `trait` item signature
|
||||
//~| NOTE expected signature
|
||||
//~| NOTE found
|
||||
//~| HELP the lifetime requirements
|
||||
//~| HELP verify the lifetime relationships
|
||||
}
|
||||
}
|
||||
|
||||
mod with_type_args {
|
||||
struct Foo;
|
||||
|
||||
struct Re<'a, T> {
|
||||
_data: (&'a u16, T),
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
fn bar(&self, r: &mut Re<u8>);
|
||||
//~^ NOTE expected
|
||||
//~| NOTE `Re` here is elided as `Re<'_, u8>`
|
||||
}
|
||||
|
||||
impl Bar for Foo {
|
||||
fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a, u8>) {}
|
||||
//~^ ERROR `impl` item signature doesn't match `trait` item signature
|
||||
//~| NOTE expected signature
|
||||
//~| NOTE found
|
||||
//~| HELP the lifetime requirements
|
||||
//~| HELP verify the lifetime relationships
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:17:9
|
||||
|
|
||||
LL | fn bar(&self, r: &mut Re);
|
||||
| -------------------------- expected `fn(&'1 plain::Foo, &'2 mut plain::Re<'3>)`
|
||||
...
|
||||
LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 plain::Foo, &'2 mut plain::Re<'1>)`
|
||||
|
|
||||
= note: expected signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'3>)`
|
||||
found signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'1>)`
|
||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||
note: `Re` here is elided as `Re<'_>`
|
||||
--> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:11:31
|
||||
|
|
||||
LL | fn bar(&self, r: &mut Re);
|
||||
| ^^
|
||||
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:40:9
|
||||
|
|
||||
LL | fn bar(&self, r: &mut Re<u8>);
|
||||
| ------------------------------ expected `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'3, u8>)`
|
||||
...
|
||||
LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a, u8>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'1, u8>)`
|
||||
|
|
||||
= note: expected signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'3, u8>)`
|
||||
found signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'1, u8>)`
|
||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||
note: `Re` here is elided as `Re<'_, u8>`
|
||||
--> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:34:31
|
||||
|
|
||||
LL | fn bar(&self, r: &mut Re<u8>);
|
||||
| ^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue