diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-03 11:07:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-03 11:07:01 +0100 |
| commit | 8dacfc2adac25b8e749a19623ce4db543bb33306 (patch) | |
| tree | 4347631bddde91e7243e60aa55c196531388d59e /src/libcore/ops | |
| parent | 3045d22263b88e17e3ff2e824b25d727d31dea6d (diff) | |
| parent | 1d0c015f9b5e4da3695ed23f269dc51a8d09b8a9 (diff) | |
| download | rust-8dacfc2adac25b8e749a19623ce4db543bb33306.tar.gz rust-8dacfc2adac25b8e749a19623ce4db543bb33306.zip | |
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.
Diffstat (limited to 'src/libcore/ops')
| -rw-r--r-- | src/libcore/ops/try.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libcore/ops/try.rs b/src/libcore/ops/try.rs index 4f4652084a8..a748ee87ef9 100644 --- a/src/libcore/ops/try.rs +++ b/src/libcore/ops/try.rs @@ -5,19 +5,20 @@ /// extracting those success or failure values from an existing instance and /// creating a new instance from a success or failure value. #[unstable(feature = "try_trait", issue = "42327")] -#[rustc_on_unimplemented( +#[cfg_attr(not(bootstrap), rustc_on_unimplemented( on(all( any(from_method="from_error", from_method="from_ok"), from_desugaring="QuestionMark"), message="the `?` operator can only be used in {ItemContext} \ that returns `Result` or `Option` \ (or another type that implements `{Try}`)", -label="cannot use the `?` operator in {ItemContext} that returns `{Self}`"), +label="cannot use the `?` operator in {ItemContext} that returns `{Self}`", +enclosing_scope="this function should return `Result` or `Option` to accept `?`"), on(all(from_method="into_result", from_desugaring="QuestionMark"), message="the `?` operator can only be applied to values \ that implement `{Try}`", label="the `?` operator cannot be applied to type `{Self}`") -)] +))] #[doc(alias = "?")] pub trait Try { /// The type of this value when viewed as successful. |
