-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-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.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.P-mediumMedium priorityMedium 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
For a specific case, the compiler reports an incorrect error message when there is a duplicate error
I tried this code:
pub struct Foo(*const ());
unsafe impl Send for Foo {}
unsafe impl Send for Foo {}
impl Foo {
fn bar(&self) {}
}
fn assert_send<T: Send>(_: T) {}
fn main() {
let foo = Foo(&());
assert_send(async move {
foo.bar();
})
}it reports this error:
|
10 | fn assert_send<T: Send>(_: T) {}
| ----------- ---- required by this bound in `assert_send`
...
13 | let foo = Foo(&());
| --- consider giving `foo` a type
14 | assert_send(async move {
| ^^^^^^^^^^^ cannot infer type for struct `Foo`
|
= note: cannot resolve `Foo: std::marker::Send`
= note: required because it appears within the type `[static generator@src/main.rs:14:28: 16:6 foo:Foo {}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@src/main.rs:14:28: 16:6 foo:Foo {}]>`
= note: required because it appears within the type `impl std::future::Future
If I comment out the line that calls foo.bar() I get the expected error:
|
3 | unsafe impl Send for Foo {}
| ------------------------ first implementation here
4 | unsafe impl Send for Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo`
Here's a playground
Meta
Reproduced in 1.14.1, It also happens in nightly
originally found in
rustc --version --verbose:
rustc --version --verbose
rustc 1.41.0 (5e1a79984 2020-01-27)
binary: rustc
commit-hash: 5e1a799842ba6ed4a57e91f7ab9435947482f7d8
commit-date: 2020-01-27
host: x86_64-apple-darwin
release: 1.41.0
LLVM version: 9.0
estebank
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-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.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.P-mediumMedium priorityMedium 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.