Skip to content

Commit

Permalink
Fix UI test
Browse files Browse the repository at this point in the history
fmt::Formatter is still not Send/Sync, but the UI test emitted two errors, for
the dyn Write and the Void inside Formatter. As of this PR, the Void is now
gone, but the dyn Write remains.
  • Loading branch information
Mark-Simulacrum committed Jan 20, 2020
1 parent 9ae32c9 commit a804a45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 31 deletions.
15 changes: 7 additions & 8 deletions src/test/ui/async-await/async-fn-nonsend.rs
Expand Up @@ -2,15 +2,15 @@
// edition:2018
// compile-flags: --crate-type lib

use std::{
cell::RefCell,
fmt::Debug,
rc::Rc,
};
use std::{cell::RefCell, fmt::Debug, rc::Rc};

fn non_sync() -> impl Debug { RefCell::new(()) }
fn non_sync() -> impl Debug {
RefCell::new(())
}

fn non_send() -> impl Debug { Rc::new(()) }
fn non_send() -> impl Debug {
Rc::new(())
}

fn take_ref<T>(_: &T) {}

Expand Down Expand Up @@ -53,5 +53,4 @@ pub fn pass_assert() {
//~^ ERROR future cannot be sent between threads safely
assert_send(non_sync_with_method_call());
//~^ ERROR future cannot be sent between threads safely
//~^^ ERROR future cannot be sent between threads safely
}
24 changes: 1 addition & 23 deletions src/test/ui/async-await/async-fn-nonsend.stderr
Expand Up @@ -62,27 +62,5 @@ LL | }
LL | }
| - `f` is later dropped here

error: future cannot be sent between threads safely
--> $DIR/async-fn-nonsend.rs:54:5
|
LL | fn assert_send(_: impl Send) {}
| ----------- ---- required by this bound in `assert_send`
...
LL | assert_send(non_sync_with_method_call());
| ^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send`
|
= help: within `std::fmt::ArgumentV1<'_>`, the trait `std::marker::Sync` is not implemented for `*mut (dyn std::ops::Fn() + 'static)`
note: future is not `Send` as this value is used across an await
--> $DIR/async-fn-nonsend.rs:43:9
|
LL | let f: &mut std::fmt::Formatter = panic!();
| - has type `&mut std::fmt::Formatter<'_>`
LL | if non_sync().fmt(f).unwrap() == () {
LL | fut().await;
| ^^^^^^^^^^^ await occurs here, with `f` maybe used later
LL | }
LL | }
| - `f` is later dropped here

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

0 comments on commit a804a45

Please sign in to comment.