diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /library/core/src/ops | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/core/src/ops')
-rw-r--r-- | library/core/src/ops/index.rs | 2 | ||||
-rw-r--r-- | library/core/src/ops/try_trait.rs | 45 |
2 files changed, 37 insertions, 10 deletions
diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs index 1f1784ec9..f4649be54 100644 --- a/library/core/src/ops/index.rs +++ b/library/core/src/ops/index.rs @@ -153,7 +153,7 @@ see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#ind see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>" ), on( - _Self = "std::string::String", + any(_Self = "alloc::string::String", _Self = "std::string::String"), note = "you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>" ), diff --git a/library/core/src/ops/try_trait.rs b/library/core/src/ops/try_trait.rs index b4f69d0b2..17625dacc 100644 --- a/library/core/src/ops/try_trait.rs +++ b/library/core/src/ops/try_trait.rs @@ -226,8 +226,14 @@ pub trait Try: FromResidual { on( all( from_desugaring = "QuestionMark", - _Self = "std::result::Result<T, E>", - R = "std::option::Option<std::convert::Infallible>" + any( + _Self = "core::result::Result<T, E>", + _Self = "std::result::Result<T, E>", + ), + any( + R = "core::option::Option<core::convert::Infallible>", + R = "std::option::Option<std::convert::Infallible>", + ) ), message = "the `?` operator can only be used on `Result`s, not `Option`s, \ in {ItemContext} that returns `Result`", @@ -237,7 +243,10 @@ pub trait Try: FromResidual { on( all( from_desugaring = "QuestionMark", - _Self = "std::result::Result<T, E>", + any( + _Self = "core::result::Result<T, E>", + _Self = "std::result::Result<T, E>", + ) ), // There's a special error message in the trait selection code for // `From` in `?`, so this is not shown for result-in-result errors, @@ -250,8 +259,14 @@ pub trait Try: FromResidual { on( all( from_desugaring = "QuestionMark", - _Self = "std::option::Option<T>", - R = "std::result::Result<T, E>", + any( + _Self = "core::option::Option<T>", + _Self = "std::option::Option<T>", + ), + any( + R = "core::result::Result<T, E>", + R = "std::result::Result<T, E>", + ) ), message = "the `?` operator can only be used on `Option`s, not `Result`s, \ in {ItemContext} that returns `Option`", @@ -261,7 +276,10 @@ pub trait Try: FromResidual { on( all( from_desugaring = "QuestionMark", - _Self = "std::option::Option<T>", + any( + _Self = "core::option::Option<T>", + _Self = "std::option::Option<T>", + ) ), // `Option`-in-`Option` always works, as there's only one possible // residual, so this can also be phrased strongly. @@ -273,8 +291,14 @@ pub trait Try: FromResidual { on( all( from_desugaring = "QuestionMark", - _Self = "std::ops::ControlFlow<B, C>", - R = "std::ops::ControlFlow<B, C>", + any( + _Self = "core::ops::ControlFlow<B, C>", + _Self = "std::ops::ControlFlow<B, C>", + ), + any( + R = "core::ops::ControlFlow<B, C>", + R = "std::ops::ControlFlow<B, C>", + ) ), message = "the `?` operator in {ItemContext} that returns `ControlFlow<B, _>` \ can only be used on other `ControlFlow<B, _>`s (with the same Break type)", @@ -285,7 +309,10 @@ pub trait Try: FromResidual { on( all( from_desugaring = "QuestionMark", - _Self = "std::ops::ControlFlow<B, C>", + any( + _Self = "core::ops::ControlFlow<B, C>", + _Self = "std::ops::ControlFlow<B, C>", + ) // `R` is not a `ControlFlow`, as that case was matched previously ), message = "the `?` operator can only be used on `ControlFlow`s \ |