-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Find more invalid doc attributes #83098
Conversation
This change makes it easier to follow the control flow. I also moved the end-of-line comments attached to some symbols to before the symbol listing. This allows rustfmt to format the code; otherwise no formatting occurs (see rust-lang/rustfmt#4750).
E.g., `#[doc(123)]`.
r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> | ||
|
||
error: unknown `doc` attribute `` |
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.
How do I display the Path
? There doesn't seem to be a Display impl.
Note that this is not a regression; this test is just exposing the previous behavior.
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.
Instead of name_or_empty
, could use name_value_literal_span
and then get the snippet for that Span
? Or is path_to_string
accessible here?
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.
I don't think rustc_ast_pretty
is accessible here, though I could add it as a dependency. I'm trying out the span_to_snippet
approach now.
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.
Both span_to_snippet
and path_to_string
worked. I'm leaning towards path_to_string
because I think it will handle foo :: bar:: baz
gracefully as foo::bar::baz
, but which one would you prefer I use? You can see what the code looks like with span_to_snippet
vs path_to_string
here: 8f40e11
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.
I'd normally want to lean against introducing more dependencies between our crates, but depending on rust_ast_pretty
when we already depend on rust_ast
is probably fine. Let's stick with path_to_string
.
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 looks like rustc_passes
already depends transitively on rustc_ast_pretty
anyway.
6b760c8
to
fe64970
Compare
This comment has been minimized.
This comment has been minimized.
"crate level attribute" -> "crate-level attribute"
a6edc85
to
5134047
Compare
It seems there are two copies of it: one in `src/test/ui/attributes/` and one in `src/test/rustdoc-ui/`. I'm guessing this is to test that the lint is emitted both when you run the compiler and when you run rustdoc.
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.
Two minor nits in existing comments, otherwise LGTM.
- Tweak lint message - Display multi-segment paths correctly
@bors r+ |
📌 Commit 8f40e11 has been approved by |
…dtwco Find more invalid doc attributes - Lint on `#[doc(123)]`, `#[doc("hello")]`, etc. - Lint every attribute; e.g., will now report two warnings for `#[doc(foo, bar)]` - Add hyphen to "crate level" - Display paths like `#[doc(foo::bar)]` correctly instead of as an empty string
…dtwco Find more invalid doc attributes - Lint on `#[doc(123)]`, `#[doc("hello")]`, etc. - Lint every attribute; e.g., will now report two warnings for `#[doc(foo, bar)]` - Add hyphen to "crate level" - Display paths like `#[doc(foo::bar)]` correctly instead of as an empty string
…dtwco Find more invalid doc attributes - Lint on `#[doc(123)]`, `#[doc("hello")]`, etc. - Lint every attribute; e.g., will now report two warnings for `#[doc(foo, bar)]` - Add hyphen to "crate level" - Display paths like `#[doc(foo::bar)]` correctly instead of as an empty string
Rollup of 10 pull requests Successful merges: - rust-lang#82989 (Custom error on literal names from other languages) - rust-lang#83054 (Validate rustc_layout_scalar_valid_range_{start,end} attributes) - rust-lang#83098 (Find more invalid doc attributes) - rust-lang#83108 (Remove unused `opt_local_def_id_to_hir_id` function) - rust-lang#83110 (Fix typos in `library/core/src/ptr/mod.rs` and `library/std/src/sys_common/thread_local_dtor.rs`) - rust-lang#83113 (Minor refactoring in try_index_step) - rust-lang#83127 (Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`) - rust-lang#83132 (Don't encode file information for span with a dummy location) - rust-lang#83141 (:arrow_up: rust-analyzer) - rust-lang#83144 (Introduce `rustc_interface::interface::Config::parse_sess_created` callback) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
#[doc(123)]
,#[doc("hello")]
, etc.#[doc(foo, bar)]
#[doc(foo::bar)]
correctly instead of as an empty string