Open
Description
This example:
#![feature(arbitrary_self_types)]
trait Test<T: core::ops::Deref<Target = Self>> {
fn is_some(self: T);
}
fn f() {
let x = Some(2);
if x.is_some() {
println!("Some");
}
}
gives the error
error[E0277]: the trait bound `std::option::Option<{integer}>: std::ops::Deref` is not satisfied
--> src/lib.rs:8:10
|
8 | if x.is_some() {
| ^^^^^^^ the trait `std::ops::Deref` is not implemented for `std::option::Option<{integer}>`
error[E0308]: mismatched types
--> src/lib.rs:8:8
|
8 | if x.is_some() {
| ^^^^^^^^^^^ expected `bool`, found `()`
error: aborting due to 2 previous errors
rather than an error because the Test
trait is not implemented.
This is presumably just a case where improved diagnostics would be good. The inherent is_some
method winds up not triggering because it requires auto-ref rather than being passed "by value".
Originally posted by @tguser402 in #66312 (comment)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.Diagnostics: An error or lint that needs small tweaks.`#![feature(arbitrary_self_types)]`Relevant to the compiler team, which will review and decide on the PR/issue.