forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#125717 - weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors Refactor `#[diagnostic::do_not_recommend]` support This commit refactors the `#[do_not_recommend]` support in the old parser to also apply to projection errors and not only to selection errors. This allows the attribute to be used more widely. Part of rust-lang#51992 r? `@compiler-errors` <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r? <reviewer name> -->
- Loading branch information
Showing
4 changed files
with
75 additions
and
8 deletions.
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
15 changes: 15 additions & 0 deletions
15
tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.current.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,15 @@ | ||
error[E0277]: Very important message! | ||
--> $DIR/type_mismatch.rs:25:14 | ||
| | ||
LL | verify::<u8>(); | ||
| ^^ the trait `TheImportantOne` is not implemented for `u8` | ||
| | ||
note: required by a bound in `verify` | ||
--> $DIR/type_mismatch.rs:22:14 | ||
| | ||
LL | fn verify<T: TheImportantOne>() {} | ||
| ^^^^^^^^^^^^^^^ required by this bound in `verify` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
15 changes: 15 additions & 0 deletions
15
tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.next.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,15 @@ | ||
error[E0277]: Very important message! | ||
--> $DIR/type_mismatch.rs:25:14 | ||
| | ||
LL | verify::<u8>(); | ||
| ^^ the trait `TheImportantOne` is not implemented for `u8` | ||
| | ||
note: required by a bound in `verify` | ||
--> $DIR/type_mismatch.rs:22:14 | ||
| | ||
LL | fn verify<T: TheImportantOne>() {} | ||
| ^^^^^^^^^^^^^^^ required by this bound in `verify` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
27 changes: 27 additions & 0 deletions
27
tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.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,27 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
#![feature(do_not_recommend)] | ||
|
||
#[diagnostic::on_unimplemented(message = "Very important message!")] | ||
trait TheImportantOne {} | ||
|
||
trait ImplementationDetail { | ||
type Restriction; | ||
} | ||
|
||
#[diagnostic::do_not_recommend] | ||
impl<T: ImplementationDetail<Restriction = ()>> TheImportantOne for T {} | ||
|
||
// Comment out this `impl` to show the expected error message. | ||
impl ImplementationDetail for u8 { | ||
type Restriction = u8; | ||
} | ||
|
||
fn verify<T: TheImportantOne>() {} | ||
|
||
pub fn main() { | ||
verify::<u8>(); | ||
//~^ERROR: Very important message! [E0277] | ||
} |