@@ -226,8 +226,14 @@ pub trait Try: FromResidual {
226226 on(
227227 all(
228228 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+ )
231237 ) ,
232238 message = "the `?` operator can only be used on `Result`s, not `Option`s, \
233239 in {ItemContext} that returns `Result`",
@@ -237,7 +243,10 @@ pub trait Try: FromResidual {
237243 on(
238244 all(
239245 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+ )
241250 ) ,
242251 // There's a special error message in the trait selection code for
243252 // `From` in `?`, so this is not shown for result-in-result errors,
@@ -250,8 +259,14 @@ pub trait Try: FromResidual {
250259 on(
251260 all(
252261 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+ )
255270 ) ,
256271 message = "the `?` operator can only be used on `Option`s, not `Result`s, \
257272 in {ItemContext} that returns `Option`",
@@ -261,7 +276,10 @@ pub trait Try: FromResidual {
261276 on(
262277 all(
263278 from_desugaring = "QuestionMark" ,
264- _Self = "std::option::Option<T>" ,
279+ any(
280+ _Self = "core::option::Option<T>" ,
281+ _Self = "std::option::Option<T>" ,
282+ )
265283 ) ,
266284 // `Option`-in-`Option` always works, as there's only one possible
267285 // residual, so this can also be phrased strongly.
@@ -273,8 +291,14 @@ pub trait Try: FromResidual {
273291 on(
274292 all(
275293 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+ )
278302 ) ,
279303 message = "the `?` operator in {ItemContext} that returns `ControlFlow<B, _>` \
280304 can only be used on other `ControlFlow<B, _>`s (with the same Break type)",
@@ -285,7 +309,10 @@ pub trait Try: FromResidual {
285309 on(
286310 all(
287311 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+ )
289316 // `R` is not a `ControlFlow`, as that case was matched previously
290317 ) ,
291318 message = "the `?` operator can only be used on `ControlFlow`s \
0 commit comments