-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking Issue for invalid_doc_attributes
lint
#82730
Comments
I think the most important thing is to at least prevent non-functioning code to go unnoticed. So at least having warnings seems good enough. Then we can always discuss if we want to make it into a hard error or not when a new edition comes up. |
Yep! I think using the future incompat architecture for this is great, because we can declare as early as possible that we're hoping to make this a hard error. And then as things settle, someone can eventually have the proper discussion about how best to actually remove it. |
It looks like this was implemented in #82708? Should we repurpose this as a tracking issue since it is linked to from the lint? |
I believe that creates the lint but does not make it lint on all cases. That was written in the interest of fixing a nightly regression, so doesn't address the issue in this thread. |
That lint is used for the rust/compiler/rustc_passes/src/check_attr.rs Lines 588 to 599 in e7e1dc1
and is thus future-incompat. |
This fixes a build failure under Windows. It seems the two options will only work at the crate level in the future so the compiler warns about them now, and will fail build later. In CI, warnings seem to fail the build already. rust-lang/rust#82730 https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level
166: Fix unknown rustdoc attribute + replace test certificate r=jethrogb a=raoulstrackx This PR: - fixes an issue where `doc(inline)` annotations are only allowed on 'use' items. Two occurrences are removed [https://github.com/rust-lang/rust/issues/82730](#82730) - updates a leaf certificate that is used for testing but has been expired. It is replaced with a new one. - silences a compiler warning where a field of a struct is written to, but never read - updates the Travis CI to use ubuntu20 - bumps the version of mbedtls Co-authored-by: Raoul Strackx <[email protected]>
Got: warning: this attribute can only be applied to a `use` item --> src/api/filesystem/mod.rs:25:7 | 25 | #[doc(inline)] | ^^^^^^ only applicable on `use` items 26 | mod async_io; | ------------- not a `use` item | = note: `#[warn(invalid_doc_attributes)]` on by default = 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 <rust-lang/rust#82730> = note: read https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#docno_inlinedocinline for more information This commit would fix this problem. Signed-off-by: Tim Zhang <[email protected]>
Got: warning: this attribute can only be applied to a `use` item --> src/api/filesystem/mod.rs:25:7 | 25 | #[doc(inline)] | ^^^^^^ only applicable on `use` items 26 | mod async_io; | ------------- not a `use` item | = note: `#[warn(invalid_doc_attributes)]` on by default = 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 <rust-lang/rust#82730> = note: read https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#docno_inlinedocinline for more information This commit would fix this problem. Signed-off-by: Tim Zhang <[email protected]>
=== stdout === === stderr === warning: `doc(primitive)` should never have been stable --> out.rs:6:7 | 6 | #[doc(primitive = "usize")] | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(invalid_doc_attributes)]` on by default = 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 <rust-lang/rust#82730> warning: 1 warning emitted ==============
This issue is still linked today from the compiler warning you get for invalid doc attributes like |
Hmm... I'm guessing nowhere? Good catch, I'll reopen (and rename) this issue for now. |
invalid_doc_attributes
lint
=== stdout === === stderr === /home/runner/work/glacier/glacier/ices/102363.sh: line 3: usize: command not found warning: unknown `doc` attribute `primitive` --> out.rs:4:7 | 4 | #[doc(primitive = "usize")] | ^^^^^^^^^^^^^^^^^^^ | = 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 <rust-lang/rust#82730> = note: `#[warn(invalid_doc_attributes)]` on by default warning: 1 warning emitted ==============
This commit makes `use std:convert::TryInto` conditional via `#[cfg(debug_assertions)]`. This avoids the following build error: ``` $ cargo bench ... error: unused import: `std::convert::TryInto` --> src/cast.rs:1:5 | 1 | use std::convert::TryInto; | ^^^^^^^^^^^^^^^^^^^^^ ``` This commit also opts into the `test` feature (only if the "bench" feature is requested, because benchmarking is only available in the nightly version of the compiler) and declares the `extern crate test` dependency on the compiler-provided `test` crate. This avoids the following build errors: ``` $ cargo bench ... error[E0433]: failed to resolve: use of undeclared crate or module `test` --> src/optimize.rs:710:33 | 710 | fn bench_optimize(bencher: &mut test::Bencher) { | ^^^^ use of undeclared crate or module `test` ``` ``` $ cargo bench ... error[E0658]: use of unstable library feature 'test' --> src/optimize.rs:710:33 | 710 | fn bench_optimize(bencher: &mut test::Bencher) { | ^^^^^^^^^^^^^ | = note: see issue #50297 <rust-lang/rust#50297> for more information = help: add `#![feature(test)]` to the crate attributes to enable ``` This commit also makes small tweaks to how `README.md` is included. It seems that this doesn't actually test the examples in the `README.md` file (this commit adds a TODO for this observation), but it does avoid the following build error: ``` $ cargo bench --features=bench ... error: unknown `doc` attribute `include` --> src/lib.rs:14:36 | 14 | #![cfg_attr(feature = "bench", doc(include = "../README.md"))] | ----^^^^^^^^^^^^^^^^^^^^^^^^- help: | use `doc = include_str!` instead: | `#![doc = include_str!("../README.md")]` | = 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 <rust-lang/rust#82730> ``` Finally, this commit declares the "bench" feature in `Cargo.toml`. After these changes the following command line succeeds: ``` $ cargo bench --features=bench ... test bits::bench_find_min_version ... bench: 1 ns/iter (+/- 0) test bits::bench_push_splitted_bytes ... bench: 3,862 ns/iter (+/- 58) test optimize::bench_optimize ... bench: 19 ns/iter (+/- 0) ```
This commit makes `use std:convert::TryInto` conditional via `#[cfg(debug_assertions)]`. This avoids the following build error: ``` $ cargo bench ... error: unused import: `std::convert::TryInto` --> src/cast.rs:1:5 | 1 | use std::convert::TryInto; | ^^^^^^^^^^^^^^^^^^^^^ ``` This commit also opts into the `test` feature (only if the "bench" feature is requested, because benchmarking is only available in the nightly version of the compiler) and declares the `extern crate test` dependency on the compiler-provided `test` crate. This avoids the following build errors: ``` $ cargo bench ... error[E0433]: failed to resolve: use of undeclared crate or module `test` --> src/optimize.rs:710:33 | 710 | fn bench_optimize(bencher: &mut test::Bencher) { | ^^^^ use of undeclared crate or module `test` ``` ``` $ cargo bench ... error[E0658]: use of unstable library feature 'test' --> src/optimize.rs:710:33 | 710 | fn bench_optimize(bencher: &mut test::Bencher) { | ^^^^^^^^^^^^^ | = note: see issue #50297 <rust-lang/rust#50297> for more information = help: add `#![feature(test)]` to the crate attributes to enable ``` This commit also makes small tweaks to how `README.md` is included. It seems that this doesn't actually test the examples in the `README.md` file (this commit adds a TODO for this observation), but it does avoid the following build error: ``` $ cargo bench --features=bench ... error: unknown `doc` attribute `include` --> src/lib.rs:14:36 | 14 | #![cfg_attr(feature = "bench", doc(include = "../README.md"))] | ----^^^^^^^^^^^^^^^^^^^^^^^^- help: | use `doc = include_str!` instead: | `#![doc = include_str!("../README.md")]` | = 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 <rust-lang/rust#82730> ``` Finally, this commit declares the "bench" feature in `Cargo.toml`. After these changes the following command line succeeds: ``` $ cargo bench --features=bench ... test bits::bench_find_min_version ... bench: 1 ns/iter (+/- 0) test bits::bench_push_splitted_bytes ... bench: 3,862 ns/iter (+/- 58) test optimize::bench_optimize ... bench: 19 ns/iter (+/- 0) ```
This commit makes `use std:convert::TryInto` conditional via `#[cfg(debug_assertions)]`. This avoids the following build error: ``` $ cargo bench ... error: unused import: `std::convert::TryInto` --> src/cast.rs:1:5 | 1 | use std::convert::TryInto; | ^^^^^^^^^^^^^^^^^^^^^ ``` This commit also opts into the `test` feature (only if the "bench" feature is requested, because benchmarking is only available in the nightly version of the compiler) and declares the `extern crate test` dependency on the compiler-provided `test` crate. This avoids the following build errors: ``` $ cargo bench ... error[E0433]: failed to resolve: use of undeclared crate or module `test` --> src/optimize.rs:710:33 | 710 | fn bench_optimize(bencher: &mut test::Bencher) { | ^^^^ use of undeclared crate or module `test` ``` ``` $ cargo bench ... error[E0658]: use of unstable library feature 'test' --> src/optimize.rs:710:33 | 710 | fn bench_optimize(bencher: &mut test::Bencher) { | ^^^^^^^^^^^^^ | = note: see issue #50297 <rust-lang/rust#50297> for more information = help: add `#![feature(test)]` to the crate attributes to enable ``` This commit also makes small tweaks to how `README.md` is included. It seems that this doesn't actually test the examples in the `README.md` file (this commit adds a TODO for this observation), but it does avoid the following build error: ``` $ cargo bench --features=bench ... error: unknown `doc` attribute `include` --> src/lib.rs:14:36 | 14 | #![cfg_attr(feature = "bench", doc(include = "../README.md"))] | ----^^^^^^^^^^^^^^^^^^^^^^^^- help: | use `doc = include_str!` instead: | `#![doc = include_str!("../README.md")]` | = 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 <rust-lang/rust#82730> ``` Finally, this commit declares the "bench" feature in `Cargo.toml`. After these changes the following command line succeeds: ``` $ cargo bench --features=bench ... test bits::bench_find_min_version ... bench: 1 ns/iter (+/- 0) test bits::bench_push_splitted_bytes ... bench: 3,862 ns/iter (+/- 58) test optimize::bench_optimize ... bench: 19 ns/iter (+/- 0) ```
This commit makes `use std:convert::TryInto` conditional via `#[cfg(debug_assertions)]`. This avoids the following build error: ``` $ cargo bench ... error: unused import: `std::convert::TryInto` --> src/cast.rs:1:5 | 1 | use std::convert::TryInto; | ^^^^^^^^^^^^^^^^^^^^^ ``` This commit also opts into the `test` feature (only if the "bench" feature is requested, because benchmarking is only available in the nightly version of the compiler) and declares the `extern crate test` dependency on the compiler-provided `test` crate. This avoids the following build errors: ``` $ cargo bench ... error[E0433]: failed to resolve: use of undeclared crate or module `test` --> src/optimize.rs:710:33 | 710 | fn bench_optimize(bencher: &mut test::Bencher) { | ^^^^ use of undeclared crate or module `test` ``` ``` $ cargo bench ... error[E0658]: use of unstable library feature 'test' --> src/optimize.rs:710:33 | 710 | fn bench_optimize(bencher: &mut test::Bencher) { | ^^^^^^^^^^^^^ | = note: see issue #50297 <rust-lang/rust#50297> for more information = help: add `#![feature(test)]` to the crate attributes to enable ``` This commit also makes small tweaks to how `README.md` is included. It seems that this doesn't actually test the examples in the `README.md` file (this commit adds a TODO for this observation), but it does avoid the following build error: ``` $ cargo bench --features=bench ... error: unknown `doc` attribute `include` --> src/lib.rs:14:36 | 14 | #![cfg_attr(feature = "bench", doc(include = "../README.md"))] | ----^^^^^^^^^^^^^^^^^^^^^^^^- help: | use `doc = include_str!` instead: | `#![doc = include_str!("../README.md")]` | = 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 <rust-lang/rust#82730> ``` Finally, this commit declares the "bench" feature in `Cargo.toml`. After these changes the following command line succeeds: ``` $ cargo bench --features=bench ... test bits::bench_find_min_version ... bench: 1 ns/iter (+/- 0) test bits::bench_push_splitted_bytes ... bench: 3,862 ns/iter (+/- 58) test optimize::bench_optimize ... bench: 19 ns/iter (+/- 0) ```
=== stdout === === stderr === error[E0601]: `main` function not found in crate `109066` --> /home/runner/work/glacier/glacier/ices/109066.rs:1:18 | 1 | #![doc(test(""))] | ^ consider adding a `main` function to `/home/runner/work/glacier/glacier/ices/109066.rs` warning: `#![doc(test(...)]` does not take a literal --> /home/runner/work/glacier/glacier/ices/109066.rs:1:13 | 1 | #![doc(test(""))] | ^^ | = 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 <rust-lang/rust#82730> = note: `#[warn(invalid_doc_attributes)]` on by default error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0601`. ==============
Got: warning: this attribute can only be applied to a `use` item --> src/api/filesystem/mod.rs:25:7 | 25 | #[doc(inline)] | ^^^^^^ only applicable on `use` items 26 | mod async_io; | ------------- not a `use` item | = note: `#[warn(invalid_doc_attributes)]` on by default = 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 <rust-lang/rust#82730> = note: read https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#docno_inlinedocinline for more information This commit would fix this problem. Signed-off-by: Tim Zhang <[email protected]>
Rollup merge of rust-lang#111505 - GuillaumeGomez:turn-invalid-doc-attr-into-err, r=rustdoc Made `INVALID_DOC_ATTRIBUTES` lint deny by default Fixes rust-lang#82730. # Explanations The `INVALID_DOC_ATTRIBUTES` lint was marked as "will become a hard error into the future" for quite some time so making it `deny` by default. <del>Waiting on rust-lang/backtrace-rs#524 for now.</del>
Got: warning: this attribute can only be applied to a `use` item --> src/api/filesystem/mod.rs:25:7 | 25 | #[doc(inline)] | ^^^^^^ only applicable on `use` items 26 | mod async_io; | ------------- not a `use` item | = note: `#[warn(invalid_doc_attributes)]` on by default = 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 <rust-lang/rust#82730> = note: read https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#docno_inlinedocinline for more information This commit would fix this problem. Signed-off-by: Tim Zhang <[email protected]>
What is this lint about
The
invalid_doc_attributes
lint detects incorrect uses of#[doc(...)]
attributes or uses of non-existent#[doc(...)]
attributes. For example,#[doc(alias = 42)]
will trigger this lint, since42
is not a string. Also,#[doc(foobar)]
will trigger this lint.If you are here because of a warning about
doc(primitive)
, see #88070 instead.Original issue
From #82702: Currently the warning reuses the existing
unknown_attributes
lint, but to properly do future incompatibility we need to use the special infrastructure that exists for it.We should also consider sticking this into the edition (see #80165), though I'm not sure if it can be automatically upgraded. This might be one of the cases where it doesn't matter.
The text was updated successfully, but these errors were encountered: