-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Refactor rustc_on_unimplemented's filter parser #140307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+510
−194
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,64 +1,109 @@ | ||
// ignore-tidy-linelength | ||
|
||
#![crate_type = "lib"] | ||
#![feature(rustc_attrs)] | ||
|
||
#![allow(unused)] | ||
|
||
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"] | ||
trait Foo<Bar, Baz, Quux> | ||
{} | ||
trait Foo<Bar, Baz, Quux> {} | ||
|
||
#[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"] | ||
#[rustc_on_unimplemented = "a collection of type `{Self}` cannot \ | ||
be built from an iterator over elements of type `{A}`"] | ||
trait MyFromIterator<A> { | ||
/// Builds a container with elements from an external iterator. | ||
fn my_from_iter<T: Iterator<Item=A>>(iterator: T) -> Self; | ||
fn my_from_iter<T: Iterator<Item = A>>(iterator: T) -> Self; | ||
} | ||
|
||
#[rustc_on_unimplemented] | ||
//~^ ERROR malformed `rustc_on_unimplemented` attribute | ||
trait BadAnnotation1 | ||
{} | ||
trait NoContent {} | ||
|
||
#[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"] | ||
//~^ ERROR cannot find parameter C on this trait | ||
trait BadAnnotation2<A,B> | ||
{} | ||
trait ParameterNotPresent<A, B> {} | ||
|
||
#[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"] | ||
//~^ ERROR positional format arguments are not allowed here | ||
trait BadAnnotation3<A,B> | ||
{} | ||
trait NoPositionalArgs<A, B> {} | ||
|
||
#[rustc_on_unimplemented(lorem="")] | ||
//~^ ERROR this attribute must have a valid | ||
trait BadAnnotation4 {} | ||
#[rustc_on_unimplemented(lorem = "")] | ||
//~^ ERROR this attribute must have a value | ||
//~^^ NOTE e.g. `#[rustc_on_unimplemented(message="foo")]` | ||
//~^^^ NOTE expected value here | ||
trait EmptyMessage {} | ||
|
||
#[rustc_on_unimplemented(lorem(ipsum(dolor)))] | ||
//~^ ERROR this attribute must have a valid | ||
trait BadAnnotation5 {} | ||
|
||
#[rustc_on_unimplemented(message="x", message="y")] | ||
//~^ ERROR this attribute must have a valid | ||
trait BadAnnotation6 {} | ||
|
||
#[rustc_on_unimplemented(message="x", on(desugared, message="y"))] | ||
//~^ ERROR this attribute must have a valid | ||
trait BadAnnotation7 {} | ||
|
||
#[rustc_on_unimplemented(on(), message="y")] | ||
//~^ ERROR this attribute must have a value | ||
//~^^ NOTE e.g. `#[rustc_on_unimplemented(message="foo")]` | ||
//~^^^ NOTE expected value here | ||
trait Invalid {} | ||
|
||
#[rustc_on_unimplemented(message = "x", message = "y")] | ||
//~^ ERROR this attribute must have a value | ||
//~^^ NOTE e.g. `#[rustc_on_unimplemented(message="foo")]` | ||
//~^^^ NOTE expected value here | ||
trait DuplicateMessage {} | ||
|
||
#[rustc_on_unimplemented(message = "x", on(desugared, message = "y"))] | ||
//~^ ERROR this attribute must have a value | ||
//~^^ NOTE e.g. `#[rustc_on_unimplemented(message="foo")]` | ||
//~^^^ NOTE expected value here | ||
trait OnInWrongPosition {} | ||
|
||
#[rustc_on_unimplemented(on(), message = "y")] | ||
//~^ ERROR empty `on`-clause | ||
trait BadAnnotation8 {} | ||
|
||
#[rustc_on_unimplemented(on="x", message="y")] | ||
//~^ ERROR this attribute must have a valid | ||
trait BadAnnotation9 {} | ||
|
||
#[rustc_on_unimplemented(on(x="y"), message="y")] | ||
trait BadAnnotation10 {} | ||
|
||
#[rustc_on_unimplemented(on(desugared, on(desugared, message="x")), message="y")] | ||
//~^ ERROR this attribute must have a valid | ||
trait BadAnnotation11 {} | ||
|
||
pub fn main() { | ||
} | ||
//~^^ NOTE empty `on`-clause here | ||
trait EmptyOn {} | ||
|
||
#[rustc_on_unimplemented(on = "x", message = "y")] | ||
//~^ ERROR this attribute must have a value | ||
//~^^ NOTE e.g. `#[rustc_on_unimplemented(message="foo")]` | ||
//~^^^ NOTE expected value here | ||
trait ExpectedPredicateInOn {} | ||
|
||
#[rustc_on_unimplemented(on(x = "y"), message = "y")] | ||
trait OnWithoutDirectives {} | ||
|
||
#[rustc_on_unimplemented(on(from_desugaring, on(from_desugaring, message = "x")), message = "y")] | ||
//~^ ERROR this attribute must have a value | ||
//~^^ NOTE e.g. `#[rustc_on_unimplemented(message="foo")]` | ||
//~^^^ NOTE expected value here | ||
trait NestedOn {} | ||
|
||
#[rustc_on_unimplemented(on("y", message = "y"))] | ||
//~^ ERROR literals inside `on`-clauses are not supported | ||
//~^^ NOTE unexpected literal here | ||
trait UnsupportedLiteral {} | ||
|
||
#[rustc_on_unimplemented(on(42, message = "y"))] | ||
//~^ ERROR literals inside `on`-clauses are not supported | ||
//~^^ NOTE unexpected literal here | ||
trait UnsupportedLiteral2 {} | ||
|
||
#[rustc_on_unimplemented(on(not(a, b), message = "y"))] | ||
//~^ ERROR expected a single predicate in `not(..)` [E0232] | ||
//~^^ NOTE unexpected quantity of predicates here | ||
trait ExpectedOnePattern {} | ||
|
||
#[rustc_on_unimplemented(on(not(), message = "y"))] | ||
//~^ ERROR expected a single predicate in `not(..)` [E0232] | ||
//~^^ NOTE unexpected quantity of predicates here | ||
trait ExpectedOnePattern2 {} | ||
|
||
#[rustc_on_unimplemented(on(thing::What, message = "y"))] | ||
//~^ ERROR expected an identifier inside this `on`-clause | ||
//~^^ NOTE expected an identifier here, not `thing::What` | ||
trait KeyMustBeIdentifier {} | ||
|
||
#[rustc_on_unimplemented(on(thing::What = "value", message = "y"))] | ||
//~^ ERROR expected an identifier inside this `on`-clause | ||
//~^^ NOTE expected an identifier here, not `thing::What` | ||
trait KeyMustBeIdentifier2 {} | ||
|
||
#[rustc_on_unimplemented(on(aaaaaaaaaaaaaa(a, b), message = "y"))] | ||
//~^ ERROR this predicate is invalid | ||
//~^^ NOTE expected one of `any`, `all` or `not` here, not `aaaaaaaaaaaaaa` | ||
trait InvalidPredicate {} | ||
|
||
#[rustc_on_unimplemented(on(something, message = "y"))] | ||
//~^ ERROR invalid flag in `on`-clause | ||
//~^^ NOTE expected one of the `crate_local`, `direct` or `from_desugaring` flags, not `something` | ||
trait InvalidFlag {} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.