-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Expand checks for register_tool #160145
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
Merged
Expand checks for register_tool #160145
Changes from all commits
Commits
Show all changes
3 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #![feature(register_tool)] | ||
| #![register_tool(foo)] |
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //@ check-pass | ||
| //@ compile-flags: -Z crate-attr=feature(register_tool) -Z crate-attr=register_tool(foo) | ||
| //@ compile-flags: -Z crate-attr=register_attribute_tool(bar) -Z crate-attr=register_lint_tool(baz) | ||
| //@ compile-flags: -A duplicate_features -A duplicate_tools | ||
| #![feature(register_tool)] | ||
| #![register_tool(foo)] | ||
| #![register_attribute_tool(bar)] | ||
| #![register_lint_tool(baz)] | ||
|
|
||
| #[foo::foo] | ||
| #[bar::bar] | ||
| #[allow(foo::baz, baz::baz)] | ||
| fn main() {} |
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| //@ aux-build: use_tool.rs | ||
|
|
||
| // `use_tool` references tool "foo", and we want to check that it has no impact on this crate. | ||
| extern crate use_tool; | ||
|
|
||
| #[foo::bar] //~ ERROR cannot find module or crate `foo` in this scope | ||
| #[allow(foo::baz)] //~ ERROR unknown tool name `foo` | ||
| //~| ERROR unknown tool name `foo` | ||
| //~| ERROR unknown tool name `foo` | ||
| fn main() {} |
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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| error[E0710]: unknown tool name `foo` found in scoped lint: `foo::baz` | ||
| --> $DIR/cross-crate.rs:7:9 | ||
| | | ||
| LL | #[allow(foo::baz)] | ||
| | ^^^ | ||
| | | ||
| = help: add `#![register_tool(foo)]` to the crate root | ||
|
|
||
| error[E0433]: cannot find module or crate `foo` in this scope | ||
| --> $DIR/cross-crate.rs:6:3 | ||
| | | ||
| LL | #[foo::bar] | ||
| | ^^^ use of unresolved module or unlinked crate `foo` | ||
|
|
||
| error[E0710]: unknown tool name `foo` found in scoped lint: `foo::baz` | ||
| --> $DIR/cross-crate.rs:7:9 | ||
| | | ||
| LL | #[allow(foo::baz)] | ||
| | ^^^ | ||
| | | ||
| = help: add `#![register_tool(foo)]` to the crate root | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error[E0710]: unknown tool name `foo` found in scoped lint: `foo::baz` | ||
| --> $DIR/cross-crate.rs:7:9 | ||
| | | ||
| LL | #[allow(foo::baz)] | ||
| | ^^^ | ||
| | | ||
| = help: add `#![register_tool(foo)]` to the crate root | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: aborting due to 4 previous errors | ||
|
|
||
| Some errors have detailed explanations: E0433, E0710. | ||
| For more information about an error, try `rustc --explain E0433`. |
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,15 +1,16 @@ | ||
| //@ check-pass | ||
| #![feature(register_tool)] | ||
| #![warn(duplicate_tools)] | ||
| // Register a tool multiple times is okay. | ||
| #![register_tool(foo)] | ||
| #![register_tool(foo)] | ||
| #![register_tool(foo)] //~ WARN [duplicate_tools] | ||
| #![register_tool(bar)] | ||
| #![register_attribute_tool(bar)] | ||
| #![register_attribute_tool(bar)] //~ WARN [duplicate_tools] | ||
| #![register_tool(baz)] | ||
| #![register_lint_tool(baz)] | ||
| #![register_attribute_tool(qux)] | ||
| #![register_lint_tool(baz)] //~ WARN [duplicate_tools] | ||
| #![register_attribute_tool(qux)] | ||
| #![register_attribute_tool(qux)] //~ WARN [duplicate_tools] | ||
| #![register_lint_tool(quux)] | ||
| #![register_lint_tool(quux)] | ||
| #![register_lint_tool(quux)] //~ WARN [duplicate_tools] | ||
|
|
||
| fn main() {} |
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| warning: duplicate tool `foo` registered | ||
| --> $DIR/duplicate-tool.rs:6:18 | ||
| | | ||
| LL | #![register_tool(foo)] | ||
| | --- already registered here | ||
| LL | #![register_tool(foo)] | ||
| | ^^^ | ||
| | | ||
| note: the lint level is defined here | ||
| --> $DIR/duplicate-tool.rs:3:9 | ||
| | | ||
| LL | #![warn(duplicate_tools)] | ||
| | ^^^^^^^^^^^^^^^ | ||
|
|
||
| warning: duplicate tool `bar` registered | ||
| --> $DIR/duplicate-tool.rs:8:28 | ||
| | | ||
| LL | #![register_tool(bar)] | ||
| | --- already registered here | ||
| LL | #![register_attribute_tool(bar)] | ||
| | ^^^ | ||
|
|
||
| warning: duplicate tool `baz` registered | ||
| --> $DIR/duplicate-tool.rs:10:23 | ||
| | | ||
| LL | #![register_tool(baz)] | ||
| | --- already registered here | ||
| LL | #![register_lint_tool(baz)] | ||
| | ^^^ | ||
|
|
||
| warning: duplicate tool `qux` registered | ||
| --> $DIR/duplicate-tool.rs:12:28 | ||
| | | ||
| LL | #![register_attribute_tool(qux)] | ||
| | --- already registered here | ||
| LL | #![register_attribute_tool(qux)] | ||
| | ^^^ | ||
|
|
||
| warning: duplicate tool `quux` registered | ||
| --> $DIR/duplicate-tool.rs:14:23 | ||
| | | ||
| LL | #![register_lint_tool(quux)] | ||
| | ---- already registered here | ||
| LL | #![register_lint_tool(quux)] | ||
| | ^^^^ | ||
|
|
||
| warning: 5 warnings emitted | ||
|
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add such a test using
-Zcrate-attr=register_tool(..) -Zallow(duplicate_tools)(whatever the precise syntax is) with a crate level attribute introducing the same tool?