Repository navigation
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
- StatusShow more project fieldsDone
Activity
jonas-schievink commentedon Nov 11, 2019
Nominating because:
This might indicate a quite serious bug in the compiler.
Centril commentedon Nov 12, 2019
I would suggest stable- and beta-nominating the fix for this PR; it seems like this could warrant a point release. cc @rust-lang/release @rust-lang/lang
emilyalbini commentedon Nov 12, 2019
@rustbot modify labels: beta-nominated stable-nominated
Centril commentedon Nov 12, 2019
Phew; looks like precedence works correctly in non-error code at least:
Crisis averted? :)
nikomatsakis commentedon Nov 12, 2019
@rustbot assign @csmoe
9 remaining items
tguser402 commentedon Dec 24, 2019
I managed to get similar symptoms without async but with
#![feature(arbitrary_self_types)]. But this time the trait compiles.Playground link
nikomatsakis commentedon Jan 8, 2020
I am 99% sure that the diagnosis I posted on #67651 also applies here.
nikomatsakis commentedon Feb 7, 2020
The async case is fixed by #68884, I think we should break out the arbitrary self types case into a distinct bug.
Add test for rust-lang#66312
Rollup merge of rust-lang#70376 - tmandry:issue-66312, r=Centril
Rollup merge of rust-lang#70376 - tmandry:issue-66312, r=Centril
Rollup merge of rust-lang#70376 - tmandry:issue-66312, r=Centril
Auto merge of rust-lang#70383 - Centril:rollup-hmfft3y, r=Centril