Skip to content

Commit 17d6d11

Browse files
committed
Update error message position
1 parent b135976 commit 17d6d11

7 files changed

+10
-19
lines changed

src/librustc/traits/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2408,7 +2408,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
24082408
("`Sync`", "shared")
24092409
};
24102410

2411-
err.note(
2411+
err.set_primary_message(
24122412
&format!("future cannot be {} between threads safely", trait_verb)
24132413
);
24142414

src/test/ui/async-await/async-fn-nonsend.stderr

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely
1+
error[E0277]: future cannot be sent between threads safely
22
--> $DIR/async-fn-nonsend.rs:50:5
33
|
44
LL | fn assert_send(_: impl Send) {}
@@ -8,7 +8,6 @@ LL | assert_send(local_dropped_before_await());
88
| ^^^^^^^^^^^ future returned by `local_dropped_before_await` is not `Send`
99
|
1010
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>`
11-
= note: future cannot be sent between threads safely
1211
note: future is not `Send` as this value is used across an await
1312
--> $DIR/async-fn-nonsend.rs:25:5
1413
|
@@ -20,7 +19,7 @@ LL | fut().await;
2019
LL | }
2120
| - `x` is later dropped here
2221

23-
error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely
22+
error[E0277]: future cannot be sent between threads safely
2423
--> $DIR/async-fn-nonsend.rs:52:5
2524
|
2625
LL | fn assert_send(_: impl Send) {}
@@ -30,7 +29,6 @@ LL | assert_send(non_send_temporary_in_match());
3029
| ^^^^^^^^^^^ future returned by `non_send_temporary_in_match` is not `Send`
3130
|
3231
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>`
33-
= note: future cannot be sent between threads safely
3432
note: future is not `Send` as this value is used across an await
3533
--> $DIR/async-fn-nonsend.rs:34:20
3634
|
@@ -42,7 +40,7 @@ LL | Some(_) => fut().await,
4240
LL | }
4341
| - `non_send()` is later dropped here
4442

45-
error[E0277]: `dyn std::fmt::Write` cannot be sent between threads safely
43+
error[E0277]: future cannot be sent between threads safely
4644
--> $DIR/async-fn-nonsend.rs:54:5
4745
|
4846
LL | fn assert_send(_: impl Send) {}
@@ -52,7 +50,6 @@ LL | assert_send(non_sync_with_method_call());
5250
| ^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send`
5351
|
5452
= help: the trait `std::marker::Send` is not implemented for `dyn std::fmt::Write`
55-
= note: future cannot be sent between threads safely
5653
note: future is not `Send` as this value is used across an await
5754
--> $DIR/async-fn-nonsend.rs:43:9
5855
|
@@ -65,7 +62,7 @@ LL | }
6562
LL | }
6663
| - `f` is later dropped here
6764

68-
error[E0277]: `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
65+
error[E0277]: future cannot be sent between threads safely
6966
--> $DIR/async-fn-nonsend.rs:54:5
7067
|
7168
LL | fn assert_send(_: impl Send) {}
@@ -75,7 +72,6 @@ LL | assert_send(non_sync_with_method_call());
7572
| ^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send`
7673
|
7774
= help: within `std::fmt::ArgumentV1<'_>`, the trait `std::marker::Sync` is not implemented for `*mut (dyn std::ops::Fn() + 'static)`
78-
= note: future cannot be sent between threads safely
7975
note: future is not `Send` as this value is used across an await
8076
--> $DIR/async-fn-nonsend.rs:43:9
8177
|

src/test/ui/async-await/issue-64130-1-sync.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: `Foo` cannot be shared between threads safely
1+
error[E0277]: future cannot be shared between threads safely
22
--> $DIR/issue-64130-1-sync.rs:21:5
33
|
44
LL | fn is_sync<T: Sync>(t: T) { }
@@ -8,7 +8,6 @@ LL | is_sync(bar());
88
| ^^^^^^^ future returned by `bar` is not `Sync`
99
|
1010
= help: within `impl std::future::Future`, the trait `std::marker::Sync` is not implemented for `Foo`
11-
= note: future cannot be shared between threads safely
1211
note: future is not `Sync` as this value is used across an await
1312
--> $DIR/issue-64130-1-sync.rs:15:5
1413
|

src/test/ui/async-await/issue-64130-2-send.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: `Foo` cannot be sent between threads safely
1+
error[E0277]: future cannot be sent between threads safely
22
--> $DIR/issue-64130-2-send.rs:21:5
33
|
44
LL | fn is_send<T: Send>(t: T) { }
@@ -8,7 +8,6 @@ LL | is_send(bar());
88
| ^^^^^^^ future returned by `bar` is not `Send`
99
|
1010
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `Foo`
11-
= note: future cannot be sent between threads safely
1211
note: future is not `Send` as this value is used across an await
1312
--> $DIR/issue-64130-2-send.rs:15:5
1413
|

src/test/ui/async-await/issue-64130-4-async-move.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
error[E0277]: `(dyn std::any::Any + std::marker::Send + 'static)` cannot be shared between threads safely
1+
error[E0277]: future cannot be sent between threads safely
22
--> $DIR/issue-64130-4-async-move.rs:15:17
33
|
44
LL | pub fn foo() -> impl Future + Send {
55
| ^^^^^^^^^^^^^^^^^^ future returned by `foo` is not `Send`
66
|
77
= help: the trait `std::marker::Sync` is not implemented for `(dyn std::any::Any + std::marker::Send + 'static)`
8-
= note: future cannot be sent between threads safely
98
note: future is not `Send` as this value is used across an await
109
--> $DIR/issue-64130-4-async-move.rs:21:26
1110
|

src/test/ui/async-await/issue-64130-non-send-future-diags.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: `std::sync::MutexGuard<'_, u32>` cannot be sent between threads safely
1+
error[E0277]: future cannot be sent between threads safely
22
--> $DIR/issue-64130-non-send-future-diags.rs:21:5
33
|
44
LL | fn is_send<T: Send>(t: T) { }
@@ -8,7 +8,6 @@ LL | is_send(foo());
88
| ^^^^^^^ future returned by `foo` is not `Send`
99
|
1010
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard<'_, u32>`
11-
= note: future cannot be sent between threads safely
1211
note: future is not `Send` as this value is used across an await
1312
--> $DIR/issue-64130-non-send-future-diags.rs:15:5
1413
|

src/test/ui/generator/not-send-sync.stderr

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | assert_send(|| {
1111
= note: required because of the requirements on the impl of `std::marker::Send` for `&std::cell::Cell<i32>`
1212
= note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:16:17: 20:6 a:&std::cell::Cell<i32> _]`
1313

14-
error[E0277]: `std::cell::Cell<i32>` cannot be shared between threads safely
14+
error[E0277]: future cannot be shared between threads safely
1515
--> $DIR/not-send-sync.rs:9:5
1616
|
1717
LL | fn assert_sync<T: Sync>(_: T) {}
@@ -21,7 +21,6 @@ LL | assert_sync(|| {
2121
| ^^^^^^^^^^^ future returned by `main` is not `Sync`
2222
|
2323
= help: within `[generator@$DIR/not-send-sync.rs:9:17: 13:6 {std::cell::Cell<i32>, ()}]`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell<i32>`
24-
= note: future cannot be shared between threads safely
2524
note: future is not `Sync` as this value is used across an yield
2625
--> $DIR/not-send-sync.rs:12:9
2726
|

0 commit comments

Comments
 (0)