Skip to content

Commit

Permalink
Follow guidelines for lint suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Dec 12, 2023
1 parent 53dcec8 commit ef1536e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 29 deletions.
8 changes: 6 additions & 2 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,8 @@ impl LangString {
&& let Some(extra) = extra
{
extra.error_invalid_codeblock_attr(format!(
"unknown attribute `{x}`. Did you mean `edition{}`?",
"unknown attribute `{x}`. There is an attribute with a similar \
name: `edition{}`?",
&x[4..]
));
}
Expand Down Expand Up @@ -1338,7 +1339,10 @@ impl LangString {
} {
if let Some(extra) = extra {
extra.error_invalid_codeblock_attr_with_help(
format!("unknown attribute `{x}`. Did you mean `{flag}`?"),
format!(
"unknown attribute `{x}`. There is an attribute with a \
similar name: `{flag}`?"
),
help,
);
}
Expand Down
24 changes: 12 additions & 12 deletions tests/rustdoc-ui/doctest/check-attr-test.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: unknown attribute `compile-fail`. Did you mean `compile_fail`?
error: unknown attribute `compile-fail`. There is an attribute with a similar name: `compile_fail`?
--> $DIR/check-attr-test.rs:5:1
|
5 | / /// foo
Expand All @@ -15,7 +15,7 @@ note: the lint level is defined here
3 | #![deny(rustdoc::invalid_codeblock_attributes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unknown attribute `compilefail`. Did you mean `compile_fail`?
error: unknown attribute `compilefail`. There is an attribute with a similar name: `compile_fail`?
--> $DIR/check-attr-test.rs:5:1
|
5 | / /// foo
Expand All @@ -27,7 +27,7 @@ error: unknown attribute `compilefail`. Did you mean `compile_fail`?
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully

error: unknown attribute `comPile_fail`. Did you mean `compile_fail`?
error: unknown attribute `comPile_fail`. There is an attribute with a similar name: `compile_fail`?
--> $DIR/check-attr-test.rs:5:1
|
5 | / /// foo
Expand All @@ -39,7 +39,7 @@ error: unknown attribute `comPile_fail`. Did you mean `compile_fail`?
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully

error: unknown attribute `should-panic`. Did you mean `should_panic`?
error: unknown attribute `should-panic`. There is an attribute with a similar name: `should_panic`?
--> $DIR/check-attr-test.rs:12:1
|
12 | / /// bar
Expand All @@ -51,7 +51,7 @@ error: unknown attribute `should-panic`. Did you mean `should_panic`?
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running

error: unknown attribute `shouldpanic`. Did you mean `should_panic`?
error: unknown attribute `shouldpanic`. There is an attribute with a similar name: `should_panic`?
--> $DIR/check-attr-test.rs:12:1
|
12 | / /// bar
Expand All @@ -63,7 +63,7 @@ error: unknown attribute `shouldpanic`. Did you mean `should_panic`?
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running

error: unknown attribute `shOuld_panic`. Did you mean `should_panic`?
error: unknown attribute `shOuld_panic`. There is an attribute with a similar name: `should_panic`?
--> $DIR/check-attr-test.rs:12:1
|
12 | / /// bar
Expand All @@ -75,7 +75,7 @@ error: unknown attribute `shOuld_panic`. Did you mean `should_panic`?
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running

error: unknown attribute `no-run`. Did you mean `no_run`?
error: unknown attribute `no-run`. There is an attribute with a similar name: `no_run`?
--> $DIR/check-attr-test.rs:19:1
|
19 | / /// foobar
Expand All @@ -87,7 +87,7 @@ error: unknown attribute `no-run`. Did you mean `no_run`?
|
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)

error: unknown attribute `norun`. Did you mean `no_run`?
error: unknown attribute `norun`. There is an attribute with a similar name: `no_run`?
--> $DIR/check-attr-test.rs:19:1
|
19 | / /// foobar
Expand All @@ -99,7 +99,7 @@ error: unknown attribute `norun`. Did you mean `no_run`?
|
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)

error: unknown attribute `nO_run`. Did you mean `no_run`?
error: unknown attribute `nO_run`. There is an attribute with a similar name: `no_run`?
--> $DIR/check-attr-test.rs:19:1
|
19 | / /// foobar
Expand All @@ -111,7 +111,7 @@ error: unknown attribute `nO_run`. Did you mean `no_run`?
|
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)

error: unknown attribute `test-harness`. Did you mean `test_harness`?
error: unknown attribute `test-harness`. There is an attribute with a similar name: `test_harness`?
--> $DIR/check-attr-test.rs:26:1
|
26 | / /// b
Expand All @@ -123,7 +123,7 @@ error: unknown attribute `test-harness`. Did you mean `test_harness`?
|
= help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function

error: unknown attribute `testharness`. Did you mean `test_harness`?
error: unknown attribute `testharness`. There is an attribute with a similar name: `test_harness`?
--> $DIR/check-attr-test.rs:26:1
|
26 | / /// b
Expand All @@ -135,7 +135,7 @@ error: unknown attribute `testharness`. Did you mean `test_harness`?
|
= help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function

error: unknown attribute `tesT_harness`. Did you mean `test_harness`?
error: unknown attribute `tesT_harness`. There is an attribute with a similar name: `test_harness`?
--> $DIR/check-attr-test.rs:26:1
|
26 | / /// b
Expand Down
26 changes: 13 additions & 13 deletions tests/rustdoc-ui/lints/check-attr.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: unknown attribute `compile-fail`. Did you mean `compile_fail`?
error: unknown attribute `compile-fail`. There is an attribute with a similar name: `compile_fail`?
--> $DIR/check-attr.rs:3:1
|
LL | / /// foo
Expand All @@ -17,7 +17,7 @@ note: the lint level is defined here
LL | #![deny(rustdoc::invalid_codeblock_attributes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unknown attribute `compilefail`. Did you mean `compile_fail`?
error: unknown attribute `compilefail`. There is an attribute with a similar name: `compile_fail`?
--> $DIR/check-attr.rs:3:1
|
LL | / /// foo
Expand All @@ -31,7 +31,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully

error: unknown attribute `comPile_fail`. Did you mean `compile_fail`?
error: unknown attribute `comPile_fail`. There is an attribute with a similar name: `compile_fail`?
--> $DIR/check-attr.rs:3:1
|
LL | / /// foo
Expand All @@ -45,7 +45,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully

error: unknown attribute `should-panic`. Did you mean `should_panic`?
error: unknown attribute `should-panic`. There is an attribute with a similar name: `should_panic`?
--> $DIR/check-attr.rs:13:1
|
LL | / /// bar
Expand All @@ -59,7 +59,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running

error: unknown attribute `shouldpanic`. Did you mean `should_panic`?
error: unknown attribute `shouldpanic`. There is an attribute with a similar name: `should_panic`?
--> $DIR/check-attr.rs:13:1
|
LL | / /// bar
Expand All @@ -73,7 +73,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running

error: unknown attribute `sHould_panic`. Did you mean `should_panic`?
error: unknown attribute `sHould_panic`. There is an attribute with a similar name: `should_panic`?
--> $DIR/check-attr.rs:13:1
|
LL | / /// bar
Expand All @@ -87,7 +87,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running

error: unknown attribute `no-run`. Did you mean `no_run`?
error: unknown attribute `no-run`. There is an attribute with a similar name: `no_run`?
--> $DIR/check-attr.rs:23:1
|
LL | / /// foobar
Expand All @@ -101,7 +101,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)

error: unknown attribute `norun`. Did you mean `no_run`?
error: unknown attribute `norun`. There is an attribute with a similar name: `no_run`?
--> $DIR/check-attr.rs:23:1
|
LL | / /// foobar
Expand All @@ -115,7 +115,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)

error: unknown attribute `no_Run`. Did you mean `no_run`?
error: unknown attribute `no_Run`. There is an attribute with a similar name: `no_run`?
--> $DIR/check-attr.rs:23:1
|
LL | / /// foobar
Expand All @@ -129,7 +129,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)

error: unknown attribute `test-harness`. Did you mean `test_harness`?
error: unknown attribute `test-harness`. There is an attribute with a similar name: `test_harness`?
--> $DIR/check-attr.rs:33:1
|
LL | / /// b
Expand All @@ -143,7 +143,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function

error: unknown attribute `testharness`. Did you mean `test_harness`?
error: unknown attribute `testharness`. There is an attribute with a similar name: `test_harness`?
--> $DIR/check-attr.rs:33:1
|
LL | / /// b
Expand All @@ -157,7 +157,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function

error: unknown attribute `teSt_harness`. Did you mean `test_harness`?
error: unknown attribute `teSt_harness`. There is an attribute with a similar name: `test_harness`?
--> $DIR/check-attr.rs:33:1
|
LL | / /// b
Expand All @@ -171,7 +171,7 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function

error: unknown attribute `rust2018`. Did you mean `edition2018`?
error: unknown attribute `rust2018`. There is an attribute with a similar name: `edition2018`?
--> $DIR/check-attr.rs:43:1
|
LL | / /// b
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-ui/lints/check-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ note: the lint level is defined here
LL | #![deny(rustdoc::missing_doc_code_examples)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unknown attribute `testharness`. Did you mean `test_harness`?
error: unknown attribute `testharness`. There is an attribute with a similar name: `test_harness`?
--> $DIR/check-fail.rs:8:1
|
LL | / //! ```rust,testharness
Expand All @@ -39,7 +39,7 @@ LL | #![deny(rustdoc::all)]
| ^^^^^^^^^^^^
= note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(rustdoc::all)]`

error: unknown attribute `testharness`. Did you mean `test_harness`?
error: unknown attribute `testharness`. There is an attribute with a similar name: `test_harness`?
--> $DIR/check-fail.rs:17:1
|
LL | / /// hello
Expand Down

0 comments on commit ef1536e

Please sign in to comment.