--- /dev/null
+// 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));
+}
--- /dev/null
+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`
+LL |
+LL | / async move {
+LL | | baz(|| async{
+LL | | foo(tx.clone());
+LL | | }).await;
+LL | | }
+ | |_____- this returned value is of type `impl std::future::Future`
+ |
+ = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::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;
+ | || - ^- value is later dropped here
+ | ||_________|______|
+ | |__________| await occurs here, with value maybe used later
+ | has type `[closure@$DIR/issue-70935-complex-spans.rs:13:13: 15:10 tx:&std::sync::mpsc::Sender<i32>]` which is not `Send`
+ = note: the return type of a function must have a statically known size
+
+error: aborting due to previous error
+