-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start using
#[diagnostic::do_not_recommend]
in the standard library
This commit starts using `#[diagnostic::do_not_recommend]` in the standard library to improve some error messages. In this case we just hide a certain nightly only impl as suggested in #121521
- Loading branch information
Showing
5 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/ui/diagnostic_namespace/do_not_recommend/do_not_recommend_nightly_types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
struct BarError; | ||
|
||
fn bar() -> Result<(), BarError> { | ||
Ok(()) | ||
} | ||
|
||
struct FooError; | ||
|
||
fn foo() -> Result<(), FooError> { | ||
bar()?; | ||
//~^ ERROR `?` couldn't convert the error to `FooError` | ||
Ok(()) | ||
} | ||
|
||
fn main() { | ||
foo(); | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/diagnostic_namespace/do_not_recommend/do_not_recommend_nightly_types.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0277]: `?` couldn't convert the error to `FooError` | ||
--> $DIR/do_not_recommend_nightly_types.rs:10:10 | ||
| | ||
LL | fn foo() -> Result<(), FooError> { | ||
| -------------------- expected `FooError` because of this | ||
LL | bar()?; | ||
| -----^ the trait `From<BarError>` is not implemented for `FooError`, which is required by `Result<(), FooError>: FromResidual<Result<Infallible, BarError>>` | ||
| | | ||
| this can't be annotated with `?` because it has type `Result<_, BarError>` | ||
| | ||
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait | ||
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>` | ||
= note: required for `Result<(), FooError>` to implement `FromResidual<Result<Infallible, BarError>>` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |