Rollup merge of #67460 - estebank:named-lts, r=nikomatsakis

Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes

Fix #66406, fix #72106.

```
error: `impl` item signature doesn't match `trait` item signature
  --> $DIR/trait-param-without-lifetime-constraint.rs:14:5
   |
LL |     fn get_relation(&self) -> To;
   |     ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL |     fn get_relation(&self) -> &ProofReader {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
   |
   = note: expected `fn(&Article) -> &ProofReader`
              found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
  --> $DIR/trait-param-without-lifetime-constraint.rs:10:31
   |
LL |     fn get_relation(&self) -> To;
   |                               ^^ consider borrowing this type parameter in the trait
```

r? @nikomatsakis
This commit is contained in:
Ralf Jung 2020-05-29 21:58:14 +02:00 committed by GitHub
commit 81207802a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 324 additions and 105 deletions

View file

@ -14,16 +14,16 @@ note: ...so that the expression is assignable
|
LL | bar(foo, x)
| ^
= note: expected `Type<'_>`
found `Type<'a>`
= 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
|
LL | bar(foo, x)
| ^^^^^^^^^^^
= note: expected `Type<'static>`
found `Type<'_>`
= note: expected `Type<'static>`
found `Type<'_>`
error: aborting due to previous error

View file

@ -58,8 +58,8 @@ note: ...so that the expression is assignable
|
LL | let x: &'a _ = &y;
| ^^
= note: expected `&'a &()`
found `&'a &'b ()`
= note: expected `&'a &()`
found `&'a &'b ()`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 1:6...
--> $DIR/E0490.rs:1:6
|

View file

