Fix warning messages

This commit is contained in:
Guillaume Gomez 2025-12-03 15:55:57 +01:00
parent 976d45452a
commit 9c8c67bfdd
21 changed files with 377 additions and 135 deletions

View file

@ -1,11 +1,29 @@
// regression test for https://github.com/rust-lang/rust/issues/149187
#![doc(html_favicon_url)] //~ ERROR: `doc(html_favicon_url)` expects a string value [invalid_doc_attributes]
#![doc(html_logo_url)] //~ ERROR: `doc(html_logo_url)` expects a string value [invalid_doc_attributes]
#![doc(html_playground_url)] //~ ERROR: `doc(html_playground_url)` expects a string value [invalid_doc_attributes]
#![doc(issue_tracker_base_url)] //~ ERROR expects a string value
#![doc(html_favicon_url = 1)] //~ ERROR expects a string value
#![doc(html_logo_url = 2)] //~ ERROR expects a string value
#![doc(html_playground_url = 3)] //~ ERROR expects a string value
#![doc(issue_tracker_base_url = 4)] //~ ERROR expects a string value
#![doc(html_no_source = "asdf")] //~ ERROR `doc(html_no_source)` does not accept a value [invalid_doc_attributes]
#![doc(html_favicon_url)]
//~^ ERROR: malformed `doc` attribute
//~| NOTE expected this to be of the form `html_favicon_url = "..."`
#![doc(html_logo_url)]
//~^ ERROR: malformed `doc` attribute
//~| NOTE expected this to be of the form `html_logo_url = "..."`
#![doc(html_playground_url)]
//~^ ERROR: malformed `doc` attribute
//~| NOTE expected this to be of the form `html_playground_url = "..."`
#![doc(issue_tracker_base_url)]
//~^ ERROR: malformed `doc` attribute
//~| NOTE expected this to be of the form `issue_tracker_base_url = "..."`
#![doc(html_favicon_url = 1)]
//~^ ERROR malformed `doc` attribute
//~| NOTE expected a string literal
#![doc(html_logo_url = 2)]
//~^ ERROR malformed `doc` attribute
//~| NOTE expected a string literal
#![doc(html_playground_url = 3)]
//~^ ERROR malformed `doc` attribute
//~| NOTE expected a string literal
#![doc(issue_tracker_base_url = 4)]
//~^ ERROR malformed `doc` attribute
//~| NOTE expected a string literal
#![doc(html_no_source = "asdf")]
//~^ ERROR malformed `doc` attribute
//~| NOTE didn't expect any arguments here

View file

