@@ -226,8 +226,14 @@ pub trait Try: FromResidual {
226
226
on(
227
227
all(
228
228
from_desugaring = "QuestionMark" ,
229
- _Self = "std::result::Result<T, E>" ,
230
- R = "std::option::Option<std::convert::Infallible>"
229
+ any(
230
+ _Self = "core::result::Result<T, E>" ,
231
+ _Self = "std::result::Result<T, E>" ,
232
+ ) ,
233
+ any(
234
+ R = "core::option::Option<core::convert::Infallible>" ,
235
+ R = "std::option::Option<std::convert::Infallible>" ,
236
+ )
231
237
) ,
232
238
message = "the `?` operator can only be used on `Result`s, not `Option`s, \
233
239
in {ItemContext} that returns `Result`",
@@ -237,7 +243,10 @@ pub trait Try: FromResidual {
237
243
on(
238
244
all(
239
245
from_desugaring = "QuestionMark" ,
240
- _Self = "std::result::Result<T, E>" ,
246
+ any(
247
+ _Self = "core::result::Result<T, E>" ,
248
+ _Self = "std::result::Result<T, E>" ,
249
+ )
241
250
) ,
242
251
// There's a special error message in the trait selection code for
243
252
// `From` in `?`, so this is not shown for result-in-result errors,
@@ -250,8 +259,14 @@ pub trait Try: FromResidual {
250
259
on(
251
260
all(
252
261
from_desugaring = "QuestionMark" ,
253
- _Self = "std::option::Option<T>" ,
254
- R = "std::result::Result<T, E>" ,
262
+ any(
263
+ _Self = "core::option::Option<T>" ,
264
+ _Self = "std::option::Option<T>" ,
265
+ ) ,
266
+ any(
267
+ R = "core::result::Result<T, E>" ,
268
+ R = "std::result::Result<T, E>" ,
269
+ )
255
270
) ,
256
271
message = "the `?` operator can only be used on `Option`s, not `Result`s, \
257
272
in {ItemContext} that returns `Option`",
@@ -261,7 +276,10 @@ pub trait Try: FromResidual {
261
276
on(
262
277
all(
263
278
from_desugaring = "QuestionMark" ,
264
- _Self = "std::option::Option<T>" ,
279
+ any(
280
+ _Self = "core::option::Option<T>" ,
281
+ _Self = "std::option::Option<T>" ,
282
+ )
265
283
) ,
266
284
// `Option`-in-`Option` always works, as there's only one possible
267
285
// residual, so this can also be phrased strongly.
@@ -273,8 +291,14 @@ pub trait Try: FromResidual {
273
291
on(
274
292
all(
275
293
from_desugaring = "QuestionMark" ,
276
- _Self = "std::ops::ControlFlow<B, C>" ,
277
- R = "std::ops::ControlFlow<B, C>" ,
294
+ any(
295
+ _Self = "core::ops::ControlFlow<B, C>" ,
296
+ _Self = "std::ops::ControlFlow<B, C>" ,
297
+ ) ,
298
+ any(
299
+ R = "core::ops::ControlFlow<B, C>" ,
300
+ R = "std::ops::ControlFlow<B, C>" ,
301
+ )
278
302
) ,
279
303
message = "the `?` operator in {ItemContext} that returns `ControlFlow<B, _>` \
280
304
can only be used on other `ControlFlow<B, _>`s (with the same Break type)",
@@ -285,7 +309,10 @@ pub trait Try: FromResidual {
285
309
on(
286
310
all(
287
311
from_desugaring = "QuestionMark" ,
288
- _Self = "std::ops::ControlFlow<B, C>" ,
312
+ any(
313
+ _Self = "core::ops::ControlFlow<B, C>" ,
314
+ _Self = "std::ops::ControlFlow<B, C>" ,
315
+ )
289
316
// `R` is not a `ControlFlow`, as that case was matched previously
290
317
) ,
291
318
message = "the `?` operator can only be used on `ControlFlow`s \
0 commit comments