-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Replace check_attr_crate_level with check_target for #[doc] #161521
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
9d0b363
6a28006
7a056e3
fc4c9ef
281ea9e
4899f5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #![feature(rustdoc_internals)] | ||
|
|
||
| #[doc(rust_logo)] | ||
| //~^ ERROR crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| #[doc(html_favicon_url = "example.org")] | ||
| //~^ ERROR crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| #[doc(html_logo_url = "example.org")] | ||
| //~^ ERROR crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| #[doc(html_playground_url = "example.org")] | ||
| //~^ ERROR crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| #[doc(issue_tracker_base_url = "example.org")] | ||
| //~^ ERROR crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| #[doc(html_root_url = "example.org")] | ||
| //~^ ERROR crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| #[doc(html_no_source)] | ||
| //~^ ERROR crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| #[doc(test(no_crate_inject))] | ||
| //~^ ERROR crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| fn function() {} | ||
|
|
||
| fn main() {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| --> $DIR/doc-crate-level.rs:3:1 | ||
| | | ||
| LL | #[doc(rust_logo)] | ||
| | ^^^^^^^^^^^^^^^^^ | ||
| | | ||
| note: this attribute does not have an `!`, which means it is applied to this function | ||
| --> $DIR/doc-crate-level.rs:19:1 | ||
| | | ||
| LL | fn function() {} | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| --> $DIR/doc-crate-level.rs:5:1 | ||
| | | ||
| LL | #[doc(html_favicon_url = "example.org")] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| note: this attribute does not have an `!`, which means it is applied to this function | ||
| --> $DIR/doc-crate-level.rs:19:1 | ||
| | | ||
| LL | fn function() {} | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| --> $DIR/doc-crate-level.rs:7:1 | ||
| | | ||
| LL | #[doc(html_logo_url = "example.org")] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| note: this attribute does not have an `!`, which means it is applied to this function | ||
| --> $DIR/doc-crate-level.rs:19:1 | ||
| | | ||
| LL | fn function() {} | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| --> $DIR/doc-crate-level.rs:9:1 | ||
| | | ||
| LL | #[doc(html_playground_url = "example.org")] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| note: this attribute does not have an `!`, which means it is applied to this function | ||
| --> $DIR/doc-crate-level.rs:19:1 | ||
| | | ||
| LL | fn function() {} | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| --> $DIR/doc-crate-level.rs:11:1 | ||
| | | ||
| LL | #[doc(issue_tracker_base_url = "example.org")] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| note: this attribute does not have an `!`, which means it is applied to this function | ||
| --> $DIR/doc-crate-level.rs:19:1 | ||
| | | ||
| LL | fn function() {} | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| --> $DIR/doc-crate-level.rs:13:1 | ||
| | | ||
| LL | #[doc(html_root_url = "example.org")] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| note: this attribute does not have an `!`, which means it is applied to this function | ||
| --> $DIR/doc-crate-level.rs:19:1 | ||
| | | ||
| LL | fn function() {} | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| --> $DIR/doc-crate-level.rs:15:1 | ||
| | | ||
| LL | #[doc(html_no_source)] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| note: this attribute does not have an `!`, which means it is applied to this function | ||
| --> $DIR/doc-crate-level.rs:19:1 | ||
| | | ||
| LL | fn function() {} | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![doc]` | ||
| --> $DIR/doc-crate-level.rs:17:1 | ||
| | | ||
| LL | #[doc(test(no_crate_inject))] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| note: this attribute does not have an `!`, which means it is applied to this function | ||
| --> $DIR/doc-crate-level.rs:19:1 | ||
| | | ||
| LL | fn function() {} | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 8 previous errors | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,4 @@ | |
| //~^ ERROR this subset of the `doc` attribute is meant for internal use only | ||
| //! This is not an official rust crate | ||
|
|
||
| #[doc(rust_logo)] | ||
| //~^ WARN this attribute can only be applied at the crate level | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason you removed this from the test?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With my new test this specific case was duplicated, I figured it fit better with the new one, so I removed it here. I left the specific test for non-feature gated |
||
| fn main() {} | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
If you use
AllowListWarnRestinstead ofAllowListit will warn instead of erroring.Then to generate the right lint
INVALID_DOC_ATTRIBUTESinstead of the defaultUNUSED_ATTRIBUTESwe should add a special case hererust/compiler/rustc_attr_parsing/src/target_checking.rs
Line 173 in ff619e2
View changes since the review
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.
It seems in this case we don't get there, because we run
AttributeParser::check_crate_leveland then return. I've added a special case in that function instead.