Skip to content

Commit 3642bcd

Browse files
authored
Rollup merge of rust-lang#90939 - estebank:wg-af-polish, r=tmandry
Tweak errors coming from `for`-loop, `?` and `.await` desugaring * Suggest removal of `.await` on non-`Future` expression * Keep track of obligations introduced by desugaring * Remove span pointing at method for obligation errors coming from desugaring * Point at called local sync `fn` and suggest making it `async` ``` error[E0277]: `()` is not a future --> $DIR/unnecessary-await.rs:9:10 | LL | boo().await; | -----^^^^^^ `()` is not a future | | | this call returns `()` | = help: the trait `Future` is not implemented for `()` help: do not `.await` the expression | LL - boo().await; LL + boo(); | help: alternatively, consider making `fn boo` asynchronous | LL | async fn boo () {} | +++++ ``` Fix rust-lang#66731.
2 parents e2ee3c4 + 145848f commit 3642bcd

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

core/src/ops/try_trait.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,14 @@ use crate::ops::ControlFlow;
115115
#[unstable(feature = "try_trait_v2", issue = "84277")]
116116
#[rustc_on_unimplemented(
117117
on(
118-
all(from_method = "from_output", from_desugaring = "TryBlock"),
118+
all(from_desugaring = "TryBlock"),
119119
message = "a `try` block must return `Result` or `Option` \
120120
(or another type that implements `{Try}`)",
121121
label = "could not wrap the final value of the block as `{Self}` doesn't implement `Try`",
122122
),
123123
on(
124-
all(from_method = "branch", from_desugaring = "QuestionMark"),
125-
message = "the `?` operator can only be applied to values \
126-
that implement `{Try}`",
124+
all(from_desugaring = "QuestionMark"),
125+
message = "the `?` operator can only be applied to values that implement `{Try}`",
127126
label = "the `?` operator cannot be applied to type `{Self}`"
128127
)
129128
)]
@@ -226,7 +225,6 @@ pub trait Try: FromResidual {
226225
#[rustc_on_unimplemented(
227226
on(
228227
all(
229-
from_method = "from_residual",
230228
from_desugaring = "QuestionMark",
231229
_Self = "std::result::Result<T, E>",
232230
R = "std::option::Option<std::convert::Infallible>"
@@ -238,7 +236,6 @@ pub trait Try: FromResidual {
238236
),
239237
on(
240238
all(
241-
from_method = "from_residual",
242239
from_desugaring = "QuestionMark",
243240
_Self = "std::result::Result<T, E>",
244241
),
@@ -252,7 +249,6 @@ pub trait Try: FromResidual {
252249
),
253250
on(
254251
all(
255-
from_method = "from_residual",
256252
from_desugaring = "QuestionMark",
257253
_Self = "std::option::Option<T>",
258254
R = "std::result::Result<T, E>",
@@ -264,7 +260,6 @@ pub trait Try: FromResidual {
264260
),
265261
on(
266262
all(
267-
from_method = "from_residual",
268263
from_desugaring = "QuestionMark",
269264
_Self = "std::option::Option<T>",
270265
),
@@ -277,7 +272,6 @@ pub trait Try: FromResidual {
277272
),
278273
on(
279274
all(
280-
from_method = "from_residual",
281275
from_desugaring = "QuestionMark",
282276
_Self = "std::ops::ControlFlow<B, C>",
283277
R = "std::ops::ControlFlow<B, C>",
@@ -290,7 +284,6 @@ pub trait Try: FromResidual {
290284
),
291285
on(
292286
all(
293-
from_method = "from_residual",
294287
from_desugaring = "QuestionMark",
295288
_Self = "std::ops::ControlFlow<B, C>",
296289
// `R` is not a `ControlFlow`, as that case was matched previously
@@ -301,10 +294,7 @@ pub trait Try: FromResidual {
301294
enclosing_scope = "this function returns a `ControlFlow`",
302295
),
303296
on(
304-
all(
305-
from_method = "from_residual",
306-
from_desugaring = "QuestionMark"
307-
),
297+
all(from_desugaring = "QuestionMark"),
308298
message = "the `?` operator can only be used in {ItemContext} \
309299
that returns `Result` or `Option` \
310300
(or another type that implements `{FromResidual}`)",

0 commit comments

Comments
 (0)