@ -14,16 +14,16 @@ note: ...so that the expression is assignable
|
LL | static_val(x);
| ^
= note: expected `std::boxed::Box<dyn std::fmt::Debug>`
found `std::boxed::Box<(dyn std::fmt::Debug + 'a)>`
= note: expected `std::boxed::Box<dyn std::fmt::Debug>`
found `std::boxed::Box<(dyn std::fmt::Debug + 'a)>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the types are compatible
--> $DIR/dyn-trait.rs:20:5
|
LL | static_val(x);
| ^^^^^^^^^^
= note: expected `StaticTrait`
found `StaticTrait`
= note: expected `StaticTrait`
found `StaticTrait`
error: aborting due to previous error

View file

@ -2,15 +2,17 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/mismatched_trait_impl-2.rs:8:5
|
LL | fn deref(&self) -> &dyn Trait {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found fn(&Struct) -> &dyn Trait
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Struct) -> &dyn Trait`
|
::: $SRC_DIR/libcore/ops/deref.rs:LL:COL
|
LL | fn deref(&self) -> &Self::Target;
| --------------------------------- expected fn(&Struct) -> &(dyn Trait + 'static)
| --------------------------------- expected `fn(&Struct) -> &(dyn Trait + 'static)`
|
= note: expected `fn(&Struct) -> &(dyn Trait + 'static)`
found `fn(&Struct) -> &dyn Trait`
= 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
error: aborting due to previous error

View file

@ -2,13 +2,15 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/mismatched_trait_impl.rs:9:5
|
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
| ---------------------------------------------- expected fn(&i32, &'a u32, &u32) -> &'a u32
| ---------------------------------------------- expected `fn(&i32, &'a u32, &u32) -> &'a u32`
...
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found fn(&i32, &u32, &u32) -> &u32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &u32, &u32) -> &u32`
|
= note: expected `fn(&i32, &'a u32, &u32) -> &'a u32`
found `fn(&i32, &u32, &u32) -> &u32`
= 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
error: aborting due to previous error

View file

@ -2,13 +2,15 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/mismatched_trait_impl.rs:9:5
|
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
| ---------------------------------------------- expected fn(&i32, &'a u32, &u32) -> &'a u32
| ---------------------------------------------- expected `fn(&i32, &'a u32, &u32) -> &'a u32`
...
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found fn(&i32, &u32, &u32) -> &u32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &u32, &u32) -> &u32`
|
= note: expected `fn(&i32, &'a u32, &u32) -> &'a u32`
found `fn(&i32, &u32, &u32) -> &u32`
= 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
error[E0623]: lifetime mismatch
--> $DIR/mismatched_trait_impl.rs:10:9

View file

@ -26,8 +26,8 @@ note: ...so that the types are compatible
|
LL | self.a();
| ^
= note: expected `&'a Self`
found `&Self`
= note: expected `&'a Self`
found `&Self`
error: aborting due to previous error

View file

@ -27,8 +27,8 @@ note: ...so that the types are compatible
|
LL | self.foo();
| ^^^
= note: expected `&'a Self`
found `&Self`
= note: expected `&'a Self`
found `&Self`
error: aborting due to previous error

View file

@ -87,8 +87,8 @@ note: ...so that the types are compatible
|
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `Publisher<'_>`
found `Publisher<'_>`
= note: expected `Publisher<'_>`
found `Publisher<'_>`
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/issue-20831-debruijn.rs:28:33
@ -117,8 +117,8 @@ note: ...so that the types are compatible
|
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `Publisher<'_>`
found `Publisher<'_>`
= note: expected `Publisher<'_>`
found `Publisher<'_>`
error: aborting due to 4 previous errors

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | match (&t,) {
| ^^^^^
= note: expected `(&&(T,),)`
found `(&&'a (T,),)`
= note: expected `(&&(T,),)`
found `(&&'a (T,),)`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 1:27...
--> $DIR/issue-52213.rs:1:27
|

View file

@ -20,8 +20,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(self.out_edges(u).map(|e| e.target()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/issue-55796.rs:21:9
@ -45,8 +45,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(self.in_edges(u).map(|e| e.target()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
error: aborting due to 2 previous errors

View file

@ -2,13 +2,15 @@ error: `impl` item signature doesn't match `trait` item signature
--> $DIR/lifetime-mismatch-between-trait-and-impl.rs:6:5
|
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32;
| ------------------------------------------- expected fn(&i32, &'a i32) -> &'a i32
| ------------------------------------------- expected `fn(&i32, &'a i32) -> &'a i32`
...
LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found fn(&i32, &i32) -> &i32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &i32) -> &i32`
|
= note: expected `fn(&i32, &'a i32) -> &'a i32`
found `fn(&i32, &i32) -> &i32`
= 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
error: aborting due to previous error

View file

@ -26,8 +26,8 @@ note: ...so that the expression is assignable
|
LL | Foo { bar }
| ^^^^^^^^^^^
= note: expected `Foo<'_>`
found `Foo<'_>`
= note: expected `Foo<'_>`
found `Foo<'_>`
error: aborting due to previous error

View file

@ -19,8 +19,8 @@ note: ...so that the types are compatible
|
LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `Visitor<'d>`
found `Visitor<'_>`
= note: expected `Visitor<'d>`
found `Visitor<'_>`
error: aborting due to previous error

View file

@ -16,8 +16,8 @@ note: ...so that the expression is assignable
|
LL | C { f: b }
| ^
= note: expected `std::boxed::Box<std::boxed::Box<&isize>>`
found `std::boxed::Box<std::boxed::Box<&isize>>`
= note: expected `std::boxed::Box<std::boxed::Box<&isize>>`
found `std::boxed::Box<std::boxed::Box<&isize>>`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 15:6...
--> $DIR/type-alias-free-regions.rs:15:6
|
@ -28,8 +28,8 @@ note: ...so that the expression is assignable
|
LL | C { f: b }
| ^^^^^^^^^^
= note: expected `C<'a>`
found `C<'_>`
= note: expected `C<'a>`
found `C<'_>`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/type-alias-free-regions.rs:27:16
@ -49,8 +49,8 @@ note: ...so that the expression is assignable
|
LL | C { f: Box::new(b.0) }
| ^^^
= note: expected `std::boxed::Box<&isize>`
found `std::boxed::Box<&isize>`
= note: expected `std::boxed::Box<&isize>`
found `std::boxed::Box<&isize>`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 25:6...
--> $DIR/type-alias-free-regions.rs:25:6
|
@ -61,8 +61,8 @@ note: ...so that the expression is assignable
|
LL | C { f: Box::new(b.0) }
| ^^^^^^^^^^^^^^^^^^^^^^
= note: expected `C<'a>`
found `C<'_>`
= note: expected `C<'a>`
found `C<'_>`
error: aborting due to 2 previous errors

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | <Foo<'a>>::C
| ^^^^^^^^^^^^
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that reference does not outlive borrowed content
--> $DIR/constant-in-expr-inherent-1.rs:8:5

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | T::C
| ^^^^
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: expected `Foo<'_>`
found `Foo<'a>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that reference does not outlive borrowed content
--> $DIR/constant-in-expr-trait-item-3.rs:10:5

View file

@ -24,8 +24,8 @@ note: ...so that the expression is assignable
|
LL | ss
| ^^
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/object-lifetime-default-elision.rs:71:5
@ -53,8 +53,8 @@ note: ...so that the expression is assignable
|
LL | ss
| ^^
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
= note: expected `&'b (dyn SomeTrait + 'b)`
found `&dyn SomeTrait`
error: aborting due to 2 previous errors

View file

@ -39,8 +39,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(v)
| ^
= note: expected `&[u8]`
found `&'a [u8]`
= note: expected `&[u8]`
found `&'a [u8]`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 25:9...
--> $DIR/region-object-lifetime-in-coercion.rs:25:9
|
@ -51,8 +51,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(v)
| ^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn Foo + 'b)>`
found `std::boxed::Box<dyn Foo>`
= note: expected `std::boxed::Box<(dyn Foo + 'b)>`
found `std::boxed::Box<dyn Foo>`
error: aborting due to 4 previous errors

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | impl<'a> Foo<'static> for &'a i32 {
| ^^^^^^^^^^^^
= note: expected `Foo<'static>`
found `Foo<'static>`
= note: expected `Foo<'static>`
found `Foo<'static>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the type `&i32` will meet its required lifetime bounds
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
@ -39,8 +39,8 @@ note: ...so that the types are compatible
|
LL | impl<'a,'b> Foo<'b> for &'a i64 {
| ^^^^^^^
= note: expected `Foo<'b>`
found `Foo<'_>`
= note: expected `Foo<'b>`
found `Foo<'_>`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the impl at 19:9...
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:9
|

View file

@ -14,8 +14,8 @@ note: ...so that the types are compatible
|
LL | impl<'a> Foo for &'a i32 {
| ^^^
= note: expected `Foo`
found `Foo`
= note: expected `Foo`
found `Foo`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the type `&i32` will meet its required lifetime bounds
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10

View file

@ -20,8 +20,8 @@ note: ...so that the expression is assignable
|
LL | box B(&*v) as Box<dyn X>
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
error: aborting due to previous error

View file

@ -20,8 +20,8 @@ note: ...so that the expression is assignable
|
LL | box B(&*v) as Box<dyn X>
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
= note: expected `std::boxed::Box<(dyn X + 'static)>`
found `std::boxed::Box<dyn X>`
error: aborting due to previous error

View file

@ -24,8 +24,8 @@ note: ...so that the expression is assignable
|
LL | box v as Box<dyn SomeTrait + 'a>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn SomeTrait + 'c)>`
found `std::boxed::Box<dyn SomeTrait>`
= note: expected `std::boxed::Box<(dyn SomeTrait + 'c)>`
found `std::boxed::Box<dyn SomeTrait>`
error: aborting due to previous error

View file

@ -14,8 +14,8 @@ note: ...so that the expression is assignable
|
LL | Ast::Add(x, y)
| ^
= note: expected `&Ast<'_>`
found `&Ast<'a>`
= note: expected `&Ast<'_>`
found `&Ast<'a>`
note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 6:19...
--> $DIR/regions-creating-enums4.rs:6:19
|
@ -26,8 +26,8 @@ note: ...so that the expression is assignable
|
LL | Ast::Add(x, y)
| ^^^^^^^^^^^^^^
= note: expected `Ast<'b>`
found `Ast<'_>`
= note: expected `Ast<'b>`
found `Ast<'_>`
error: aborting due to previous error

View file

@ -39,8 +39,8 @@ LL | | if false { return ay; }
LL | | return z;
LL | | }));
| |_____^
= note: expected `&isize`
found `&isize`
= note: expected `&isize`
found `&isize`
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/regions-nested-fns.rs:14:27

View file

@ -29,8 +29,8 @@ LL | | where <() as Project<'a, 'b>>::Item : Eq
LL | | {
LL | | }
| |_^
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/regions-normalize-in-where-clause-list.rs:22:1
@ -63,8 +63,8 @@ LL | | where <() as Project<'a, 'b>>::Item : Eq
LL | | {
LL | | }
| |_^
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/regions-normalize-in-where-clause-list.rs:22:4
@ -87,8 +87,8 @@ note: ...so that the types are compatible
|
LL | fn bar<'a, 'b>()
| ^^^
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
error: aborting due to 3 previous errors

View file

@ -14,8 +14,8 @@ note: ...so that the expression is assignable
|
LL | with(|o| o)
| ^
= note: expected `&isize`
found `&isize`
= note: expected `&isize`
found `&isize`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 9:14...
--> $DIR/regions-ret-borrowed-1.rs:9:14
|

View file

@ -14,8 +14,8 @@ note: ...so that the expression is assignable
|
LL | with(|o| o)
| ^
= note: expected `&isize`
found `&isize`
= note: expected `&isize`
found `&isize`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 12:14...
--> $DIR/regions-ret-borrowed.rs:12:14
|

View file

@ -41,8 +41,8 @@ note: ...so that the expression is assignable
|
LL | x
| ^
= note: expected `&'b mut (dyn Dummy + 'b)`
found `&mut (dyn Dummy + 'b)`
= note: expected `&'b mut (dyn Dummy + 'b)`
found `&mut (dyn Dummy + 'b)`
error[E0308]: mismatched types
--> $DIR/regions-trait-object-subtyping.rs:22:5

View file

@ -118,8 +118,8 @@ note: ...so that the types are compatible
|
LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected `W<'l1, 'l2>`
found `W<'_, '_>`
= note: expected `W<'l1, 'l2>`
found `W<'_, '_>`
error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the enum it is implemented for does not
--> $DIR/reject-specialized-drops-8142.rs:61:14

View file

@ -0,0 +1,53 @@
use std::error::Error;
use std::fmt;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum ValueRef<'a> {
Null,
Integer(i64),
Real(f64),
Text(&'a [u8]),
Blob(&'a [u8]),
}
impl<'a> ValueRef<'a> {
pub fn as_str(&self) -> FromSqlResult<&'a str, &'a &'a str> {
match *self {
ValueRef::Text(t) => {
std::str::from_utf8(t).map_err(|_| FromSqlError::InvalidType).map(|x| (x, &x))
}
_ => Err(FromSqlError::InvalidType),
}
}
}
#[derive(Debug)]
#[non_exhaustive]
pub enum FromSqlError {
InvalidType
}
impl fmt::Display for FromSqlError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "InvalidType")
}
}
impl Error for FromSqlError {}
pub type FromSqlResult<T, K> = Result<(T, K), FromSqlError>;
pub trait FromSql: Sized {
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
}
impl FromSql for &str {
fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> {
//~^ ERROR `impl` item signature doesn't match `trait` item signature
value.as_str()
}
}
pub fn main() {
println!("{}", "Hello World");
}

View file

@ -0,0 +1,19 @@
error: `impl` item signature doesn't match `trait` item signature
--> $DIR/self-without-lifetime-constraint.rs:45:5
|
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
| -------------------------------------------------------------------- expected `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), FromSqlError>`
...
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), FromSqlError>`
|
= note: expected `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), _>`
found `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), _>`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/self-without-lifetime-constraint.rs:41:60
|
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
| ^^^^ consider borrowing this type parameter in the trait
error: aborting due to previous error

View file

@ -19,8 +19,8 @@ note: ...so that the types are compatible
|
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
| ^^^^^^^^^^
= note: expected `T1<'a>`
found `T1<'_>`
= note: expected `T1<'a>`
found `T1<'_>`
error: aborting due to previous error

