Skip to content
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

Closed
Manishearth opened this issue Mar 3, 2021 · 7 comments · Fixed by #111505
Closed

Tracking Issue for invalid_doc_attributes lint #82730

Manishearth opened this issue Mar 3, 2021 · 7 comments · Fixed by #111505
Labels
C-future-incompatibility Category: Future-incompatibility lints T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Manishearth
Copy link
Member

Manishearth commented Mar 3, 2021

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, since 42 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.

@Manishearth Manishearth added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-future-incompatibility Category: Future-incompatibility lints labels Mar 3, 2021
@GuillaumeGomez
Copy link
Member

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.

@Manishearth
Copy link
Member Author

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.

@camelid
Copy link
Member

camelid commented Mar 11, 2021

It looks like this was implemented in #82708? Should we repurpose this as a tracking issue since it is linked to from the lint?

@Manishearth
Copy link
Member Author

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.

@camelid
Copy link
Member

camelid commented Mar 13, 2021

I believe that creates the lint but does not make it lint on all cases.

That lint is used for the unknown `doc` attribute warning:

self.tcx.struct_span_lint_hir(
INVALID_DOC_ATTRIBUTES,
hir_id,
i_meta.span,
|lint| {
lint.build(&format!(
"unknown `doc` attribute `{}`",
i_meta.name_or_empty()
))
.emit();
},
);

and is thus future-incompat.

zugzwang pushed a commit to fortanix/sq-dsm that referenced this issue Sep 16, 2021
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
bors bot referenced this issue in fortanix/rust-mbedtls Oct 18, 2021
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]>
bergwolf pushed a commit to bergwolf/fuse-backend-rs that referenced this issue Nov 25, 2021
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]>
jiangliu pushed a commit to cloud-hypervisor/fuse-backend-rs that referenced this issue Nov 25, 2021
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]>
github-actions bot pushed a commit to rust-lang/glacier that referenced this issue Jun 19, 2022
=== 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

==============
@jonas-schievink
Copy link
Contributor

This issue is still linked today from the compiler warning you get for invalid doc attributes like #[doc(bla)]. Since this is a future-incompat lint, where is turning this into a hard error actually tracked?

@camelid
Copy link
Member

camelid commented Jun 22, 2022

Hmm... I'm guessing nowhere? Good catch, I'll reopen (and rename) this issue for now.

@camelid camelid reopened this Jun 22, 2022
@camelid camelid changed the title Future incompatibility lint for unknown rustdoc attributes Tracking Issue for invalid_doc_attributes lint Jun 22, 2022
github-actions bot pushed a commit to rust-lang/glacier that referenced this issue Apr 1, 2023
=== 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

==============
anforowicz added a commit to anforowicz/qr_code that referenced this issue Apr 20, 2023
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)
    ```
anforowicz added a commit to anforowicz/qr_code that referenced this issue Apr 27, 2023
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)
    ```
anforowicz added a commit to anforowicz/qr_code that referenced this issue Apr 27, 2023
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)
    ```
anforowicz added a commit to anforowicz/qr_code that referenced this issue Apr 27, 2023
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)
    ```
github-actions bot pushed a commit to rust-lang/glacier that referenced this issue Jun 7, 2023
=== 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`.
==============
ZizhengBian pushed a commit to ZizhengBian/fuse-backend-rs that referenced this issue Oct 19, 2023
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]>
@bors bors closed this as completed in 8185c84 Mar 2, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 2, 2024
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>
blair61t added a commit to blair61t/rust-backend that referenced this issue Dec 2, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-future-incompatibility Category: Future-incompatibility lints T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants