-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-arbitrary_self_types`#![feature(arbitrary_self_types)]``#![feature(arbitrary_self_types)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.F-arbitrary_self_types`#![feature(arbitrary_self_types)]``#![feature(arbitrary_self_types)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.