View file

@ -0,0 +1,20 @@
struct Article {
proof_reader: ProofReader,
}
struct ProofReader {
name: String,
}
pub trait HaveRelationship<To> {
fn get_relation(&self) -> To;
}
impl HaveRelationship<&ProofReader> for Article {
fn get_relation(&self) -> &ProofReader {
//~^ ERROR `impl` item signature doesn't match `trait` item signature
&self.proof_reader
}
}
fn main() {}

View file

@ -0,0 +1,19 @@
error: `impl` item signature doesn't match `trait` item signature
--> $DIR/trait-param-without-lifetime-constraint.rs:14:5
|
LL | fn get_relation(&self) -> To;
| ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL | fn get_relation(&self) -> &ProofReader {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
|
= note: expected `fn(&Article) -> &ProofReader`
found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/trait-param-without-lifetime-constraint.rs:10:31
|
LL | fn get_relation(&self) -> To;
| ^^ consider borrowing this type parameter in the trait
error: aborting due to previous error

View file

@ -23,8 +23,8 @@ note: ...so that the expression is assignable
|
LL | Box::new(items.iter())
| ^^^^^^^^^^^^^^^^^^^^^^
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = &T>>`
= note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>`
found `std::boxed::Box<dyn std::iter::Iterator<Item = &T>>`
error: aborting due to previous error