-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #75020 - JohnTitor:fix-multispan, r=estebank,tmandry
Avoid complex diagnostics in snippets which contain newlines Fixes #70935 r? `@estebank` `@tmandry`
- Loading branch information
Showing
4 changed files
with
186 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// edition:2018 | ||
// #70935: Check if we do not emit snippet | ||
// with newlines which lead complex diagnostics. | ||
|
||
use std::future::Future; | ||
|
||
async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> { | ||
} | ||
|
||
fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send { | ||
//~^ ERROR: future cannot be sent between threads safely | ||
async move { | ||
baz(|| async{ | ||
foo(tx.clone()); | ||
}).await; | ||
} | ||
} | ||
|
||
fn bar(_s: impl Future + Send) { | ||
} | ||
|
||
fn main() { | ||
let (tx, _rx) = std::sync::mpsc::channel(); | ||
bar(foo(tx)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
error: future cannot be sent between threads safely | ||
--> $DIR/issue-70935-complex-spans.rs:10:45 | ||
| | ||
LL | fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send { | ||
| ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | ||
| | ||
= help: the trait `Sync` is not implemented for `Sender<i32>` | ||
note: future is not `Send` as this value is used across an await | ||
--> $DIR/issue-70935-complex-spans.rs:13:9 | ||
| | ||
LL | / baz(|| async{ | ||
LL | | foo(tx.clone()); | ||
LL | | }).await; | ||
| |________________^ first, await occurs here, with the value maybe used later... | ||
note: the value is later dropped here | ||
--> $DIR/issue-70935-complex-spans.rs:15:17 | ||
| | ||
LL | }).await; | ||
| ^ | ||
note: this has type `[closure@$DIR/issue-70935-complex-spans.rs:13:13: 15:10]` which is not `Send` | ||
--> $DIR/issue-70935-complex-spans.rs:13:13 | ||
| | ||
LL | baz(|| async{ | ||
| _____________^ | ||
LL | | foo(tx.clone()); | ||
LL | | }).await; | ||
| |_________^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters