- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-trait-systemArea: Trait systemArea: Trait systemAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-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
trait Test<T> {
    fn is_some(self: T);
}
fn f() {
    let x = Some(2);
    if x.is_some() {
        println!("Some");
    }
}
produces an expected error:
error[E0307]: invalid `self` parameter type: T
 --> src/lib.rs:2:22
  |
2 |     fn is_some(self: T);
  |                      ^
  |
  = note: type of `self` must be `Self` or a type that dereferences to it
  = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
trait Test<T> {
    fn is_some(self: T);
}
async fn f() {
    let x = Some(2);
    if x.is_some() {
        println!("Some");
    }
}
the original error is replaced with this:
error[E0308]: mismatched types
 --> src/lib.rs:7:8
  |
7 |     if x.is_some() {
  |        ^^^^^^^^^^^ expected bool, found ()
  |
  = note: expected type `bool`
             found type `()`
Meta
rustc --version --verbose:
rustc 1.39.0 (4560ea788 2019-11-04)
binary: rustc
commit-hash: 4560ea788cb760f0a34127156c78e2552949f734
commit-date: 2019-11-04
host: x86_64-unknown-linux-gnu
release: 1.39.0
LLVM version: 9.0
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-trait-systemArea: Trait systemArea: Trait systemAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-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.
Type
Projects
Status
Done