@ -1,58 +1,211 @@
error: `doc(html_favicon_url)` expects a string value
--> $DIR/bad-render-options.rs:3:8
error[E0539]: malformed `doc` attribute input
--> $DIR/bad-render-options.rs:3:1
|
LL | #![doc(html_favicon_url)]
| ^^^^^^^^^^^^^^^^
| ^^^^^^^----------------^^
| |
| expected this to be of the form `html_favicon_url = "..."`
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #![doc(html_favicon_url)]
LL + #![doc = "string"]
|
LL - #![doc(html_favicon_url)]
LL + #![doc(hidden)]
|
LL - #![doc(html_favicon_url)]
LL + #![doc(inline)]
|
LL - #![doc(html_favicon_url)]
LL + #![doc(test)]
|
= note: `#[deny(invalid_doc_attributes)]` on by default
error: `doc(html_logo_url)` expects a string value
--> $DIR/bad-render-options.rs:4:8
error[E0539]: malformed `doc` attribute input
--> $DIR/bad-render-options.rs:6:1
|
LL | #![doc(html_logo_url)]
| ^^^^^^^^^^^^^
| ^^^^^^^-------------^^
| |
| expected this to be of the form `html_logo_url = "..."`
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #![doc(html_logo_url)]
LL + #![doc = "string"]
|
LL - #![doc(html_logo_url)]
LL + #![doc(hidden)]
|
LL - #![doc(html_logo_url)]
LL + #![doc(inline)]
|
LL - #![doc(html_logo_url)]
LL + #![doc(test)]
|
error: `doc(html_playground_url)` expects a string value
--> $DIR/bad-render-options.rs:5:8
error[E0539]: malformed `doc` attribute input
--> $DIR/bad-render-options.rs:9:1
|
LL | #![doc(html_playground_url)]
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^-------------------^^
| |
| expected this to be of the form `html_playground_url = "..."`
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #![doc(html_playground_url)]
LL + #![doc = "string"]
|
LL - #![doc(html_playground_url)]
LL + #![doc(hidden)]
|
LL - #![doc(html_playground_url)]
LL + #![doc(inline)]
|
LL - #![doc(html_playground_url)]
LL + #![doc(test)]
|
error: `doc(issue_tracker_base_url)` expects a string value
--> $DIR/bad-render-options.rs:6:8
error[E0539]: malformed `doc` attribute input
--> $DIR/bad-render-options.rs:12:1
|
LL | #![doc(issue_tracker_base_url)]
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^----------------------^^
| |
| expected this to be of the form `issue_tracker_base_url = "..."`
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #![doc(issue_tracker_base_url)]
LL + #![doc = "string"]
|
LL - #![doc(issue_tracker_base_url)]
LL + #![doc(hidden)]
|
LL - #![doc(issue_tracker_base_url)]
LL + #![doc(inline)]
|
LL - #![doc(issue_tracker_base_url)]
LL + #![doc(test)]
|
error: `doc(html_favicon_url)` expects a string value
--> $DIR/bad-render-options.rs:7:8
error[E0539]: malformed `doc` attribute input
--> $DIR/bad-render-options.rs:15:1
|
LL | #![doc(html_favicon_url = 1)]
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^-^^
| |
| expected a string literal here
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #![doc(html_favicon_url = 1)]
LL + #![doc = "string"]
|
LL - #![doc(html_favicon_url = 1)]
LL + #![doc(hidden)]
|
LL - #![doc(html_favicon_url = 1)]
LL + #![doc(inline)]
|
LL - #![doc(html_favicon_url = 1)]
LL + #![doc(test)]
|
error: `doc(html_logo_url)` expects a string value
--> $DIR/bad-render-options.rs:8:8
error[E0539]: malformed `doc` attribute input
--> $DIR/bad-render-options.rs:18:1
|
LL | #![doc(html_logo_url = 2)]
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^-^^
| |
| expected a string literal here
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #![doc(html_logo_url = 2)]
LL + #![doc = "string"]
|
LL - #![doc(html_logo_url = 2)]
LL + #![doc(hidden)]
|
LL - #![doc(html_logo_url = 2)]
LL + #![doc(inline)]
|
LL - #![doc(html_logo_url = 2)]
LL + #![doc(test)]
|
error: `doc(html_playground_url)` expects a string value
--> $DIR/bad-render-options.rs:9:8
error[E0539]: malformed `doc` attribute input
--> $DIR/bad-render-options.rs:21:1
|
LL | #![doc(html_playground_url = 3)]
| ^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^
| |
| expected a string literal here
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #![doc(html_playground_url = 3)]
LL + #![doc = "string"]
|
LL - #![doc(html_playground_url = 3)]
LL + #![doc(hidden)]
|
LL - #![doc(html_playground_url = 3)]
LL + #![doc(inline)]
|
LL - #![doc(html_playground_url = 3)]
LL + #![doc(test)]
|
error: `doc(issue_tracker_base_url)` expects a string value
--> $DIR/bad-render-options.rs:10:8
error[E0539]: malformed `doc` attribute input
--> $DIR/bad-render-options.rs:24:1
|
LL | #![doc(issue_tracker_base_url = 4)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^
| |
| expected a string literal here
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #![doc(issue_tracker_base_url = 4)]
LL + #![doc = "string"]
|
LL - #![doc(issue_tracker_base_url = 4)]
LL + #![doc(hidden)]
|
LL - #![doc(issue_tracker_base_url = 4)]
LL + #![doc(inline)]
|
LL - #![doc(issue_tracker_base_url = 4)]
LL + #![doc(test)]
|
error: `doc(html_no_source)` does not accept a value
--> $DIR/bad-render-options.rs:11:8
error[E0565]: malformed `doc` attribute input
--> $DIR/bad-render-options.rs:27:1
|
LL | #![doc(html_no_source = "asdf")]
| ^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^--------^^
| |
| didn't expect any arguments here
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #![doc(html_no_source = "asdf")]
LL + #![doc = "string"]
|
LL - #![doc(html_no_source = "asdf")]
LL + #![doc(hidden)]
|
LL - #![doc(html_no_source = "asdf")]
LL + #![doc(inline)]
|
LL - #![doc(html_no_source = "asdf")]
LL + #![doc(test)]
|
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0539, E0565.
For more information about an error, try `rustc --explain E0539`.

