Given the following snippet
trait Trait { fn f() -> impl Sized; }
impl Trait for () { fn f() {} }
the compiler emits a correct suggestion:
warning: impl trait in impl method signature does not match trait method signature
--> src/lib.rs:3:21
|
1 | trait Trait { fn f() -> impl Sized; }
| ---------- return type from trait method defined here
2 |
3 | impl Trait for () { fn f() {} }
| ^^^^^^
|
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
= note: `#[warn(refining_impl_trait_internal)]` (part of `#[warn(refining_impl_trait)]`) on by default
help: replace the return type so that it matches the trait
|
3 | impl Trait for () { fn f()-> impl Sized {} }
| +++++++++++++
However, if you enable the feature return_type_notation the suggestion will be different and invalid:
#![feature(return_type_notation)]
trait Trait { fn f() -> impl Sized; }
impl Trait for () { fn f() {} }
warning: impl trait in impl method signature does not match trait method signature
--> src/lib.rs:5:21
|
3 | trait Trait { fn f() -> impl Sized; }
| ---------- return type from trait method defined here
4 |
5 | impl Trait for () { fn f() {} }
| ^^^^^^
|
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
= note: `#[warn(refining_impl_trait_internal)]` (part of `#[warn(refining_impl_trait)]`) on by default
help: replace the return type so that it matches the trait
|
5 | impl Trait for () { fn f()-> impl Sized { <Self as Trait>::f(..) } {} }
| ++++++++++++++++++++++++++++++++++++++++
Given the following snippet
the compiler emits a correct suggestion:
However, if you enable the feature
return_type_notationthe suggestion will be different and invalid: