Skip to content

Commit

Permalink
update test ui for raw-ptr borrow inside generator
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe committed Jan 19, 2020
1 parent 42b6ed1 commit cd7b5ed
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting/suggestions.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issue-64130-4-async-move.stderr
Expand Up @@ -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() {
Expand Down
16 changes: 16 additions & 0 deletions 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;
})
}
26 changes: 26 additions & 0 deletions 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

0 comments on commit cd7b5ed

Please sign in to comment.