You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #66651 - Areredify:on-unimplemented-scope, r=davidtwco
Add `enclosing scope` parameter to `rustc_on_unimplemented`
Adds a new parameter to `#[rustc_on_unimplemented]`, `enclosing scope`, which highlights the function or closure scope with a message.
The wip part refers to adding this annotation to `Try` trait to improve ergonomics (which I don't know how to do since I change both std and librustc)
Closes#61709.
Copy file name to clipboardexpand all lines: src/test/ui/async-await/try-on-option-in-async.stderr
+24-6
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,44 @@
1
1
error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
2
2
--> $DIR/try-on-option-in-async.rs:8:9
3
3
|
4
-
LL | x?;
5
-
| ^^ cannot use the `?` operator in an async block that returns `{integer}`
4
+
LL | async {
5
+
| ___________-
6
+
LL | | let x: Option<u32> = None;
7
+
LL | | x?;
8
+
| | ^^ cannot use the `?` operator in an async block that returns `{integer}`
9
+
LL | | 22
10
+
LL | | }.await
11
+
| |_____- this function should return `Result` or `Option` to accept `?`
6
12
|
7
13
= help: the trait `std::ops::Try` is not implemented for `{integer}`
8
14
= note: required by `std::ops::Try::from_error`
9
15
10
16
error[E0277]: the `?` operator can only be used in an async closure that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
11
17
--> $DIR/try-on-option-in-async.rs:16:9
12
18
|
13
-
LL | x?;
14
-
| ^^ cannot use the `?` operator in an async closure that returns `u32`
19
+
LL | let async_closure = async || {
20
+
| __________________________________-
21
+
LL | | let x: Option<u32> = None;
22
+
LL | | x?;
23
+
| | ^^ cannot use the `?` operator in an async closure that returns `u32`
24
+
LL | | 22_u32
25
+
LL | | };
26
+
| |_____- this function should return `Result` or `Option` to accept `?`
15
27
|
16
28
= help: the trait `std::ops::Try` is not implemented for `u32`
17
29
= note: required by `std::ops::Try::from_error`
18
30
19
31
error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
20
32
--> $DIR/try-on-option-in-async.rs:25:5
21
33
|
22
-
LL | x?;
23
-
| ^^ cannot use the `?` operator in an async function that returns `u32`
34
+
LL | async fn an_async_function() -> u32 {
35
+
| _____________________________________-
36
+
LL | | let x: Option<u32> = None;
37
+
LL | | x?;
38
+
| | ^^ cannot use the `?` operator in an async function that returns `u32`
39
+
LL | | 22
40
+
LL | | }
41
+
| |_- this function should return `Result` or `Option` to accept `?`
24
42
|
25
43
= help: the trait `std::ops::Try` is not implemented for `u32`
0 commit comments