View file

@ -1,14 +1,14 @@
error: same `cfg` was in `auto_cfg(hide(...))` and `auto_cfg(show(...))` on the same item
--> $DIR/cfg-hide-show-conflict.rs:3:31
--> $DIR/cfg-hide-show-conflict.rs:3:8
|
LL | #![doc(auto_cfg(show(windows, target_os = "linux")))]
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^
|
note: first change was here
--> $DIR/cfg-hide-show-conflict.rs:2:22
--> $DIR/cfg-hide-show-conflict.rs:2:8
|
LL | #![doc(auto_cfg(hide(target_os = "linux")))]
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^
error: aborting due to 1 previous error

View file

@ -1,26 +1,26 @@
error: `#[doc(alias = "...")]` isn't allowed on foreign module
--> $DIR/check-doc-alias-attr-location.rs:7:7
--> $DIR/check-doc-alias-attr-location.rs:7:15
|
LL | #[doc(alias = "foo")]
| ^^^^^^^^^^^^^
| ^^^^^
error: `#[doc(alias = "...")]` isn't allowed on implementation block
--> $DIR/check-doc-alias-attr-location.rs:10:7
--> $DIR/check-doc-alias-attr-location.rs:10:15
|
LL | #[doc(alias = "bar")]
| ^^^^^^^^^^^^^
| ^^^^^
error: `#[doc(alias = "...")]` isn't allowed on implementation block
--> $DIR/check-doc-alias-attr-location.rs:16:7
--> $DIR/check-doc-alias-attr-location.rs:16:15
|
LL | #[doc(alias = "foobar")]
| ^^^^^^^^^^^^^^^^
| ^^^^^^^^
error: `#[doc(alias = "...")]` isn't allowed on type alias in implementation block
--> $DIR/check-doc-alias-attr-location.rs:18:11
--> $DIR/check-doc-alias-attr-location.rs:18:19
|
LL | #[doc(alias = "assoc")]
| ^^^^^^^^^^^^^^^
| ^^^^^^^
error: aborting due to 4 previous errors

View file

@ -4,11 +4,28 @@ error: doc alias attribute expects a string `#[doc(alias = "a")]` or a list of s
LL | #[doc(alias)]
| ^^^^^
error: doc alias attribute expects a string `#[doc(alias = "a")]` or a list of strings `#[doc(alias("a", "b"))]`
--> $DIR/check-doc-alias-attr.rs:8:7
error[E0539]: malformed `doc` attribute input
--> $DIR/check-doc-alias-attr.rs:8:1
|
LL | #[doc(alias = 0)]
| ^^^^^^^^^
| ^^^^^^^^^^^^^^-^^
| |
| expected a string literal here
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #[doc(alias = 0)]
LL + #[doc = "string"]
|
LL - #[doc(alias = 0)]
LL + #[doc(hidden)]
|
LL - #[doc(alias = 0)]
LL + #[doc(inline)]
|
LL - #[doc(alias = 0)]
LL + #[doc(test)]
|
error: '"' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:9:15
@ -54,25 +71,42 @@ error: `#[doc(alias = "...")]` attribute cannot have empty value
LL | #[doc(alias = "")]
| ^^
error: `#[doc(alias("a"))]` expects string literals
--> $DIR/check-doc-alias-attr.rs:19:13
error[E0539]: malformed `doc` attribute input
--> $DIR/check-doc-alias-attr.rs:19:1
|
LL | #[doc(alias(0))]
| ^
| ^^^^^^^^^^^^-^^^
| |
| expected a string literal here
|
help: try changing it to one of the following valid forms of the attribute
|
LL - #[doc(alias(0))]
LL + #[doc = "string"]
|
LL - #[doc(alias(0))]
LL + #[doc(hidden)]
|
LL - #[doc(alias(0))]
LL + #[doc(inline)]
|
LL - #[doc(alias(0))]
LL + #[doc(test)]
|
error: '"' character isn't allowed in `#[doc(alias("..."))]`
error: '"' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:20:13
|
LL | #[doc(alias("\""))]
| ^^^^
error: '\n' character isn't allowed in `#[doc(alias("..."))]`
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:21:13
|
LL | #[doc(alias("\n"))]
| ^^^^
error: '\n' character isn't allowed in `#[doc(alias("..."))]`
error: '\n' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:22:13
|
LL | #[doc(alias("
@ -80,25 +114,25 @@ LL | #[doc(alias("
LL | | "))]
| |_^
error: '\t' character isn't allowed in `#[doc(alias("..."))]`
error: '\t' character isn't allowed in `#[doc(alias = "...")]`
--> $DIR/check-doc-alias-attr.rs:24:13
|
LL | #[doc(alias("\t"))]
| ^^^^
error: `#[doc(alias("..."))]` cannot start or end with ' '
error: `#[doc(alias = "...")]` cannot start or end with ' '
--> $DIR/check-doc-alias-attr.rs:25:13
|
LL | #[doc(alias(" hello"))]
| ^^^^^^^^
error: `#[doc(alias("..."))]` cannot start or end with ' '
error: `#[doc(alias = "...")]` cannot start or end with ' '
--> $DIR/check-doc-alias-attr.rs:26:13
|
LL | #[doc(alias("hello "))]
| ^^^^^^^^
error: `#[doc(alias("..."))]` attribute cannot have empty value
error: `#[doc(alias = "...")]` attribute cannot have empty value
--> $DIR/check-doc-alias-attr.rs:27:13
|
LL | #[doc(alias(""))]
@ -106,3 +140,4 @@ LL | #[doc(alias(""))]
error: aborting due to 17 previous errors
For more information about this error, try `rustc --explain E0539`.

View file

@ -1,8 +1,8 @@
error: `#[doc(alias = "...")]` isn't allowed on associated constant in trait implementation block
--> $DIR/doc-alias-assoc-const.rs:8:11
--> $DIR/doc-alias-assoc-const.rs:8:19
|
LL | #[doc(alias = "CONST_BAZ")]
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^
error: aborting due to 1 previous error

View file

@ -1,8 +1,8 @@
error: `#[doc(alias = "...")]` is the same as the item's name
--> $DIR/doc-alias-same-name.rs:3:7
error: `#[doc(alias = "Foo"]` is the same as the item's name
--> $DIR/doc-alias-same-name.rs:3:15
|
LL | #[doc(alias = "Foo")]
| ^^^^^^^^^^^^^
| ^^^^^
error: aborting due to 1 previous error

View file

@ -2,7 +2,7 @@ error: unknown `doc` attribute `include`
--> $DIR/doc-include-suggestion.rs:1:7
|
LL | #[doc(include = "external-cross-doc.md")]
| ------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-- help: use `doc = include_str!` instead: `#[doc = include_str!("external-cross-doc.md")]`
| ^^^^^^^ help: use `doc = include_str!` instead: `#[doc = include_str!("external-cross-doc.md")]`
|
= note: `#[deny(invalid_doc_attributes)]` on by default

View file

@ -1,16 +1,16 @@
error: `#![doc(auto_cfg(hide(...)))]` expects a list of items
--> $DIR/doc_cfg_hide.rs:2:8
--> $DIR/doc_cfg_hide.rs:2:17
|
LL | #![doc(auto_cfg(hide = "test"))]
| ^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^
|
= note: `#[deny(invalid_doc_attributes)]` on by default
error: `#![doc(auto_cfg(hide(...)))]` expects a list of items
--> $DIR/doc_cfg_hide.rs:3:8
--> $DIR/doc_cfg_hide.rs:3:17
|
LL | #![doc(auto_cfg(hide))]
| ^^^^^^^^^^^^^^
| ^^^^
error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/value items
--> $DIR/doc_cfg_hide.rs:4:22

View file

@ -6,8 +6,6 @@
#[doc(test(no_crate_inject))]
//~^ ERROR can only be applied at the crate level
//~| HELP to apply to the crate, use an inner attribute
//~| SUGGESTION !
#[doc(inline)]
//~^ ERROR can only be applied to a `use` item
pub fn foo() {}

View file

@ -1,18 +1,14 @@
error: this attribute can only be applied at the crate level
--> $DIR/invalid-doc-attr.rs:7:7
--> $DIR/invalid-doc-attr.rs:7:12
|
LL | #[doc(test(no_crate_inject))]
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^
|
= note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information
= note: `#[deny(invalid_doc_attributes)]` on by default
help: to apply to the crate, use an inner attribute
|
LL | #![doc(test(no_crate_inject))]
| +
error: this attribute can only be applied to a `use` item
--> $DIR/invalid-doc-attr.rs:11:7
--> $DIR/invalid-doc-attr.rs:9:7
|
LL | #[doc(inline)]
| ^^^^^^ only applicable on `use` items
@ -23,15 +19,15 @@ LL | pub fn foo() {}
= note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#inline-and-no_inline> for more information
error: this attribute can only be applied at the crate level
--> $DIR/invalid-doc-attr.rs:16:12
--> $DIR/invalid-doc-attr.rs:14:17
|
LL | #![doc(test(no_crate_inject))]
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^
|
= note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information
error: conflicting doc inlining attributes
--> $DIR/invalid-doc-attr.rs:26:7
--> $DIR/invalid-doc-attr.rs:24:7
|
LL | #[doc(inline)]
| ^^^^^^ this attribute...
@ -41,7 +37,7 @@ LL | #[doc(no_inline)]
= help: remove one of the conflicting attributes
error: this attribute can only be applied to an `extern crate` item
--> $DIR/invalid-doc-attr.rs:32:7
--> $DIR/invalid-doc-attr.rs:30:7
|
LL | #[doc(masked)]
| ^^^^^^ only applicable on `extern crate` items
@ -52,7 +48,7 @@ LL | pub struct Masked;
= note: read <https://doc.rust-lang.org/unstable-book/language-features/doc-masked.html> for more information
error: this attribute cannot be applied to an `extern crate self` item
--> $DIR/invalid-doc-attr.rs:36:7
--> $DIR/invalid-doc-attr.rs:34:7
|
LL | #[doc(masked)]
| ^^^^^^ not applicable on `extern crate self` items
@ -63,21 +59,27 @@ LL | pub extern crate self as reexport;
error: this attribute can only be applied to an `extern crate` item
--> $DIR/invalid-doc-attr.rs:4:8
|
LL | #![doc(masked)]
| ^^^^^^ only applicable on `extern crate` items
LL | / #![crate_type = "lib"]
LL | | #![feature(doc_masked)]
LL | |
LL | | #![doc(masked)]
| | ^^^^^^ only applicable on `extern crate` items
... |
LL | | pub extern crate self as reexport;
| |__________________________________- not an `extern crate` item
|
= note: read <https://doc.rust-lang.org/unstable-book/language-features/doc-masked.html> for more information
error: this attribute can only be applied at the crate level
--> $DIR/invalid-doc-attr.rs:19:11
--> $DIR/invalid-doc-attr.rs:17:16
|
LL | #[doc(test(no_crate_inject))]
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^
|
= note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information
error: this attribute can only be applied to a `use` item
--> $DIR/invalid-doc-attr.rs:21:11
--> $DIR/invalid-doc-attr.rs:19:11
|
LL | #[doc(inline)]
| ^^^^^^ only applicable on `use` items