From cdf2a8ffc5f8af31529b44964457a7a7e9979680 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 Sep 2024 18:03:54 +0200 Subject: [PATCH 01/10] Rename `standalone` doctest attribute into `standalone-crate` --- library/core/src/panic/location.rs | 2 +- .../src/write-documentation/documentation-tests.md | 4 ++-- src/librustdoc/doctest.rs | 2 +- src/librustdoc/doctest/make.rs | 2 +- src/librustdoc/html/markdown.rs | 8 ++++---- tests/run-make/doctests-merge/doctest-standalone.rs | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs index e2a842046a9..97408a4ac18 100644 --- a/library/core/src/panic/location.rs +++ b/library/core/src/panic/location.rs @@ -44,7 +44,7 @@ impl<'a> Location<'a> { /// /// # Examples /// - /// ```standalone + /// ```standalone-crate /// use std::panic::Location; /// /// /// Returns the [`Location`] at which it is called. diff --git a/src/doc/rustdoc/src/write-documentation/documentation-tests.md b/src/doc/rustdoc/src/write-documentation/documentation-tests.md index 7ed2e9720fe..94ef34ea5a5 100644 --- a/src/doc/rustdoc/src/write-documentation/documentation-tests.md +++ b/src/doc/rustdoc/src/write-documentation/documentation-tests.md @@ -414,11 +414,11 @@ In some cases, doctests cannot be merged. For example, if you have: The problem with this code is that, if you change any other doctests, it'll likely break when runing `rustdoc --test`, making it tricky to maintain. -This is where the `standalone` attribute comes in: it tells `rustdoc` that a doctest +This is where the `standalone-crate` attribute comes in: it tells `rustdoc` that a doctest should not be merged with the others. So the previous code should use it: ```rust -//! ```standalone +//! ```standalone-crate //! let location = std::panic::Location::caller(); //! assert_eq!(location.line(), 4); //! ``` diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 3ee6b24ac92..bdd6fbe8c0c 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -837,7 +837,7 @@ impl CreateRunnableDocTests { let is_standalone = !doctest.can_be_merged || scraped_test.langstr.compile_fail || scraped_test.langstr.test_harness - || scraped_test.langstr.standalone + || scraped_test.langstr.standalone_crate || self.rustdoc_options.nocapture || self.rustdoc_options.test_args.iter().any(|arg| arg == "--show-output"); if is_standalone { diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index d560e3a476b..efbb332d12d 100644 --- a/src/librustdoc/doctest/make.rs +++ b/src/librustdoc/doctest/make.rs @@ -48,7 +48,7 @@ impl DocTestBuilder { ) -> Self { let can_merge_doctests = can_merge_doctests && lang_str.is_some_and(|lang_str| { - !lang_str.compile_fail && !lang_str.test_harness && !lang_str.standalone + !lang_str.compile_fail && !lang_str.test_harness && !lang_str.standalone_crate }); let SourceInfo { crate_attrs, maybe_crate_attrs, crates, everything_else } = diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index b18d621478c..fbba63f9445 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -871,7 +871,7 @@ pub(crate) struct LangString { pub(crate) rust: bool, pub(crate) test_harness: bool, pub(crate) compile_fail: bool, - pub(crate) standalone: bool, + pub(crate) standalone_crate: bool, pub(crate) error_codes: Vec, pub(crate) edition: Option, pub(crate) added_classes: Vec, @@ -1194,7 +1194,7 @@ impl Default for LangString { rust: true, test_harness: false, compile_fail: false, - standalone: false, + standalone_crate: false, error_codes: Vec::new(), edition: None, added_classes: Vec::new(), @@ -1264,8 +1264,8 @@ impl LangString { seen_rust_tags = !seen_other_tags || seen_rust_tags; data.no_run = true; } - LangStringToken::LangToken("standalone") => { - data.standalone = true; + LangStringToken::LangToken("standalone-crate") => { + data.standalone_crate = true; seen_rust_tags = !seen_other_tags || seen_rust_tags; } LangStringToken::LangToken(x) if x.starts_with("edition") => { diff --git a/tests/run-make/doctests-merge/doctest-standalone.rs b/tests/run-make/doctests-merge/doctest-standalone.rs index 134ffb58285..4b6a1c6ab61 100644 --- a/tests/run-make/doctests-merge/doctest-standalone.rs +++ b/tests/run-make/doctests-merge/doctest-standalone.rs @@ -1,11 +1,11 @@ #![crate_name = "foo"] #![crate_type = "lib"] -//! ```standalone +//! ```standalone-crate //! foo::init(); //! ``` -/// ```standalone +/// ```standalone-crate /// foo::init(); /// ``` pub fn init() { From 35f24d0d14f66ddd59088af7f5f1582d21b6ea11 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 Sep 2024 21:28:15 +0200 Subject: [PATCH 02/10] Improve code for codeblock invalid attributes --- src/librustdoc/html/markdown.rs | 43 ++++++++++++++------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index fbba63f9445..a9befefa118 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1298,35 +1298,28 @@ impl LangString { } LangStringToken::LangToken(x) if extra.is_some() => { let s = x.to_lowercase(); - if let Some((flag, help)) = if s == "compile-fail" - || s == "compile_fail" - || s == "compilefail" - { - Some(( + if let Some((flag, help)) = match s.as_str() { + "compile-fail" | "compile_fail" | "compilefail" => Some(( "compile_fail", - "the code block will either not be tested if not marked as a rust one \ - or won't fail if it compiles successfully", - )) - } else if s == "should-panic" || s == "should_panic" || s == "shouldpanic" { - Some(( + "the code block will either not be tested if not marked as a rust \ + one or won't fail if it compiles successfully", + )), + "should-panic" | "should_panic" | "shouldpanic" => Some(( "should_panic", - "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", - )) - } else if s == "no-run" || s == "no_run" || s == "norun" { - Some(( + "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", + )), + "no-run" | "no_run" | "norun" => Some(( "no_run", - "the code block will either not be tested if not marked as a rust one \ - or will be run (which you might not want)", - )) - } else if s == "test-harness" || s == "test_harness" || s == "testharness" { - Some(( + "the code block will either not be tested if not marked as a rust \ + one or will be run (which you might not want)", + )), + "test-harness" | "test_harness" | "testharness" => Some(( "test_harness", - "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", - )) - } else { - None + "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", + )), + _ => None, } { if let Some(extra) = extra { extra.error_invalid_codeblock_attr_with_help( From 0956f69cafb4132023b9974f0a4a091bcac76618 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 Sep 2024 21:39:52 +0200 Subject: [PATCH 03/10] Add warning if `standalone-crate` is mistyped --- src/librustdoc/html/markdown.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index a9befefa118..c487138152d 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1319,6 +1319,20 @@ impl LangString { "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", )), + "standalone" | "standalone_crate" => { + if let Some(extra) = extra + && extra.sp.at_least_rust_2024() + { + Some(( + "standalone-crate", + "the code block will either not be tested if not marked as \ + a rust one or the code will be run as part of the merged \ + doctests if compatible", + )) + } else { + None + } + } _ => None, } { if let Some(extra) = extra { From 84d41e2fc19570e553dc6704e747062373ce4270 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 Sep 2024 21:40:11 +0200 Subject: [PATCH 04/10] Add regression tests for mistyped `standalone-crate` attribute --- .../doctest/standalone-warning-2024.rs | 16 ++++++++ .../doctest/standalone-warning-2024.stderr | 38 +++++++++++++++++++ .../rustdoc-ui/doctest/standalone-warning.rs | 10 +++++ 3 files changed, 64 insertions(+) create mode 100644 tests/rustdoc-ui/doctest/standalone-warning-2024.rs create mode 100644 tests/rustdoc-ui/doctest/standalone-warning-2024.stderr create mode 100644 tests/rustdoc-ui/doctest/standalone-warning.rs diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.rs b/tests/rustdoc-ui/doctest/standalone-warning-2024.rs new file mode 100644 index 00000000000..33ed16a87fa --- /dev/null +++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.rs @@ -0,0 +1,16 @@ +// This test checks that it will output warnings for usage of `standalone` or `standalone_crate`. + +//@ compile-flags:--test -Zunstable-options --edition 2024 +//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" +//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout-test: ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL" + +#![deny(warnings)] + +//! ```standalone +//! bla +//! ``` +//! +//! ```standalone_crate +//! bla +//! ``` diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr new file mode 100644 index 00000000000..ec9d17bb073 --- /dev/null +++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr @@ -0,0 +1,38 @@ +error: unknown attribute `standalone` + --> $DIR/standalone-warning-2024.rs:10:1 + | +10 | / //! ```standalone +11 | | //! bla +12 | | //! ``` +13 | | //! +14 | | //! ```standalone_crate +15 | | //! bla +16 | | //! ``` + | |_______^ + | + = help: there is an attribute with a similar name: `standalone-crate` + = help: the code block will either not be tested if not marked as a rust one or the code will be run as part of the merged doctests if compatible +note: the lint level is defined here + --> $DIR/standalone-warning-2024.rs:8:9 + | +8 | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]` + +error: unknown attribute `standalone_crate` + --> $DIR/standalone-warning-2024.rs:10:1 + | +10 | / //! ```standalone +11 | | //! bla +12 | | //! ``` +13 | | //! +14 | | //! ```standalone_crate +15 | | //! bla +16 | | //! ``` + | |_______^ + | + = help: there is an attribute with a similar name: `standalone-crate` + = help: the code block will either not be tested if not marked as a rust one or the code will be run as part of the merged doctests if compatible + +error: aborting due to 2 previous errors + diff --git a/tests/rustdoc-ui/doctest/standalone-warning.rs b/tests/rustdoc-ui/doctest/standalone-warning.rs new file mode 100644 index 00000000000..323d8f5f580 --- /dev/null +++ b/tests/rustdoc-ui/doctest/standalone-warning.rs @@ -0,0 +1,10 @@ +// This test checks that it will not output warning for usage of `standalone` or `standalone_crate`. +//@ check-pass + +//! ```standalone +//! bla +//! ``` +//! +//! ```standalone_crate +//! bla +//! ``` From 632fed891df4850e579b2c796de7e18b53d80daa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 28 Sep 2024 01:32:09 +0200 Subject: [PATCH 05/10] Improve mistyped docblock attribute warning messages --- src/librustdoc/html/markdown.rs | 58 +++++++++---------- .../rustdoc-ui/doctest/check-attr-test.stderr | 48 +++++++-------- .../doctest/standalone-warning-2024.stderr | 8 +-- tests/rustdoc-ui/lints/check-attr.stderr | 52 ++++++++--------- tests/rustdoc-ui/lints/check-fail.stderr | 8 +-- 5 files changed, 85 insertions(+), 89 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index c487138152d..e1a8dc6e50c 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1298,37 +1298,31 @@ impl LangString { } LangStringToken::LangToken(x) if extra.is_some() => { let s = x.to_lowercase(); - if let Some((flag, help)) = match s.as_str() { - "compile-fail" | "compile_fail" | "compilefail" => Some(( - "compile_fail", - "the code block will either not be tested if not marked as a rust \ - one or won't fail if it compiles successfully", - )), - "should-panic" | "should_panic" | "shouldpanic" => Some(( - "should_panic", - "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", - )), - "no-run" | "no_run" | "norun" => Some(( - "no_run", - "the code block will either not be tested if not marked as a rust \ - one or will be run (which you might not want)", - )), - "test-harness" | "test_harness" | "testharness" => Some(( - "test_harness", - "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", - )), + if let Some(help) = match s.as_str() { + "compile-fail" | "compile_fail" | "compilefail" => Some( + "use `compile_fail` to invert the results of this test, so that it \ + passes if it cannot be compiled and fails if it can", + ), + "should-panic" | "should_panic" | "shouldpanic" => Some( + "use `should_panic` to invert the results of this test, so that if \ + passes if it panics and fails if it does not", + ), + "no-run" | "no_run" | "norun" => Some( + "use `no_run` to compile, but not run, the code sample during \ + testing", + ), + "test-harness" | "test_harness" | "testharness" => Some( + "use `test_harness` to run functions marked `#[test]` instead of a \ + potentially-implicit `main` function", + ), "standalone" | "standalone_crate" => { if let Some(extra) = extra && extra.sp.at_least_rust_2024() { - Some(( - "standalone-crate", - "the code block will either not be tested if not marked as \ - a rust one or the code will be run as part of the merged \ - doctests if compatible", - )) + Some( + "use `standalone-crate` to compile this code block \ + separately", + ) } else { None } @@ -1339,10 +1333,12 @@ impl LangString { extra.error_invalid_codeblock_attr_with_help( format!("unknown attribute `{x}`"), |lint| { - lint.help(format!( - "there is an attribute with a similar name: `{flag}`" - )) - .help(help); + lint.help(help).help( + "this code block may be skipped during testing, \ + because unknown attributes are treated as markers for \ + code samples written in other programming languages, \ + unless it is also explicitly marked as `rust`", + ); }, ); } diff --git a/tests/rustdoc-ui/doctest/check-attr-test.stderr b/tests/rustdoc-ui/doctest/check-attr-test.stderr index 10f763a6f9d..257136d1633 100644 --- a/tests/rustdoc-ui/doctest/check-attr-test.stderr +++ b/tests/rustdoc-ui/doctest/check-attr-test.stderr @@ -8,8 +8,8 @@ error: unknown attribute `compile-fail` 9 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` note: the lint level is defined here --> $DIR/check-attr-test.rs:3:9 | @@ -26,8 +26,8 @@ error: unknown attribute `compilefail` 9 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `comPile_fail` --> $DIR/check-attr-test.rs:5:1 @@ -39,8 +39,8 @@ error: unknown attribute `comPile_fail` 9 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `should-panic` --> $DIR/check-attr-test.rs:12:1 @@ -52,8 +52,8 @@ error: unknown attribute `should-panic` 16 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `shouldpanic` --> $DIR/check-attr-test.rs:12:1 @@ -65,8 +65,8 @@ error: unknown attribute `shouldpanic` 16 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `shOuld_panic` --> $DIR/check-attr-test.rs:12:1 @@ -78,8 +78,8 @@ error: unknown attribute `shOuld_panic` 16 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `no-run` --> $DIR/check-attr-test.rs:19:1 @@ -91,8 +91,8 @@ error: unknown attribute `no-run` 23 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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) + = help: use `no_run` to compile, but not run, the code sample during testing + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `norun` --> $DIR/check-attr-test.rs:19:1 @@ -104,8 +104,8 @@ error: unknown attribute `norun` 23 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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) + = help: use `no_run` to compile, but not run, the code sample during testing + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `nO_run` --> $DIR/check-attr-test.rs:19:1 @@ -117,8 +117,8 @@ error: unknown attribute `nO_run` 23 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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) + = help: use `no_run` to compile, but not run, the code sample during testing + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `test-harness` --> $DIR/check-attr-test.rs:26:1 @@ -130,8 +130,8 @@ error: unknown attribute `test-harness` 30 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `testharness` --> $DIR/check-attr-test.rs:26:1 @@ -143,8 +143,8 @@ error: unknown attribute `testharness` 30 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `tesT_harness` --> $DIR/check-attr-test.rs:26:1 @@ -156,8 +156,8 @@ error: unknown attribute `tesT_harness` 30 | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: aborting due to 12 previous errors diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr index ec9d17bb073..ef2e2364319 100644 --- a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr +++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr @@ -10,8 +10,8 @@ error: unknown attribute `standalone` 16 | | //! ``` | |_______^ | - = help: there is an attribute with a similar name: `standalone-crate` - = help: the code block will either not be tested if not marked as a rust one or the code will be run as part of the merged doctests if compatible + = help: use `standalone-crate` to compile this code block separately + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` note: the lint level is defined here --> $DIR/standalone-warning-2024.rs:8:9 | @@ -31,8 +31,8 @@ error: unknown attribute `standalone_crate` 16 | | //! ``` | |_______^ | - = help: there is an attribute with a similar name: `standalone-crate` - = help: the code block will either not be tested if not marked as a rust one or the code will be run as part of the merged doctests if compatible + = help: use `standalone-crate` to compile this code block separately + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: aborting due to 2 previous errors diff --git a/tests/rustdoc-ui/lints/check-attr.stderr b/tests/rustdoc-ui/lints/check-attr.stderr index d640125ab51..e23806e0bab 100644 --- a/tests/rustdoc-ui/lints/check-attr.stderr +++ b/tests/rustdoc-ui/lints/check-attr.stderr @@ -10,8 +10,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` note: the lint level is defined here --> $DIR/check-attr.rs:1:9 | @@ -30,8 +30,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `comPile_fail` --> $DIR/check-attr.rs:3:1 @@ -45,8 +45,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `should-panic` --> $DIR/check-attr.rs:13:1 @@ -60,8 +60,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `shouldpanic` --> $DIR/check-attr.rs:13:1 @@ -75,8 +75,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `sHould_panic` --> $DIR/check-attr.rs:13:1 @@ -90,8 +90,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `no-run` --> $DIR/check-attr.rs:23:1 @@ -105,8 +105,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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) + = help: use `no_run` to compile, but not run, the code sample during testing + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `norun` --> $DIR/check-attr.rs:23:1 @@ -120,8 +120,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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) + = help: use `no_run` to compile, but not run, the code sample during testing + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `no_Run` --> $DIR/check-attr.rs:23:1 @@ -135,8 +135,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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) + = help: use `no_run` to compile, but not run, the code sample during testing + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `test-harness` --> $DIR/check-attr.rs:33:1 @@ -150,8 +150,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `testharness` --> $DIR/check-attr.rs:33:1 @@ -165,8 +165,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `teSt_harness` --> $DIR/check-attr.rs:33:1 @@ -180,8 +180,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: unknown attribute `rust2018` --> $DIR/check-attr.rs:43:1 @@ -222,8 +222,8 @@ LL | | /// boo LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: aborting due to 15 previous errors diff --git a/tests/rustdoc-ui/lints/check-fail.stderr b/tests/rustdoc-ui/lints/check-fail.stderr index 99b01bac598..2eb9496e5dc 100644 --- a/tests/rustdoc-ui/lints/check-fail.stderr +++ b/tests/rustdoc-ui/lints/check-fail.stderr @@ -31,8 +31,8 @@ LL | | //! let x = 12; LL | | //! ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` note: the lint level is defined here --> $DIR/check-fail.rs:6:9 | @@ -51,8 +51,8 @@ LL | | /// let x = 12; LL | | /// ``` | |_______^ | - = help: there is an attribute with a similar name: `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 + = help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function + = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: aborting due to 4 previous errors From bfc9951fa80f8c372852dc13896cf1ea59eaede0 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 29 Sep 2024 00:22:29 +0000 Subject: [PATCH 06/10] cargo update Locking 5 packages to latest compatible versions Updating autocfg v1.3.0 -> v1.4.0 Updating flate2 v1.0.33 -> v1.0.34 Updating portable-atomic v1.8.0 -> v1.9.0 Updating syn v2.0.77 -> v2.0.79 Updating tempfile v3.12.0 -> v3.13.0 note: pass `--verbose` to see 81 unchanged dependencies behind latest library dependencies: Locking 0 packages to latest compatible versions note: pass `--verbose` to see 9 unchanged dependencies behind latest rustbook dependencies: Locking 13 packages to latest compatible versions Updating autocfg v1.3.0 -> v1.4.0 Updating cc v1.1.21 -> v1.1.22 Updating flate2 v1.0.33 -> v1.0.34 Updating libc v0.2.158 -> v0.2.159 Updating pkg-config v0.3.30 -> v0.3.31 Updating redox_syscall v0.5.4 -> v0.5.6 Updating serde_spanned v0.6.7 -> v0.6.8 Updating syn v2.0.77 -> v2.0.79 Updating tempfile v3.12.0 -> v3.13.0 Updating thiserror v1.0.63 -> v1.0.64 Updating thiserror-impl v1.0.63 -> v1.0.64 Updating toml_edit v0.22.21 -> v0.22.22 Updating winnow v0.6.18 -> v0.6.20 note: pass `--verbose` to see 30 unchanged dependencies behind latest --- Cargo.lock | 90 +++++++++++++++++------------------ src/tools/rustbook/Cargo.lock | 52 ++++++++++---------- 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebb8d114f2a..d00bf4b1292 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -207,9 +207,9 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" @@ -505,7 +505,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -534,7 +534,7 @@ dependencies = [ "rustc_tools_util", "serde", "serde_json", - "syn 2.0.77", + "syn 2.0.79", "tempfile", "termize", "tokio", @@ -643,7 +643,7 @@ dependencies = [ "nom", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -861,7 +861,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -872,7 +872,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -898,7 +898,7 @@ version = "0.1.83" dependencies = [ "itertools", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -918,7 +918,7 @@ checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -939,7 +939,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -949,7 +949,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" dependencies = [ "derive_builder_core", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -961,7 +961,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1039,7 +1039,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1192,9 +1192,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide 0.8.0", @@ -1330,7 +1330,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1554,7 +1554,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1686,7 +1686,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2661,7 +2661,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2763,9 +2763,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -3073,7 +3073,7 @@ dependencies = [ "rinja_parser", "rustc-hash 2.0.0", "serde", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3671,7 +3671,7 @@ dependencies = [ "fluent-syntax", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "unic-langid", ] @@ -3805,7 +3805,7 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3954,7 +3954,7 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "synstructure", ] @@ -4535,7 +4535,7 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "synstructure", ] @@ -4623,7 +4623,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4760,7 +4760,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5024,9 +5024,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -5041,7 +5041,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5078,9 +5078,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -5174,7 +5174,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5365,7 +5365,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5536,7 +5536,7 @@ checksum = "1ed7f4237ba393424195053097c1516bd4590dc82b84f2f97c5c69e12704555b" dependencies = [ "proc-macro-hack", "quote", - "syn 2.0.77", + "syn 2.0.79", "unic-langid-impl", ] @@ -5734,7 +5734,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -5756,7 +5756,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5923,7 +5923,7 @@ dependencies = [ "rayon", "serde", "serde_json", - "syn 2.0.77", + "syn 2.0.79", "windows-metadata", ] @@ -5956,7 +5956,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5967,7 +5967,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6234,7 +6234,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "synstructure", ] @@ -6256,7 +6256,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6276,7 +6276,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "synstructure", ] @@ -6299,5 +6299,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] diff --git a/src/tools/rustbook/Cargo.lock b/src/tools/rustbook/Cargo.lock index e5f0aabbf7c..060deb18344 100644 --- a/src/tools/rustbook/Cargo.lock +++ b/src/tools/rustbook/Cargo.lock @@ -102,9 +102,9 @@ checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bincode" @@ -161,9 +161,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.21" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" dependencies = [ "shlex", ] @@ -376,9 +376,9 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide", @@ -572,9 +572,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libdbus-sys" @@ -949,9 +949,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "polib" @@ -1082,9 +1082,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" dependencies = [ "bitflags 2.6.0", ] @@ -1205,9 +1205,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -1275,9 +1275,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -1306,9 +1306,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -1346,18 +1346,18 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -1411,9 +1411,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "serde", @@ -1766,9 +1766,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] From e9635685859626cc4ea252eac65beef0f6066e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 29 Sep 2024 12:18:11 +0200 Subject: [PATCH 07/10] cleanup: don't `.into()` identical types --- compiler/rustc_const_eval/src/interpret/intrinsics.rs | 7 ++----- compiler/rustc_interface/src/interface.rs | 2 +- compiler/rustc_lint/src/if_let_rescope.rs | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index e1fd8bea1f3..4c34ffc5d4e 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -396,11 +396,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { for i in 0..dest_len { let place = self.project_index(&dest, i)?; - let value = if i == index { - elem.clone() - } else { - self.project_index(&input, i)?.into() - }; + let value = + if i == index { elem.clone() } else { self.project_index(&input, i)? }; self.copy_op(&value, &place)?; } } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index c2241773c8c..3b8077bb3fc 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -427,7 +427,7 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se Err(e) => early_dcx.early_fatal(format!("failed to load fluent bundle: {e}")), }; - let mut locale_resources = Vec::from(config.locale_resources); + let mut locale_resources = config.locale_resources; locale_resources.push(codegen_backend.locale_resource()); let mut sess = rustc_session::build_session( diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 229d0c36421..c6218fe1e74 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -304,7 +304,7 @@ impl Subdiagnostic for IfLetRescopeRewrite { .chain(repeat('}').take(closing_brackets.count)) .collect(), )); - let msg = f(diag, crate::fluent_generated::lint_suggestion.into()); + let msg = f(diag, crate::fluent_generated::lint_suggestion); diag.multipart_suggestion_with_style( msg, suggestions, From 1a28599981a02ee865e51470be1009300a720faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 29 Sep 2024 12:51:28 +0200 Subject: [PATCH 08/10] cleanup: don't manually `unwrap_or_default()` --- compiler/rustc_expand/src/proc_macro_server.rs | 6 ++---- compiler/rustc_hir_typeck/src/upvar.rs | 10 +++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index a7b251ab252..0dc35618ff8 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -627,8 +627,7 @@ impl server::TokenStream for Rustc<'_, '_> { base: Option, trees: Vec>, ) -> Self::TokenStream { - let mut stream = - if let Some(base) = base { base } else { tokenstream::TokenStream::default() }; + let mut stream = base.unwrap_or_default(); for tree in trees { for tt in (tree, &mut *self).to_internal() { stream.push_tree(tt); @@ -642,8 +641,7 @@ impl server::TokenStream for Rustc<'_, '_> { base: Option, streams: Vec, ) -> Self::TokenStream { - let mut stream = - if let Some(base) = base { base } else { tokenstream::TokenStream::default() }; + let mut stream = base.unwrap_or_default(); for s in streams { stream.push_stream(s); } diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index c5843b883a1..63cf483aa22 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -1369,13 +1369,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for (&var_hir_id, _) in upvars.iter() { let mut diagnostics_info = Vec::new(); - let auto_trait_diagnostic = if let Some(diagnostics_info) = - self.compute_2229_migrations_for_trait(min_captures, var_hir_id, closure_clause) - { - diagnostics_info - } else { - FxIndexMap::default() - }; + let auto_trait_diagnostic = self + .compute_2229_migrations_for_trait(min_captures, var_hir_id, closure_clause) + .unwrap_or_default(); let drop_reorder_diagnostic = if let Some(diagnostics_info) = self .compute_2229_migrations_for_drop( From 6f5f21adfc88a914c507ba8c9a0f1f34ae292d44 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 28 Sep 2024 22:37:59 +0200 Subject: [PATCH 09/10] Rename doctest attribute `standalone-crate` into `standalone_crate` for coherency --- library/core/src/panic/location.rs | 2 +- .../src/write-documentation/documentation-tests.md | 4 ++-- src/librustdoc/html/markdown.rs | 6 +++--- tests/run-make/doctests-merge/doctest-standalone.rs | 4 ++-- tests/rustdoc-ui/doctest/standalone-warning-2024.rs | 2 +- .../rustdoc-ui/doctest/standalone-warning-2024.stderr | 10 +++++----- tests/rustdoc-ui/doctest/standalone-warning.rs | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs index 97408a4ac18..1ad5c07d15c 100644 --- a/library/core/src/panic/location.rs +++ b/library/core/src/panic/location.rs @@ -44,7 +44,7 @@ impl<'a> Location<'a> { /// /// # Examples /// - /// ```standalone-crate + /// ```standalone_crate /// use std::panic::Location; /// /// /// Returns the [`Location`] at which it is called. diff --git a/src/doc/rustdoc/src/write-documentation/documentation-tests.md b/src/doc/rustdoc/src/write-documentation/documentation-tests.md index 94ef34ea5a5..c93893b5ada 100644 --- a/src/doc/rustdoc/src/write-documentation/documentation-tests.md +++ b/src/doc/rustdoc/src/write-documentation/documentation-tests.md @@ -414,11 +414,11 @@ In some cases, doctests cannot be merged. For example, if you have: The problem with this code is that, if you change any other doctests, it'll likely break when runing `rustdoc --test`, making it tricky to maintain. -This is where the `standalone-crate` attribute comes in: it tells `rustdoc` that a doctest +This is where the `standalone_crate` attribute comes in: it tells `rustdoc` that a doctest should not be merged with the others. So the previous code should use it: ```rust -//! ```standalone-crate +//! ```standalone_crate //! let location = std::panic::Location::caller(); //! assert_eq!(location.line(), 4); //! ``` diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index e1a8dc6e50c..8ae5484feda 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1264,7 +1264,7 @@ impl LangString { seen_rust_tags = !seen_other_tags || seen_rust_tags; data.no_run = true; } - LangStringToken::LangToken("standalone-crate") => { + LangStringToken::LangToken("standalone_crate") => { data.standalone_crate = true; seen_rust_tags = !seen_other_tags || seen_rust_tags; } @@ -1315,12 +1315,12 @@ impl LangString { "use `test_harness` to run functions marked `#[test]` instead of a \ potentially-implicit `main` function", ), - "standalone" | "standalone_crate" => { + "standalone" | "standalone_crate" | "standalone-crate" => { if let Some(extra) = extra && extra.sp.at_least_rust_2024() { Some( - "use `standalone-crate` to compile this code block \ + "use `standalone_crate` to compile this code block \ separately", ) } else { diff --git a/tests/run-make/doctests-merge/doctest-standalone.rs b/tests/run-make/doctests-merge/doctest-standalone.rs index 4b6a1c6ab61..ac9f8f9272a 100644 --- a/tests/run-make/doctests-merge/doctest-standalone.rs +++ b/tests/run-make/doctests-merge/doctest-standalone.rs @@ -1,11 +1,11 @@ #![crate_name = "foo"] #![crate_type = "lib"] -//! ```standalone-crate +//! ```standalone_crate //! foo::init(); //! ``` -/// ```standalone-crate +/// ```standalone_crate /// foo::init(); /// ``` pub fn init() { diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.rs b/tests/rustdoc-ui/doctest/standalone-warning-2024.rs index 33ed16a87fa..aac43031546 100644 --- a/tests/rustdoc-ui/doctest/standalone-warning-2024.rs +++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.rs @@ -11,6 +11,6 @@ //! bla //! ``` //! -//! ```standalone_crate +//! ```standalone-crate //! bla //! ``` diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr index ef2e2364319..d69d03d8657 100644 --- a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr +++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr @@ -5,12 +5,12 @@ error: unknown attribute `standalone` 11 | | //! bla 12 | | //! ``` 13 | | //! -14 | | //! ```standalone_crate +14 | | //! ```standalone-crate 15 | | //! bla 16 | | //! ``` | |_______^ | - = help: use `standalone-crate` to compile this code block separately + = help: use `standalone_crate` to compile this code block separately = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` note: the lint level is defined here --> $DIR/standalone-warning-2024.rs:8:9 @@ -19,19 +19,19 @@ note: the lint level is defined here | ^^^^^^^^ = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]` -error: unknown attribute `standalone_crate` +error: unknown attribute `standalone-crate` --> $DIR/standalone-warning-2024.rs:10:1 | 10 | / //! ```standalone 11 | | //! bla 12 | | //! ``` 13 | | //! -14 | | //! ```standalone_crate +14 | | //! ```standalone-crate 15 | | //! bla 16 | | //! ``` | |_______^ | - = help: use `standalone-crate` to compile this code block separately + = help: use `standalone_crate` to compile this code block separately = help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust` error: aborting due to 2 previous errors diff --git a/tests/rustdoc-ui/doctest/standalone-warning.rs b/tests/rustdoc-ui/doctest/standalone-warning.rs index 323d8f5f580..ce081c7641c 100644 --- a/tests/rustdoc-ui/doctest/standalone-warning.rs +++ b/tests/rustdoc-ui/doctest/standalone-warning.rs @@ -5,6 +5,6 @@ //! bla //! ``` //! -//! ```standalone_crate +//! ```standalone-crate //! bla //! ``` From 71cd918dc78c84d41bb89c2fc8effcfd000f4e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 29 Sep 2024 13:31:30 +0200 Subject: [PATCH 10/10] cleanup: don't clone types that are Copy --- compiler/rustc_middle/src/middle/stability.rs | 2 +- .../rustc_mir_transform/src/coroutine/by_move_body.rs | 10 +++++----- compiler/rustc_mir_transform/src/single_use_consts.rs | 5 ++--- compiler/rustc_pattern_analysis/src/constructor.rs | 8 ++++---- compiler/rustc_resolve/src/diagnostics.rs | 6 +----- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 54cfd995832..ee34ccd889f 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -217,7 +217,7 @@ pub fn early_report_macro_deprecation( suggestion_span: span, note: depr.note, path, - since_kind: deprecated_since_kind(is_in_effect, depr.since.clone()), + since_kind: deprecated_since_kind(is_in_effect, depr.since), }; lint_buffer.buffer_lint(deprecation_lint(is_in_effect), node_id, span, diag); } diff --git a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs index 65442877d2d..cc4b7689d40 100644 --- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs +++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs @@ -223,14 +223,14 @@ pub(crate) fn coroutine_by_move_body_def_id<'tcx>( // Inherited from the by-ref coroutine. body_def.codegen_fn_attrs(tcx.codegen_fn_attrs(coroutine_def_id).clone()); - body_def.constness(tcx.constness(coroutine_def_id).clone()); - body_def.coroutine_kind(tcx.coroutine_kind(coroutine_def_id).clone()); + body_def.constness(tcx.constness(coroutine_def_id)); + body_def.coroutine_kind(tcx.coroutine_kind(coroutine_def_id)); body_def.def_ident_span(tcx.def_ident_span(coroutine_def_id)); body_def.def_span(tcx.def_span(coroutine_def_id)); - body_def.explicit_predicates_of(tcx.explicit_predicates_of(coroutine_def_id).clone()); + body_def.explicit_predicates_of(tcx.explicit_predicates_of(coroutine_def_id)); body_def.generics_of(tcx.generics_of(coroutine_def_id).clone()); - body_def.param_env(tcx.param_env(coroutine_def_id).clone()); - body_def.predicates_of(tcx.predicates_of(coroutine_def_id).clone()); + body_def.param_env(tcx.param_env(coroutine_def_id)); + body_def.predicates_of(tcx.predicates_of(coroutine_def_id)); // The type of the coroutine is the `by_move_coroutine_ty`. body_def.type_of(ty::EarlyBinder::bind(by_move_coroutine_ty)); diff --git a/compiler/rustc_mir_transform/src/single_use_consts.rs b/compiler/rustc_mir_transform/src/single_use_consts.rs index 9884b6dd1c3..277a33c0311 100644 --- a/compiler/rustc_mir_transform/src/single_use_consts.rs +++ b/compiler/rustc_mir_transform/src/single_use_consts.rs @@ -185,15 +185,14 @@ impl<'tcx> MutVisitor<'tcx> for LocalReplacer<'tcx> { && let Some(local) = place.as_local() && local == self.local { - let const_op = self + let const_op = *self .operand .as_ref() .unwrap_or_else(|| { bug!("the operand was already stolen"); }) .constant() - .unwrap() - .clone(); + .unwrap(); var_debug_info.value = VarDebugInfoContents::Const(const_op); } } diff --git a/compiler/rustc_pattern_analysis/src/constructor.rs b/compiler/rustc_pattern_analysis/src/constructor.rs index 3cb7576154f..8fce4266345 100644 --- a/compiler/rustc_pattern_analysis/src/constructor.rs +++ b/compiler/rustc_pattern_analysis/src/constructor.rs @@ -735,10 +735,10 @@ impl Clone for Constructor { Constructor::UnionField => Constructor::UnionField, Constructor::Bool(b) => Constructor::Bool(*b), Constructor::IntRange(range) => Constructor::IntRange(*range), - Constructor::F16Range(lo, hi, end) => Constructor::F16Range(lo.clone(), *hi, *end), - Constructor::F32Range(lo, hi, end) => Constructor::F32Range(lo.clone(), *hi, *end), - Constructor::F64Range(lo, hi, end) => Constructor::F64Range(lo.clone(), *hi, *end), - Constructor::F128Range(lo, hi, end) => Constructor::F128Range(lo.clone(), *hi, *end), + Constructor::F16Range(lo, hi, end) => Constructor::F16Range(*lo, *hi, *end), + Constructor::F32Range(lo, hi, end) => Constructor::F32Range(*lo, *hi, *end), + Constructor::F64Range(lo, hi, end) => Constructor::F64Range(*lo, *hi, *end), + Constructor::F128Range(lo, hi, end) => Constructor::F128Range(*lo, *hi, *end), Constructor::Str(value) => Constructor::Str(value.clone()), Constructor::Opaque(inner) => Constructor::Opaque(inner.clone()), Constructor::Or => Constructor::Or, diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 46e30c614ab..582db97e1ce 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1469,11 +1469,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } let unused_macro = self.unused_macros.iter().find_map(|(def_id, (_, unused_ident))| { - if unused_ident.name == ident.name { - Some((def_id.clone(), unused_ident.clone())) - } else { - None - } + if unused_ident.name == ident.name { Some((def_id, unused_ident)) } else { None } }); if let Some((def_id, unused_ident)) = unused_macro {