about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorcsmoe <csmoe@msn.com>2020-01-19 12:59:59 +0800
committercsmoe <csmoe@msn.com>2020-01-19 13:22:41 +0800
commitcd7b5edc2cac3fa0db6b464a6e94edd8f334274d (patch)
tree12a1c38337b68bc89453d760ea076658c990d6eb /src
parent42b6ed13be779499d118af721913a66bd3d946ea (diff)
downloadrust-cd7b5edc2cac3fa0db6b464a6e94edd8f334274d.tar.gz
rust-cd7b5edc2cac3fa0db6b464a6e94edd8f334274d.zip
update test ui for raw-ptr borrow inside generator
Diffstat (limited to 'src')
-rw-r--r--src/librustc/traits/error_reporting/suggestions.rs2
-rw-r--r--src/test/ui/async-await/issue-64130-4-async-move.stderr2
-rw-r--r--src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs16
-rw-r--r--src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr26
4 files changed, 44 insertions, 2 deletions
diff --git a/src/librustc/traits/error_reporting/suggestions.rs b/src/librustc/traits/error_reporting/suggestions.rs
index 189412f60b9..ce961112670 100644
--- a/src/librustc/traits/error_reporting/suggestions.rs
+++ b/src/librustc/traits/error_reporting/suggestions.rs
@@ -12,8 +12,8 @@ use rustc_errors::{
     error_code, pluralize, struct_span_err, Applicability, DiagnosticBuilder, Style,
 };
 use rustc_hir as hir;
-use rustc_hir::def_id::DefId;
 use rustc_hir::def::DefKind;
+use rustc_hir::def_id::DefId;
 use rustc_hir::intravisit::Visitor;
 use rustc_hir::Node;
 use rustc_span::source_map::SourceMap;
diff --git a/src/test/ui/async-await/issue-64130-4-async-move.stderr b/src/test/ui/async-await/issue-64130-4-async-move.stderr
index f59dbc26384..1e52d74f155 100644
--- a/src/test/ui/async-await/issue-64130-4-async-move.stderr
+++ b/src/test/ui/async-await/issue-64130-4-async-move.stderr
@@ -25,7 +25,7 @@ LL |                 let _x = get().await;
 ...
 LL |     }
    |     - `client` is later dropped here
-help: consider moving this method call into a `let` binding to create a shorter lived borrow
+help: consider moving this into a `let` binding to create a shorter lived borrow
   --> $DIR/issue-64130-4-async-move.rs:19:15
    |
 LL |         match client.status() {
diff --git a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs
new file mode 100644
index 00000000000..3a814b47517
--- /dev/null
+++ b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.rs
@@ -0,0 +1,16 @@
+// edition:2018
+
+struct Foo(*const u8);
+
+unsafe impl Send for Foo {}
+
+async fn bar(_: Foo) {}
+
+fn assert_send<T: Send>(_: T) {}
+
+fn main() {
+    assert_send(async {
+    //~^ ERROR future cannot be sent between threads safely
+        bar(Foo(std::ptr::null())).await;
+    })
+}
diff --git a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr
new file mode 100644
index 00000000000..7638ba1fe7d
--- /dev/null
+++ b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr
@@ -0,0 +1,26 @@
+error: future cannot be sent between threads safely
+  --> $DIR/issue-65436-raw-ptr-not-send.rs:12:5
+   |
+LL | fn assert_send<T: Send>(_: T) {}
+   |    -----------    ---- required by this bound in `assert_send`
+...
+LL |     assert_send(async {
+   |     ^^^^^^^^^^^ future returned by `main` is not `Send`
+   |
+   = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `*const u8`
+note: future is not `Send` as this value is used across an await
+  --> $DIR/issue-65436-raw-ptr-not-send.rs:14:9
+   |
+LL |         bar(Foo(std::ptr::null())).await;
+   |         ^^^^^^^^----------------^^^^^^^^- `std::ptr::null()` is later dropped here
+   |         |       |
+   |         |       has type `*const u8`
+   |         await occurs here, with `std::ptr::null()` maybe used later
+help: consider moving this into a `let` binding to create a shorter lived borrow
+  --> $DIR/issue-65436-raw-ptr-not-send.rs:14:13
+   |
+LL |         bar(Foo(std::ptr::null())).await;
+   |             ^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+