mirror of https://github.com/rust-lang/rust.git
Use verbose suggestion for changing arg type
This commit is contained in:
parent
c422581297
commit
75692056e1
|
@ -981,7 +981,7 @@ fn report_trait_method_mismatch<'tcx>(
|
|||
.next()
|
||||
.unwrap_or(impl_err_span);
|
||||
|
||||
diag.span_suggestion(
|
||||
diag.span_suggestion_verbose(
|
||||
span,
|
||||
"change the self-receiver type to match the trait",
|
||||
sugg,
|
||||
|
@ -1005,12 +1005,12 @@ fn report_trait_method_mismatch<'tcx>(
|
|||
}
|
||||
hir::FnRetTy::Return(hir_ty) => {
|
||||
let sugg = trait_sig.output();
|
||||
diag.span_suggestion(hir_ty.span, msg, sugg, ap);
|
||||
diag.span_suggestion_verbose(hir_ty.span, msg, sugg, ap);
|
||||
}
|
||||
};
|
||||
};
|
||||
} else if let Some(trait_ty) = trait_sig.inputs().get(*i) {
|
||||
diag.span_suggestion(
|
||||
diag.span_suggestion_verbose(
|
||||
impl_err_span,
|
||||
"change the parameter type to match the trait",
|
||||
trait_ty,
|
||||
|
|
|
@ -12,10 +12,7 @@ error[E0053]: method `make` has an incompatible type for trait
|
|||
--> $DIR/defaults-specialization.rs:19:18
|
||||
|
|
||||
LL | fn make() -> u8 { 0 }
|
||||
| ^^
|
||||
| |
|
||||
| expected associated type, found `u8`
|
||||
| help: change the output type to match the trait: `<A<T> as Tr>::Ty`
|
||||
| ^^ expected associated type, found `u8`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/defaults-specialization.rs:9:18
|
||||
|
@ -24,6 +21,10 @@ LL | fn make() -> Self::Ty {
|
|||
| ^^^^^^^^
|
||||
= note: expected signature `fn() -> <A<T> as Tr>::Ty`
|
||||
found signature `fn() -> u8`
|
||||
help: change the output type to match the trait
|
||||
|
|
||||
LL | fn make() -> <A<T> as Tr>::Ty { 0 }
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0053]: method `make` has an incompatible type for trait
|
||||
--> $DIR/defaults-specialization.rs:35:18
|
||||
|
@ -32,10 +33,7 @@ LL | default type Ty = bool;
|
|||
| ----------------------- associated type is `default` and may be overridden
|
||||
LL |
|
||||
LL | fn make() -> bool { true }
|
||||
| ^^^^
|
||||
| |
|
||||
| expected associated type, found `bool`
|
||||
| help: change the output type to match the trait: `<B<T> as Tr>::Ty`
|
||||
| ^^^^ expected associated type, found `bool`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/defaults-specialization.rs:9:18
|
||||
|
@ -44,6 +42,10 @@ LL | fn make() -> Self::Ty {
|
|||
| ^^^^^^^^
|
||||
= note: expected signature `fn() -> <B<T> as Tr>::Ty`
|
||||
found signature `fn() -> bool`
|
||||
help: change the output type to match the trait
|
||||
|
|
||||
LL | fn make() -> <B<T> as Tr>::Ty { true }
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/defaults-specialization.rs:10:9
|
||||
|
|
|
@ -2,22 +2,20 @@ error[E0053]: method `poll` has an incompatible type for trait
|
|||
--> $DIR/bad-self-type.rs:10:13
|
||||
|
|
||||
LL | fn poll(self, _: &mut Context<'_>) -> Poll<()> {
|
||||
| ^^^^
|
||||
| |
|
||||
| expected `Pin<&mut MyFuture>`, found `MyFuture`
|
||||
| help: change the self-receiver type to match the trait: `self: Pin<&mut MyFuture>`
|
||||
| ^^^^ expected `Pin<&mut MyFuture>`, found `MyFuture`
|
||||
|
|
||||
= note: expected signature `fn(Pin<&mut MyFuture>, &mut Context<'_>) -> Poll<_>`
|
||||
found signature `fn(MyFuture, &mut Context<'_>) -> Poll<_>`
|
||||
help: change the self-receiver type to match the trait
|
||||
|
|
||||
LL | fn poll(self: Pin<&mut MyFuture>, _: &mut Context<'_>) -> Poll<()> {
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0053]: method `foo` has an incompatible type for trait
|
||||
--> $DIR/bad-self-type.rs:22:18
|
||||
|
|
||||
LL | fn foo(self: Box<Self>) {}
|
||||
| ------^^^^^^^^^
|
||||
| | |
|
||||
| | expected `MyFuture`, found `Box<MyFuture>`
|
||||
| help: change the self-receiver type to match the trait: `self`
|
||||
| ^^^^^^^^^ expected `MyFuture`, found `Box<MyFuture>`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/bad-self-type.rs:17:12
|
||||
|
@ -26,6 +24,10 @@ LL | fn foo(self);
|
|||
| ^^^^
|
||||
= note: expected signature `fn(MyFuture)`
|
||||
found signature `fn(Box<MyFuture>)`
|
||||
help: change the self-receiver type to match the trait
|
||||
|
|
||||
LL | fn foo(self) {}
|
||||
| ~~~~
|
||||
|
||||
error[E0053]: method `bar` has an incompatible type for trait
|
||||
--> $DIR/bad-self-type.rs:24:17
|
||||
|
|
|
@ -2,25 +2,27 @@ error[E0053]: method `from` has an incompatible type for trait
|
|||
--> $DIR/issue-90444.rs:3:16
|
||||
|
|
||||
LL | fn from(_: fn((), (), &mut ())) -> Self {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| types differ in mutability
|
||||
| help: change the parameter type to match the trait: `for<'a> fn((), (), &'a ())`
|
||||
| ^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
||||
|
|
||||
= note: expected signature `fn(for<'a> fn((), (), &'a ())) -> A`
|
||||
found signature `fn(for<'a> fn((), (), &'a mut ())) -> A`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn from(_: for<'a> fn((), (), &'a ())) -> Self {
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0053]: method `from` has an incompatible type for trait
|
||||
--> $DIR/issue-90444.rs:11:16
|
||||
|
|
||||
LL | fn from(_: fn((), (), u64)) -> Self {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected `u32`, found `u64`
|
||||
| help: change the parameter type to match the trait: `fn((), (), u32)`
|
||||
| ^^^^^^^^^^^^^^^ expected `u32`, found `u64`
|
||||
|
|
||||
= note: expected signature `fn(fn((), (), u32)) -> B`
|
||||
found signature `fn(fn((), (), u64)) -> B`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn from(_: fn((), (), u32)) -> Self {
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,10 +2,8 @@ error[E0053]: method `b` has an incompatible type for trait
|
|||
--> $DIR/reordered-type-param.rs:16:30
|
||||
|
|
||||
LL | fn b<F:Clone,G>(&self, _x: G) -> G { panic!() }
|
||||
| - - ^
|
||||
| | | |
|
||||
| | | expected type parameter `F`, found type parameter `G`
|
||||
| | | help: change the parameter type to match the trait: `F`
|
||||
| - - ^ expected type parameter `F`, found type parameter `G`
|
||||
| | |
|
||||
| | found type parameter
|
||||
| expected type parameter
|
||||
|
|
||||
|
@ -18,6 +16,10 @@ LL | fn b<C:Clone,D>(&self, x: C) -> C;
|
|||
found signature `fn(&E, G) -> G`
|
||||
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn b<F:Clone,G>(&self, _x: F) -> G { panic!() }
|
||||
| ~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -89,13 +89,14 @@ error[E0053]: method `call` has an incompatible type for trait
|
|||
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:13:32
|
||||
|
|
||||
LL | extern "rust-call" fn call(self, args: ()) -> () {}
|
||||
| ^^^^
|
||||
| |
|
||||
| expected `&Foo`, found `Foo`
|
||||
| help: change the self-receiver type to match the trait: `&self`
|
||||
| ^^^^ expected `&Foo`, found `Foo`
|
||||
|
|
||||
= note: expected signature `extern "rust-call" fn(&Foo, ()) -> _`
|
||||
found signature `extern "rust-call" fn(Foo, ())`
|
||||
help: change the self-receiver type to match the trait
|
||||
|
|
||||
LL | extern "rust-call" fn call(&self, args: ()) -> () {}
|
||||
| ~~~~~
|
||||
|
||||
error[E0183]: manual implementations of `FnOnce` are experimental
|
||||
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:18:6
|
||||
|
@ -158,13 +159,14 @@ error[E0053]: method `call_mut` has an incompatible type for trait
|
|||
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:36
|
||||
|
|
||||
LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {}
|
||||
| ^^^^^
|
||||
| |
|
||||
| types differ in mutability
|
||||
| help: change the self-receiver type to match the trait: `&mut self`
|
||||
| ^^^^^ types differ in mutability
|
||||
|
|
||||
= note: expected signature `extern "rust-call" fn(&mut Bar, ()) -> _`
|
||||
found signature `extern "rust-call" fn(&Bar, ())`
|
||||
help: change the self-receiver type to match the trait
|
||||
|
|
||||
LL | extern "rust-call" fn call_mut(&mut self, args: ()) -> () {}
|
||||
| ~~~~~~~~~
|
||||
|
||||
error[E0046]: not all trait items implemented, missing: `Output`
|
||||
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:35:1
|
||||
|
|
|
@ -2,10 +2,8 @@ error[E0053]: method `foo` has an incompatible type for trait
|
|||
--> $DIR/impl-generic-mismatch-ab.rs:8:32
|
||||
|
|
||||
LL | fn foo<B: Debug>(&self, a: &impl Debug, b: &B) { }
|
||||
| - ^^^^^^^^^^^
|
||||
| | |
|
||||
| | expected type parameter `B`, found type parameter `impl Debug`
|
||||
| | help: change the parameter type to match the trait: `&B`
|
||||
| - ^^^^^^^^^^^ expected type parameter `B`, found type parameter `impl Debug`
|
||||
| |
|
||||
| expected type parameter
|
||||
|
|
||||
note: type in trait
|
||||
|
@ -17,6 +15,10 @@ LL | fn foo<A: Debug>(&self, a: &A, b: &impl Debug);
|
|||
found signature `fn(&(), &impl Debug, &B)`
|
||||
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn foo<B: Debug>(&self, a: &B, b: &B) { }
|
||||
| ~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -27,10 +27,7 @@ LL | type Ty = impl Sized;
|
|||
| ---------- the expected opaque type
|
||||
LL |
|
||||
LL | fn method() -> () {}
|
||||
| ^^
|
||||
| |
|
||||
| expected opaque type, found `()`
|
||||
| help: change the output type to match the trait: `<() as compare_method::Trait>::Ty`
|
||||
| ^^ expected opaque type, found `()`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/in-assoc-type-unconstrained.rs:17:24
|
||||
|
@ -44,6 +41,10 @@ note: this item must have the opaque type in its signature in order to be able t
|
|||
|
|
||||
LL | fn method() -> () {}
|
||||
| ^^^^^^
|
||||
help: change the output type to match the trait
|
||||
|
|
||||
LL | fn method() -> <() as compare_method::Trait>::Ty {}
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: unconstrained opaque type
|
||||
--> $DIR/in-assoc-type-unconstrained.rs:20:19
|
||||
|
|
|
@ -2,10 +2,8 @@ error[E0053]: method `early` has an incompatible type for trait
|
|||
--> $DIR/method-signature-matches.rs:55:27
|
||||
|
|
||||
LL | fn early<'late, T>(_: &'late ()) {}
|
||||
| - ^^^^^^^^^
|
||||
| | |
|
||||
| | expected type parameter `T`, found `()`
|
||||
| | help: change the parameter type to match the trait: `&T`
|
||||
| - ^^^^^^^^^ expected type parameter `T`, found `()`
|
||||
| |
|
||||
| expected this type parameter
|
||||
|
|
||||
note: type in trait
|
||||
|
@ -15,6 +13,10 @@ LL | fn early<'early, T>(x: &'early T) -> impl Sized;
|
|||
| ^^^^^^^^^
|
||||
= note: expected signature `fn(&T)`
|
||||
found signature `fn(&'late ())`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn early<'late, T>(_: &T) {}
|
||||
| ~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0053]: method `owo` has an incompatible type for trait
|
|||
--> $DIR/method-signature-matches.rs:11:15
|
||||
|
|
||||
LL | fn owo(_: u8) {}
|
||||
| ^^
|
||||
| |
|
||||
| expected `()`, found `u8`
|
||||
| help: change the parameter type to match the trait: `()`
|
||||
| ^^ expected `()`, found `u8`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/method-signature-matches.rs:6:15
|
||||
|
@ -14,6 +11,10 @@ LL | fn owo(x: ()) -> impl Sized;
|
|||
| ^^
|
||||
= note: expected signature `fn(())`
|
||||
found signature `fn(u8)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn owo(_: ()) {}
|
||||
| ~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0053]: method `owo` has an incompatible type for trait
|
|||
--> $DIR/method-signature-matches.rs:22:21
|
||||
|
|
||||
LL | async fn owo(_: u8) {}
|
||||
| ^^
|
||||
| |
|
||||
| expected `()`, found `u8`
|
||||
| help: change the parameter type to match the trait: `()`
|
||||
| ^^ expected `()`, found `u8`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/method-signature-matches.rs:17:21
|
||||
|
@ -14,6 +11,10 @@ LL | async fn owo(x: ()) {}
|
|||
| ^^
|
||||
= note: expected signature `fn(()) -> _`
|
||||
found signature `fn(u8) -> _`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | async fn owo(_: ()) {}
|
||||
| ~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -75,10 +75,7 @@ error[E0053]: method `bar` has an incompatible type for trait
|
|||
--> $DIR/opaque-and-lifetime-mismatch.rs:10:17
|
||||
|
|
||||
LL | fn bar() -> i32 {
|
||||
| ^^^
|
||||
| |
|
||||
| expected `Wrapper<'static>`, found `i32`
|
||||
| help: change the output type to match the trait: `Wrapper<'static>`
|
||||
| ^^^ expected `Wrapper<'static>`, found `i32`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/opaque-and-lifetime-mismatch.rs:4:17
|
||||
|
@ -87,6 +84,10 @@ LL | fn bar() -> Wrapper<impl Sized>;
|
|||
| ^^^^^^^^^^^^^^^^^^^
|
||||
= note: expected signature `fn() -> Wrapper<'static>`
|
||||
found signature `fn() -> i32`
|
||||
help: change the output type to match the trait
|
||||
|
|
||||
LL | fn bar() -> Wrapper<'static> {
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
--> $DIR/opaque-and-lifetime-mismatch.rs:24:17
|
||||
|
|
|
@ -5,10 +5,7 @@ LL | default impl<U> Foo for U
|
|||
| - found this type parameter
|
||||
...
|
||||
LL | fn bar(&self) -> U {
|
||||
| ^
|
||||
| |
|
||||
| expected associated type, found type parameter `U`
|
||||
| help: change the output type to match the trait: `impl Sized`
|
||||
| ^ expected associated type, found type parameter `U`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/specialization-broken.rs:8:22
|
||||
|
@ -17,6 +14,10 @@ LL | fn bar(&self) -> impl Sized;
|
|||
| ^^^^^^^^^^
|
||||
= note: expected signature `fn(&_) -> impl Sized`
|
||||
found signature `fn(&_) -> U`
|
||||
help: change the output type to match the trait
|
||||
|
|
||||
LL | fn bar(&self) -> impl Sized {
|
||||
| ~~~~~~~~~~
|
||||
|
||||
error: method with return-position `impl Trait` in trait cannot be specialized
|
||||
--> $DIR/specialization-broken.rs:15:5
|
||||
|
|
|
@ -26,13 +26,14 @@ LL | type Foo = impl PartialEq<(Foo, i32)>;
|
|||
| -------------------------- the found opaque type
|
||||
...
|
||||
LL | fn eq(&self, _other: &(Foo, i32)) -> bool {
|
||||
| ^^^^^^^^^^^
|
||||
| |
|
||||
| expected `a::Bar`, found opaque type
|
||||
| help: change the parameter type to match the trait: `&(a::Bar, i32)`
|
||||
| ^^^^^^^^^^^ expected `a::Bar`, found opaque type
|
||||
|
|
||||
= note: expected signature `fn(&a::Bar, &(a::Bar, _)) -> _`
|
||||
found signature `fn(&a::Bar, &(a::Foo, _)) -> _`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn eq(&self, _other: &(a::Bar, i32)) -> bool {
|
||||
| ~~~~~~~~~~~~~~
|
||||
|
||||
error: unconstrained opaque type
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:19:16
|
||||
|
@ -49,10 +50,7 @@ LL | type Foo = impl PartialEq<(Foo, i32)>;
|
|||
| -------------------------- the expected opaque type
|
||||
...
|
||||
LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
|
||||
| ^^^^^^^^^^^
|
||||
| |
|
||||
| expected opaque type, found `b::Bar`
|
||||
| help: change the parameter type to match the trait: `&(b::Foo, i32)`
|
||||
| ^^^^^^^^^^^ expected opaque type, found `b::Bar`
|
||||
|
|
||||
= note: expected signature `fn(&b::Bar, &(b::Foo, _)) -> _`
|
||||
found signature `fn(&b::Bar, &(b::Bar, _)) -> _`
|
||||
|
@ -61,6 +59,10 @@ note: this item must have the opaque type in its signature in order to be able t
|
|||
|
|
||||
LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
|
||||
| ^^
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn eq(&self, _other: &(b::Foo, i32)) -> bool {
|
||||
| ~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
@ -2,13 +2,14 @@ error[E0053]: method `fmt` has an incompatible type for trait
|
|||
--> $DIR/trait_type.rs:7:21
|
||||
|
|
||||
LL | fn fmt(&self, x: &str) -> () { }
|
||||
| ^^^^
|
||||
| |
|
||||
| types differ in mutability
|
||||
| help: change the parameter type to match the trait: `&mut Formatter<'_>`
|
||||
| ^^^^ types differ in mutability
|
||||
|
|
||||
= note: expected signature `fn(&MyType, &mut Formatter<'_>) -> Result<(), std::fmt::Error>`
|
||||
found signature `fn(&MyType, &str)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn fmt(&self, x: &mut Formatter<'_>) -> () { }
|
||||
| ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0050]: method `fmt` has 1 parameter but the declaration in trait `std::fmt::Display::fmt` has 2
|
||||
--> $DIR/trait_type.rs:12:11
|
||||
|
|
|
@ -397,10 +397,7 @@ LL | type Out = impl Debug;
|
|||
| ---------- the expected opaque type
|
||||
...
|
||||
LL | fn in_trait_impl_return() -> impl Debug { () }
|
||||
| ^^^^^^^^^^
|
||||
| |
|
||||
| expected opaque type, found a different opaque type
|
||||
| help: change the output type to match the trait: `<() as DummyTrait>::Out`
|
||||
| ^^^^^^^^^^ expected opaque type, found a different opaque type
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/where-allowed.rs:119:34
|
||||
|
@ -410,6 +407,10 @@ LL | fn in_trait_impl_return() -> Self::Out;
|
|||
= note: expected signature `fn() -> <() as DummyTrait>::Out`
|
||||
found signature `fn() -> impl Debug`
|
||||
= note: distinct uses of `impl Trait` result in different opaque types
|
||||
help: change the output type to match the trait
|
||||
|
|
||||
LL | fn in_trait_impl_return() -> <() as DummyTrait>::Out { () }
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: unconstrained opaque type
|
||||
--> $DIR/where-allowed.rs:122:16
|
||||
|
|
|
@ -4,13 +4,14 @@ error[E0053]: method `call` has an incompatible type for trait
|
|||
LL | impl<'a, T> Fn<(&'a T,)> for Foo {
|
||||
| - found this type parameter
|
||||
LL | extern "rust-call" fn call(&self, (_,): (T,)) {}
|
||||
| ^^^^
|
||||
| |
|
||||
| expected `&'a T`, found type parameter `T`
|
||||
| help: change the parameter type to match the trait: `(&'a T,)`
|
||||
| ^^^^ expected `&'a T`, found type parameter `T`
|
||||
|
|
||||
= note: expected signature `extern "rust-call" fn(&Foo, (&'a _,))`
|
||||
found signature `extern "rust-call" fn(&Foo, (_,))`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | extern "rust-call" fn call(&self, (_,): (&'a T,)) {}
|
||||
| ~~~~~~~~
|
||||
|
||||
error[E0053]: method `call_mut` has an incompatible type for trait
|
||||
--> $DIR/issue-20225.rs:11:51
|
||||
|
@ -18,13 +19,14 @@ error[E0053]: method `call_mut` has an incompatible type for trait
|
|||
LL | impl<'a, T> FnMut<(&'a T,)> for Foo {
|
||||
| - found this type parameter
|
||||
LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
|
||||
| ^^^^
|
||||
| |
|
||||
| expected `&'a T`, found type parameter `T`
|
||||
| help: change the parameter type to match the trait: `(&'a T,)`
|
||||
| ^^^^ expected `&'a T`, found type parameter `T`
|
||||
|
|
||||
= note: expected signature `extern "rust-call" fn(&mut Foo, (&'a _,))`
|
||||
found signature `extern "rust-call" fn(&mut Foo, (_,))`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | extern "rust-call" fn call_mut(&mut self, (_,): (&'a T,)) {}
|
||||
| ~~~~~~~~
|
||||
|
||||
error[E0053]: method `call_once` has an incompatible type for trait
|
||||
--> $DIR/issue-20225.rs:18:47
|
||||
|
@ -33,13 +35,14 @@ LL | impl<'a, T> FnOnce<(&'a T,)> for Foo {
|
|||
| - found this type parameter
|
||||
...
|
||||
LL | extern "rust-call" fn call_once(self, (_,): (T,)) {}
|
||||
| ^^^^
|
||||
| |
|
||||
| expected `&'a T`, found type parameter `T`
|
||||
| help: change the parameter type to match the trait: `(&'a T,)`
|
||||
| ^^^^ expected `&'a T`, found type parameter `T`
|
||||
|
|
||||
= note: expected signature `extern "rust-call" fn(Foo, (&'a _,))`
|
||||
found signature `extern "rust-call" fn(Foo, (_,))`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | extern "rust-call" fn call_once(self, (_,): (&'a T,)) {}
|
||||
| ~~~~~~~~
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -2,13 +2,14 @@ error[E0053]: method `next` has an incompatible type for trait
|
|||
--> $DIR/issue-21332.rs:5:27
|
||||
|
|
||||
LL | fn next(&mut self) -> Result<i32, i32> { Ok(7) }
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected `Option<i32>`, found `Result<i32, i32>`
|
||||
| help: change the output type to match the trait: `Option<i32>`
|
||||
| ^^^^^^^^^^^^^^^^ expected `Option<i32>`, found `Result<i32, i32>`
|
||||
|
|
||||
= note: expected signature `fn(&mut S) -> Option<i32>`
|
||||
found signature `fn(&mut S) -> Result<i32, i32>`
|
||||
help: change the output type to match the trait
|
||||
|
|
||||
LL | fn next(&mut self) -> Option<i32> { Ok(7) }
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0053]: method `foo` has an incompatible type for trait
|
|||
--> $DIR/E0053.rs:9:15
|
||||
|
|
||||
LL | fn foo(x: i16) { }
|
||||
| ^^^
|
||||
| |
|
||||
| expected `u16`, found `i16`
|
||||
| help: change the parameter type to match the trait: `u16`
|
||||
| ^^^ expected `u16`, found `i16`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/E0053.rs:2:15
|
||||
|
@ -14,15 +11,16 @@ LL | fn foo(x: u16);
|
|||
| ^^^
|
||||
= note: expected signature `fn(u16)`
|
||||
found signature `fn(i16)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn foo(x: u16) { }
|
||||
| ~~~
|
||||
|
||||
error[E0053]: method `bar` has an incompatible type for trait
|
||||
--> $DIR/E0053.rs:11:12
|
||||
|
|
||||
LL | fn bar(&mut self) { }
|
||||
| ^^^^^^^^^
|
||||
| |
|
||||
| types differ in mutability
|
||||
| help: change the self-receiver type to match the trait: `&self`
|
||||
| ^^^^^^^^^ types differ in mutability
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/E0053.rs:3:12
|
||||
|
@ -31,6 +29,10 @@ LL | fn bar(&self);
|
|||
| ^^^^^
|
||||
= note: expected signature `fn(&Bar)`
|
||||
found signature `fn(&mut Bar)`
|
||||
help: change the self-receiver type to match the trait
|
||||
|
|
||||
LL | fn bar(&self) { }
|
||||
| ~~~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,13 +2,14 @@ error[E0053]: method `drop` has an incompatible type for trait
|
|||
--> $DIR/issue-112036.rs:4:13
|
||||
|
|
||||
LL | fn drop(self) {}
|
||||
| ^^^^
|
||||
| |
|
||||
| expected `&mut Foo`, found `Foo`
|
||||
| help: change the self-receiver type to match the trait: `&mut self`
|
||||
| ^^^^ expected `&mut Foo`, found `Foo`
|
||||
|
|
||||
= note: expected signature `fn(&mut Foo)`
|
||||
found signature `fn(Foo)`
|
||||
help: change the self-receiver type to match the trait
|
||||
|
|
||||
LL | fn drop(&mut self) {}
|
||||
| ~~~~~~~~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0053]: method `bar` has an incompatible type for trait
|
|||
--> $DIR/issue-13033.rs:8:30
|
||||
|
|
||||
LL | fn bar(&mut self, other: &dyn Foo) {}
|
||||
| ^^^^^^^^
|
||||
| |
|
||||
| types differ in mutability
|
||||
| help: change the parameter type to match the trait: `&mut dyn Foo`
|
||||
| ^^^^^^^^ types differ in mutability
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/issue-13033.rs:2:30
|
||||
|
@ -14,6 +11,10 @@ LL | fn bar(&mut self, other: &mut dyn Foo);
|
|||
| ^^^^^^^^^^^^
|
||||
= note: expected signature `fn(&mut Baz, &mut dyn Foo)`
|
||||
found signature `fn(&mut Baz, &dyn Foo)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn bar(&mut self, other: &mut dyn Foo) {}
|
||||
| ~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0053]: method `foo` has an incompatible type for trait
|
|||
--> $DIR/trait-impl-fn-incompatibility.rs:9:15
|
||||
|
|
||||
LL | fn foo(x: i16) { }
|
||||
| ^^^
|
||||
| |
|
||||
| expected `u16`, found `i16`
|
||||
| help: change the parameter type to match the trait: `u16`
|
||||
| ^^^ expected `u16`, found `i16`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/trait-impl-fn-incompatibility.rs:2:15
|
||||
|
@ -14,15 +11,16 @@ LL | fn foo(x: u16);
|
|||
| ^^^
|
||||
= note: expected signature `fn(u16)`
|
||||
found signature `fn(i16)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn foo(x: u16) { }
|
||||
| ~~~
|
||||
|
||||
error[E0053]: method `bar` has an incompatible type for trait
|
||||
--> $DIR/trait-impl-fn-incompatibility.rs:10:28
|
||||
|
|
||||
LL | fn bar(&mut self, bar: &Bar) { }
|
||||
| ^^^^
|
||||
| |
|
||||
| types differ in mutability
|
||||
| help: change the parameter type to match the trait: `&mut Bar`
|
||||
| ^^^^ types differ in mutability
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/trait-impl-fn-incompatibility.rs:3:28
|
||||
|
@ -31,6 +29,10 @@ LL | fn bar(&mut self, bar: &mut Bar);
|
|||
| ^^^^^^^^
|
||||
= note: expected signature `fn(&mut Bar, &mut Bar)`
|
||||
found signature `fn(&mut Bar, &Bar)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn bar(&mut self, bar: &mut Bar) { }
|
||||
| ~~~~~~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0053]: method `foo` has an incompatible type for trait
|
|||
--> $DIR/issue-35869.rs:11:15
|
||||
|
|
||||
LL | fn foo(_: fn(u16) -> ()) {}
|
||||
| ^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected `u8`, found `u16`
|
||||
| help: change the parameter type to match the trait: `fn(u8)`
|
||||
| ^^^^^^^^^^^^^ expected `u8`, found `u16`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/issue-35869.rs:2:15
|
||||
|
@ -14,15 +11,16 @@ LL | fn foo(_: fn(u8) -> ());
|
|||
| ^^^^^^^^^^^^
|
||||
= note: expected signature `fn(fn(u8))`
|
||||
found signature `fn(fn(u16))`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn foo(_: fn(u8)) {}
|
||||
| ~~~~~~
|
||||
|
||||
error[E0053]: method `bar` has an incompatible type for trait
|
||||
--> $DIR/issue-35869.rs:13:15
|
||||
|
|
||||
LL | fn bar(_: Option<u16>) {}
|
||||
| ^^^^^^^^^^^
|
||||
| |
|
||||
| expected `u8`, found `u16`
|
||||
| help: change the parameter type to match the trait: `Option<u8>`
|
||||
| ^^^^^^^^^^^ expected `u8`, found `u16`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/issue-35869.rs:3:15
|
||||
|
@ -31,15 +29,16 @@ LL | fn bar(_: Option<u8>);
|
|||
| ^^^^^^^^^^
|
||||
= note: expected signature `fn(Option<u8>)`
|
||||
found signature `fn(Option<u16>)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn bar(_: Option<u8>) {}
|
||||
| ~~~~~~~~~~
|
||||
|
||||
error[E0053]: method `baz` has an incompatible type for trait
|
||||
--> $DIR/issue-35869.rs:15:15
|
||||
|
|
||||
LL | fn baz(_: (u16, u16)) {}
|
||||
| ^^^^^^^^^^
|
||||
| |
|
||||
| expected `u8`, found `u16`
|
||||
| help: change the parameter type to match the trait: `(u8, u16)`
|
||||
| ^^^^^^^^^^ expected `u8`, found `u16`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/issue-35869.rs:4:15
|
||||
|
@ -48,15 +47,16 @@ LL | fn baz(_: (u8, u16));
|
|||
| ^^^^^^^^^
|
||||
= note: expected signature `fn((u8, _))`
|
||||
found signature `fn((u16, _))`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn baz(_: (u8, u16)) {}
|
||||
| ~~~~~~~~~
|
||||
|
||||
error[E0053]: method `qux` has an incompatible type for trait
|
||||
--> $DIR/issue-35869.rs:17:17
|
||||
|
|
||||
LL | fn qux() -> u16 { 5u16 }
|
||||
| ^^^
|
||||
| |
|
||||
| expected `u8`, found `u16`
|
||||
| help: change the output type to match the trait: `u8`
|
||||
| ^^^ expected `u8`, found `u16`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/issue-35869.rs:5:17
|
||||
|
@ -65,6 +65,10 @@ LL | fn qux() -> u8;
|
|||
| ^^
|
||||
= note: expected signature `fn() -> u8`
|
||||
found signature `fn() -> u16`
|
||||
help: change the output type to match the trait
|
||||
|
|
||||
LL | fn qux() -> u8 { 5u16 }
|
||||
| ~~
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -2,37 +2,40 @@ error[E0053]: method `mul` has an incompatible type for trait
|
|||
--> $DIR/wrong-mul-method-signature.rs:16:21
|
||||
|
|
||||
LL | fn mul(self, s: &f64) -> Vec1 {
|
||||
| ^^^^
|
||||
| |
|
||||
| expected `f64`, found `&f64`
|
||||
| help: change the parameter type to match the trait: `f64`
|
||||
| ^^^^ expected `f64`, found `&f64`
|
||||
|
|
||||
= note: expected signature `fn(Vec1, _) -> Vec1`
|
||||
found signature `fn(Vec1, &_) -> Vec1`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn mul(self, s: f64) -> Vec1 {
|
||||
| ~~~
|
||||
|
||||
error[E0053]: method `mul` has an incompatible type for trait
|
||||
--> $DIR/wrong-mul-method-signature.rs:33:21
|
||||
|
|
||||
LL | fn mul(self, s: f64) -> Vec2 {
|
||||
| ^^^
|
||||
| |
|
||||
| expected `Vec2`, found `f64`
|
||||
| help: change the parameter type to match the trait: `Vec2`
|
||||
| ^^^ expected `Vec2`, found `f64`
|
||||
|
|
||||
= note: expected signature `fn(Vec2, Vec2) -> f64`
|
||||
found signature `fn(Vec2, f64) -> Vec2`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn mul(self, s: Vec2) -> Vec2 {
|
||||
| ~~~~
|
||||
|
||||
error[E0053]: method `mul` has an incompatible type for trait
|
||||
--> $DIR/wrong-mul-method-signature.rs:52:29
|
||||
|
|
||||
LL | fn mul(self, s: f64) -> f64 {
|
||||
| ^^^
|
||||
| |
|
||||
| expected `i32`, found `f64`
|
||||
| help: change the output type to match the trait: `i32`
|
||||
| ^^^ expected `i32`, found `f64`
|
||||
|
|
||||
= note: expected signature `fn(Vec3, _) -> i32`
|
||||
found signature `fn(Vec3, _) -> f64`
|
||||
help: change the output type to match the trait
|
||||
|
|
||||
LL | fn mul(self, s: f64) -> i32 {
|
||||
| ~~~
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong-mul-method-signature.rs:63:45
|
||||
|
|
|
@ -5,10 +5,7 @@ LL | type MyPrivate = impl Sized;
|
|||
| ---------- the found opaque type
|
||||
LL | impl Trait for u32 {
|
||||
LL | fn dont_define_this(private: MyPrivate) {
|
||||
| ^^^^^^^^^
|
||||
| |
|
||||
| expected `Private`, found opaque type
|
||||
| help: change the parameter type to match the trait: `Private`
|
||||
| ^^^^^^^^^ expected `Private`, found opaque type
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/unnameable_type.rs:10:39
|
||||
|
@ -17,6 +14,10 @@ LL | fn dont_define_this(_private: Private) {}
|
|||
| ^^^^^^^
|
||||
= note: expected signature `fn(Private)`
|
||||
found signature `fn(MyPrivate)`
|
||||
help: change the parameter type to match the trait
|
||||
|
|
||||
LL | fn dont_define_this(private: Private) {
|
||||
| ~~~~~~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0053]: method `values` has an incompatible type for trait
|
|||
--> $DIR/mismatched-map-under-self.rs:10:15
|
||||
|
|
||||
LL | fn values(self) -> Self::Values {
|
||||
| ^^^^
|
||||
| |
|
||||
| expected `&Option<T>`, found `Option<T>`
|
||||
| help: change the self-receiver type to match the trait: `&self`
|
||||
| ^^^^ expected `&Option<T>`, found `Option<T>`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/mismatched-map-under-self.rs:4:15
|
||||
|
@ -14,6 +11,10 @@ LL | fn values(&self) -> Self::Values;
|
|||
| ^^^^^
|
||||
= note: expected signature `fn(&Option<_>)`
|
||||
found signature `fn(Option<_>)`
|
||||
help: change the self-receiver type to match the trait
|
||||
|
|
||||
LL | fn values(&self) -> Self::Values {
|
||||
| ~~~~~
|
||||
|
||||
error[E0631]: type mismatch in function arguments
|
||||
--> $DIR/mismatched-map-under-self.rs:12:18
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0053]: method `dummy2` has an incompatible type for trait
|
|||
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
||||
|
|
||||
LL | fn dummy2(self: &Bar<T>) {}
|
||||
| ------^^^^^^^
|
||||
| | |
|
||||
| | expected `&'a Bar<T>`, found `Bar<T>`
|
||||
| help: change the self-receiver type to match the trait: `&self`
|
||||
| ^^^^^^^ expected `&'a Bar<T>`, found `Bar<T>`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/ufcs-explicit-self-bad.rs:31:15
|
||||
|
@ -14,6 +11,10 @@ LL | fn dummy2(&self);
|
|||
| ^^^^^
|
||||
= note: expected signature `fn(&&'a Bar<_>)`
|
||||
found signature `fn(&Bar<_>)`
|
||||
help: change the self-receiver type to match the trait
|
||||
|
|
||||
LL | fn dummy2(&self) {}
|
||||
| ~~~~~
|
||||
|
||||
error[E0307]: invalid `self` parameter type: `isize`
|
||||
--> $DIR/ufcs-explicit-self-bad.rs:8:18
|
||||
|
|
Loading…
Reference in New Issue