From 8200c1e52e1f67cee0546b288a72154407cf1c0a Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 12 Dec 2024 13:26:09 -0700 Subject: [PATCH 01/19] rustdoc-search: fix mismatched path when parent re-exported twice --- src/librustdoc/html/render/search_index.rs | 8 ++++++++ tests/rustdoc-js/reexport.js | 9 +++++++++ tests/rustdoc-js/reexport.rs | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index cfb62c3ca164..134438efa5ec 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -423,6 +423,14 @@ pub(crate) fn build_index( } Some(path) }); + } else if let Some(parent_idx) = item.parent_idx { + let i = >::try_into(parent_idx).unwrap(); + item.path = { + let p = &crate_paths[i].1; + join_with_double_colon(&p[..p.len() - 1]) + }; + item.exact_path = + crate_paths[i].2.as_ref().map(|xp| join_with_double_colon(&xp[..xp.len() - 1])); } // Omit the parent path if it is same to that of the prior item. diff --git a/tests/rustdoc-js/reexport.js b/tests/rustdoc-js/reexport.js index 9021cc2e90fe..0b9415dd3e48 100644 --- a/tests/rustdoc-js/reexport.js +++ b/tests/rustdoc-js/reexport.js @@ -14,4 +14,13 @@ const EXPECTED = [ { 'path': 'reexport', 'name': 'AnotherOne' }, ], }, + { + 'query': 'fn:Equivalent::equivalent', + 'others': [ + // These results must never contain `reexport::equivalent::NotEquivalent`, + // since that path does not exist. + { 'path': 'equivalent::Equivalent', 'name': 'equivalent' }, + { 'path': 'reexport::NotEquivalent', 'name': 'equivalent' }, + ], + }, ]; diff --git a/tests/rustdoc-js/reexport.rs b/tests/rustdoc-js/reexport.rs index 0b3718cd9a3e..ecbbeca5ea89 100644 --- a/tests/rustdoc-js/reexport.rs +++ b/tests/rustdoc-js/reexport.rs @@ -2,6 +2,15 @@ // This is a DWIM case, since renaming the export probably means the intent is also different. // For the de-duplication case of exactly the same name, see reexport-dedup +//@ aux-crate:equivalent=equivalent.rs +//@ compile-flags: --extern equivalent +//@ aux-build:equivalent.rs +//@ build-aux-docs +#[doc(inline)] +pub extern crate equivalent; +#[doc(inline)] +pub use equivalent::Equivalent as NotEquivalent; + pub mod fmt { pub struct Subscriber; } From 7880abac443a7c514026f71129e061e44992c36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 12 Dec 2024 22:55:31 +0100 Subject: [PATCH 02/19] crashes: more tests v2 --- tests/crashes/133426.rs | 12 ++++++++++++ tests/crashes/133597.rs | 11 +++++++++++ tests/crashes/133639.rs | 33 +++++++++++++++++++++++++++++++++ tests/crashes/133808.rs | 15 +++++++++++++++ tests/crashes/133868.rs | 13 +++++++++++++ tests/crashes/133965.rs | 9 +++++++++ tests/crashes/133966.rs | 3 +++ tests/crashes/134005.rs | 5 +++++ tests/crashes/134061.rs | 4 ++++ tests/crashes/134162.rs | 8 ++++++++ tests/crashes/134217.rs | 9 +++++++++ 11 files changed, 122 insertions(+) create mode 100644 tests/crashes/133426.rs create mode 100644 tests/crashes/133597.rs create mode 100644 tests/crashes/133639.rs create mode 100644 tests/crashes/133808.rs create mode 100644 tests/crashes/133868.rs create mode 100644 tests/crashes/133965.rs create mode 100644 tests/crashes/133966.rs create mode 100644 tests/crashes/134005.rs create mode 100644 tests/crashes/134061.rs create mode 100644 tests/crashes/134162.rs create mode 100644 tests/crashes/134217.rs diff --git a/tests/crashes/133426.rs b/tests/crashes/133426.rs new file mode 100644 index 000000000000..307a94c0f6ca --- /dev/null +++ b/tests/crashes/133426.rs @@ -0,0 +1,12 @@ +//@ known-bug: #133426 + +fn a( + _: impl Iterator< + Item = [(); { + match *todo!() { ! }; + }], + >, +) { +} + +fn b(_: impl Iterator) {} diff --git a/tests/crashes/133597.rs b/tests/crashes/133597.rs new file mode 100644 index 000000000000..f716d5e7bc74 --- /dev/null +++ b/tests/crashes/133597.rs @@ -0,0 +1,11 @@ +//@ known-bug: #133597 + +pub trait Foo2 { + fn boxed<'a: 'a>() -> impl Sized + FnOnce<()>; +} + +impl Foo2 for () {} + + +fn f() -> impl FnOnce<()> { || () } +fn main() { () = f(); } diff --git a/tests/crashes/133639.rs b/tests/crashes/133639.rs new file mode 100644 index 000000000000..d522b0730cf8 --- /dev/null +++ b/tests/crashes/133639.rs @@ -0,0 +1,33 @@ +//@ known-bug: #133639 + +#![feature(with_negative_coherence)] +#![feature(min_specialization)] +#![feature(generic_const_exprs)] + +#![crate_type = "lib"] +use std::str::FromStr; + +struct a; + +trait c {} + +impl FromStr for e +where + a<{ d <= 2 }>: c, +{ + type Err = (); + fn from_str(f: &str) -> Result { + unimplemented!() + } +} +struct e; + +impl FromStr for e +where + a<{ d <= 2 }>: c, +{ + type Err = (); + fn from_str(f: &str) -> Result { + unimplemented!() + } +} diff --git a/tests/crashes/133808.rs b/tests/crashes/133808.rs new file mode 100644 index 000000000000..9c6a23d1e35b --- /dev/null +++ b/tests/crashes/133808.rs @@ -0,0 +1,15 @@ +//@ known-bug: #133808 + +#![feature(generic_const_exprs, transmutability)] + +mod assert { + use std::mem::TransmuteFrom; + + pub fn is_transmutable() + where + Dst: TransmuteFrom, + { + } +} + +pub fn main() {} diff --git a/tests/crashes/133868.rs b/tests/crashes/133868.rs new file mode 100644 index 000000000000..dc25cb9df288 --- /dev/null +++ b/tests/crashes/133868.rs @@ -0,0 +1,13 @@ +//@ known-bug: #133868 + +trait Foo { + type Assoc; +} + +trait Bar { + fn method() -> impl Sized; +} +impl Bar for T where ::Assoc: Sized +{ + fn method() {} +} diff --git a/tests/crashes/133965.rs b/tests/crashes/133965.rs new file mode 100644 index 000000000000..69f533ccbe98 --- /dev/null +++ b/tests/crashes/133965.rs @@ -0,0 +1,9 @@ +//@ known-bug: #133965 +//@ needs-rustc-debug-assertions + +struct NonGeneric {} + +#[derive(Default)] +struct NonGeneric<'a, const N: usize> {} + +pub fn main() {} diff --git a/tests/crashes/133966.rs b/tests/crashes/133966.rs new file mode 100644 index 000000000000..25a881ae99b4 --- /dev/null +++ b/tests/crashes/133966.rs @@ -0,0 +1,3 @@ +//@ known-bug: #133966 +pub struct Data([[&'static str]; 5_i32]); +const _: &'static Data = unsafe { &*(&[] as *const Data) }; diff --git a/tests/crashes/134005.rs b/tests/crashes/134005.rs new file mode 100644 index 000000000000..c1f4c758a14e --- /dev/null +++ b/tests/crashes/134005.rs @@ -0,0 +1,5 @@ +//@ known-bug: #134005 + +fn main() { + let _ = [std::ops::Add::add, std::ops::Mul::mul, main as fn(_, &_)]; +} diff --git a/tests/crashes/134061.rs b/tests/crashes/134061.rs new file mode 100644 index 000000000000..e00eb7603fea --- /dev/null +++ b/tests/crashes/134061.rs @@ -0,0 +1,4 @@ +//@ known-bug: #134061 +//@ needs-rustc-debug-assertions + +const x: () = |&'a diff --git a/tests/crashes/134162.rs b/tests/crashes/134162.rs new file mode 100644 index 000000000000..9e5a4a1cb0bf --- /dev/null +++ b/tests/crashes/134162.rs @@ -0,0 +1,8 @@ +//@ known-bug: #134162 + +fn main() { + struct X; + + let xs = [X, X, X]; + let eq = xs == [panic!("panic evaluated"); 2]; +} diff --git a/tests/crashes/134217.rs b/tests/crashes/134217.rs new file mode 100644 index 000000000000..1b14c660e8b4 --- /dev/null +++ b/tests/crashes/134217.rs @@ -0,0 +1,9 @@ +//@ known-bug: #134217 + +impl std::ops::CoerceUnsized for A {} + +fn main() { + if let _ = true + && true + {} +} From 65a54a7f277b30ebeeacb5b303804fa8ffb5c922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 11 Dec 2024 21:17:33 +0000 Subject: [PATCH 03/19] Tweak multispan rendering Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments. --- compiler/rustc_errors/src/emitter.rs | 8 +- .../excessive_nesting.stderr | 3 +- .../clippy/tests/ui/async_yields_async.stderr | 1 - .../shared_at_bottom.stderr | 6 +- .../tests/ui/collapsible_else_if.stderr | 5 -- .../clippy/tests/ui/crashes/ice-360.stderr | 6 -- .../ui/crate_level_checks/no_std_swap.stderr | 3 +- .../tests/ui/doc/unbalanced_ticks.stderr | 4 +- .../ui/empty_line_after/doc_comments.stderr | 5 +- .../empty_line_after/outer_attribute.stderr | 3 +- .../clippy/tests/ui/enum_variants.stderr | 2 - .../clippy/tests/ui/infinite_loops.stderr | 7 +- .../tests/ui/manual_find_fixable.stderr | 36 +++------ .../tests/ui/map_flatten_fixable.stderr | 3 - src/tools/clippy/tests/ui/match_bool.stderr | 3 - .../ui/match_expr_like_matches_macro.stderr | 3 +- .../tests/ui/missing_doc_crate_missing.stderr | 4 +- .../clippy/tests/ui/needless_doc_main.stderr | 14 +--- src/tools/clippy/tests/ui/needless_if.stderr | 1 - src/tools/clippy/tests/ui/never_loop.stderr | 3 - .../clippy/tests/ui/option_if_let_else.stderr | 3 +- .../clippy/tests/ui/question_mark.stderr | 3 +- .../ui/significant_drop_tightening.stderr | 3 +- src/tools/clippy/tests/ui/single_match.stderr | 5 +- .../suspicious_doc_comments_unfixable.stderr | 9 +-- .../tests/ui/temporary_assignment.stderr | 3 +- .../too_long_first_doc_paragraph-fix.stderr | 4 +- .../ui/too_long_first_doc_paragraph.stderr | 7 +- .../tests/ui/unnecessary_lazy_eval.stderr | 3 - .../clippy/tests/ui/vec_init_then_push.stderr | 3 +- ...ustom_code_classes_in_docs-warning3.stderr | 6 -- .../rustdoc-ui/doctest/check-attr-test.stderr | 48 +++--------- .../doctest/private-item-doc-test.stderr | 4 +- .../private-public-item-doc-test.stderr | 4 +- .../doctest/standalone-warning-2024.stderr | 10 +-- tests/rustdoc-ui/invalid-syntax.stderr | 7 +- .../ice-generic-type-alias-105742.stderr | 5 -- tests/rustdoc-ui/lints/check-attr.stderr | 51 +----------- tests/rustdoc-ui/lints/check-fail.stderr | 8 +- tests/rustdoc-ui/lints/lint-group.stderr | 4 +- tests/rustdoc-ui/unescaped_backticks.stderr | 12 --- ...alloc-error-handler-bad-signature-1.stderr | 6 +- .../associated-types-eq-2.stderr | 6 +- tests/ui/associated-types/issue-59324.stderr | 3 +- tests/ui/async-await/issue-84841.stderr | 3 +- .../ui/async-await/issues/issue-72312.stderr | 5 +- .../async-closure-gate.afn.stderr | 3 +- .../async-closure-gate.nofeat.stderr | 3 +- ...issue-109271-pass-self-into-closure.stderr | 2 - .../2229_closure_analysis/issue-88476.stderr | 12 --- .../wild_patterns.stderr | 18 ----- .../huge_multispan_highlight.ascii.svg | 78 +++++++++---------- .../huge_multispan_highlight.unicode.svg | 78 +++++++++---------- .../coercion/coerce-loop-issue-122561.stderr | 3 +- ...const_arg_trivial_macro_expansion-2.stderr | 5 +- .../issues/issue-67945-2.full.stderr | 3 +- .../const-generics/issues/issue-71202.stderr | 1 - .../infinite_loop.eval_limit.stderr | 1 - .../const-eval/infinite_loop.no_ice.stderr | 1 - .../ctfe-simple-loop.allow.stderr | 5 +- .../ctfe-simple-loop.warn.stderr | 15 +--- .../evade-deduplication-issue-118612.stderr | 15 ---- .../drop-tracking-parent-expression.stderr | 6 -- tests/ui/coroutine/parent-expression.stderr | 6 -- .../too-live-local-in-immovable-gen.stderr | 3 - .../ui/coroutine/yield-in-initializer.stderr | 2 - tests/ui/coverage-attr/name-value.stderr | 2 - tests/ui/coverage-attr/word-only.stderr | 2 - .../ui/drop/lint-tail-expr-drop-order.stderr | 36 --------- ...89280-emitter-overflow-splice-lines.stderr | 3 +- tests/ui/expr/if/if-let-arm-types.stderr | 3 +- tests/ui/extern/issue-116203.stderr | 3 +- ...43106-gating-of-builtin-attrs-error.stderr | 5 -- ...issue-43106-gating-of-builtin-attrs.stderr | 1 - .../issue-43106-gating-of-derive.stderr | 2 - tests/ui/for/for-else-err.stderr | 3 +- tests/ui/for/for-else-let-else-err.stderr | 3 +- .../collectivity-regression.stderr | 5 +- ...-predicate-entailment-error.current.stderr | 9 --- tests/ui/issues/issue-18611.stderr | 3 +- tests/ui/issues/issue-51714.stderr | 14 +--- .../issue-76168-hr-outlives-3.stderr | 9 --- tests/ui/lifetimes/issue-97194.stderr | 5 +- tests/ui/lint/non-local-defs/consts.stderr | 1 - .../ui/lint/non-local-defs/weird-exprs.stderr | 5 -- .../loops/dont-suggest-break-thru-item.stderr | 6 +- tests/ui/loops/loop-else-err.stderr | 3 +- tests/ui/loops/loop-else-let-else-err.stderr | 3 +- .../lub-glb/old-lub-glb-hr-noteq1.leak.stderr | 3 +- tests/ui/macros/issue-112342-1.stderr | 3 +- .../ui/match/match-type-err-first-arm.stderr | 3 +- ...oximated-shorter-to-static-no-bound.stderr | 5 +- ...mated-shorter-to-static-wrong-bound.stderr | 5 +- tests/ui/nll/snocat-regression.stderr | 5 +- tests/ui/parser/fn-arg-doc-comment.stderr | 8 +- .../issue-86188-return-not-in-fn-body.stderr | 6 +- .../ui/return/return-match-array-const.stderr | 10 +-- .../tail-expr-as-potential-return.stderr | 9 +-- ...-unadorned-extern-block.edition2024.stderr | 3 +- .../min_specialization/issue-79224.stderr | 5 +- ...missing-stability-attr-at-top-level.stderr | 3 +- tests/ui/static/issue-24446.stderr | 10 +-- .../ui/suggestions/if-then-neeing-semi.stderr | 12 +-- .../match-prev-arm-needing-semi.stderr | 9 +-- ...try-operator-dont-suggest-semicolon.stderr | 3 +- .../ice-120503-async-const-method.stderr | 6 -- .../const_generic_type.no_infer.stderr | 5 +- .../hidden_type_mismatch.stderr | 3 +- .../hkl_forbidden4.stderr | 6 +- tests/ui/while/while-else-err.stderr | 3 +- tests/ui/while/while-else-let-else-err.stderr | 3 +- 111 files changed, 206 insertions(+), 653 deletions(-) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 1b6c6edcc614..9595790d574c 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -3048,11 +3048,15 @@ impl FileWithAnnotatedLines { // working correctly. let middle = min(ann.line_start + 4, ann.line_end); // We'll show up to 4 lines past the beginning of the multispan start. - // We will *not* include the tail of lines that are only whitespace. + // We will *not* include the tail of lines that are only whitespace, a comment or + // a bare delimiter. let until = (ann.line_start..middle) .rev() .filter_map(|line| file.get_line(line - 1).map(|s| (line + 1, s))) - .find(|(_, s)| !s.trim().is_empty()) + .find(|(_, s)| { + let s = s.trim(); + !["", "{", "}", "(", ")", "[", "]"].contains(&s) && !s.starts_with("//") + }) .map(|(line, _)| line) .unwrap_or(ann.line_start); for line in ann.line_start + 1..until { diff --git a/src/tools/clippy/tests/ui-toml/excessive_nesting/excessive_nesting.stderr b/src/tools/clippy/tests/ui-toml/excessive_nesting/excessive_nesting.stderr index ccdaecdd4817..9cf6fc66757d 100644 --- a/src/tools/clippy/tests/ui-toml/excessive_nesting/excessive_nesting.stderr +++ b/src/tools/clippy/tests/ui-toml/excessive_nesting/excessive_nesting.stderr @@ -66,8 +66,7 @@ error: this block is too nested LL | if true { | _________________________^ LL | | if true { -LL | | -LL | | } +... | LL | | } | |_________________^ | diff --git a/src/tools/clippy/tests/ui/async_yields_async.stderr b/src/tools/clippy/tests/ui/async_yields_async.stderr index 861c3f2ce4a5..54baa69a035d 100644 --- a/src/tools/clippy/tests/ui/async_yields_async.stderr +++ b/src/tools/clippy/tests/ui/async_yields_async.stderr @@ -80,7 +80,6 @@ error: an async construct yields a type which is itself awaitable LL | let _m = async || { | _______________________- LL | | println!("I'm bored"); -LL | | // Some more stuff ... | LL | | CustomFutureType | | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_bottom.stderr b/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_bottom.stderr index 68ebb6ad7811..36b177739732 100644 --- a/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_bottom.stderr +++ b/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_bottom.stderr @@ -115,8 +115,7 @@ error: all if blocks contain the same code at the end --> tests/ui/branches_sharing_code/shared_at_bottom.rs:183:5 | LL | / x << 2 -LL | | -LL | | +... | LL | | }; | |_____^ | @@ -131,8 +130,7 @@ error: all if blocks contain the same code at the end --> tests/ui/branches_sharing_code/shared_at_bottom.rs:192:5 | LL | / x * 4 -LL | | -LL | | +... | LL | | } | |_____^ | diff --git a/src/tools/clippy/tests/ui/collapsible_else_if.stderr b/src/tools/clippy/tests/ui/collapsible_else_if.stderr index 395c2dcf68dc..c27a2967f3c2 100644 --- a/src/tools/clippy/tests/ui/collapsible_else_if.stderr +++ b/src/tools/clippy/tests/ui/collapsible_else_if.stderr @@ -43,7 +43,6 @@ LL | } else { | ____________^ LL | | if y == "world" { LL | | println!("world") -LL | | } ... | LL | | } LL | | } @@ -66,7 +65,6 @@ LL | } else { | ____________^ LL | | if let Some(42) = Some(42) { LL | | println!("world") -LL | | } ... | LL | | } LL | | } @@ -89,7 +87,6 @@ LL | } else { | ____________^ LL | | if let Some(42) = Some(42) { LL | | println!("world") -LL | | } ... | LL | | } LL | | } @@ -112,7 +109,6 @@ LL | } else { | ____________^ LL | | if x == "hello" { LL | | println!("world") -LL | | } ... | LL | | } LL | | } @@ -135,7 +131,6 @@ LL | } else { | ____________^ LL | | if let Some(42) = Some(42) { LL | | println!("world") -LL | | } ... | LL | | } LL | | } diff --git a/src/tools/clippy/tests/ui/crashes/ice-360.stderr b/src/tools/clippy/tests/ui/crashes/ice-360.stderr index 50b245c65cde..d37e0216edf4 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-360.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-360.stderr @@ -2,9 +2,6 @@ error: this loop never actually loops --> tests/ui/crashes/ice-360.rs:5:5 | LL | / loop { -LL | | -LL | | -LL | | ... | LL | | LL | | } @@ -16,9 +13,6 @@ error: this loop could be written as a `while let` loop --> tests/ui/crashes/ice-360.rs:5:5 | LL | / loop { -LL | | -LL | | -LL | | ... | LL | | LL | | } diff --git a/src/tools/clippy/tests/ui/crate_level_checks/no_std_swap.stderr b/src/tools/clippy/tests/ui/crate_level_checks/no_std_swap.stderr index 7d7922ae8cac..bcc8684f7c2b 100644 --- a/src/tools/clippy/tests/ui/crate_level_checks/no_std_swap.stderr +++ b/src/tools/clippy/tests/ui/crate_level_checks/no_std_swap.stderr @@ -2,8 +2,7 @@ error: this looks like you are trying to swap `a` and `b` --> tests/ui/crate_level_checks/no_std_swap.rs:12:5 | LL | / a = b; -LL | | -LL | | +... | LL | | b = a; | |_________^ help: try: `core::mem::swap(&mut a, &mut b)` | diff --git a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr index 50324010e97f..3bcf65c4595d 100644 --- a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr +++ b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr @@ -3,9 +3,7 @@ error: backticks are unbalanced | LL | /// This is a doc comment with `unbalanced_tick marks and several words that | _____^ -LL | | -LL | | /// should be `encompassed_by` tick marks because they `contain_underscores`. -LL | | /// Because of the initial `unbalanced_tick` pair, the error message is +... | LL | | /// very `confusing_and_misleading`. | |____________________________________^ | diff --git a/src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr b/src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr index 2852e26680f6..475a817eff9a 100644 --- a/src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr +++ b/src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr @@ -96,10 +96,7 @@ error: empty lines after doc comment --> tests/ui/empty_line_after/doc_comments.rs:63:5 | LL | / /// for OldA -LL | | // struct OldA; -LL | | -LL | | /// Docs -LL | | /// for OldB +... | LL | | // struct OldB; LL | | | |_^ diff --git a/src/tools/clippy/tests/ui/empty_line_after/outer_attribute.stderr b/src/tools/clippy/tests/ui/empty_line_after/outer_attribute.stderr index 75fc23e9e7eb..a95306e2fa33 100644 --- a/src/tools/clippy/tests/ui/empty_line_after/outer_attribute.stderr +++ b/src/tools/clippy/tests/ui/empty_line_after/outer_attribute.stderr @@ -103,8 +103,7 @@ error: empty lines after outer attribute --> tests/ui/empty_line_after/outer_attribute.rs:64:1 | LL | / #[allow(unused)] -LL | | -LL | | // This comment is isolated +... | LL | | | |_^ LL | pub fn isolated_comment() {} diff --git a/src/tools/clippy/tests/ui/enum_variants.stderr b/src/tools/clippy/tests/ui/enum_variants.stderr index aaac3cbb82dc..c118ac80a92b 100644 --- a/src/tools/clippy/tests/ui/enum_variants.stderr +++ b/src/tools/clippy/tests/ui/enum_variants.stderr @@ -13,7 +13,6 @@ error: all variants have the same prefix: `c` LL | / enum Foo { LL | | LL | | cFoo, -LL | | ... | LL | | cBaz, LL | | } @@ -45,7 +44,6 @@ error: all variants have the same prefix: `Food` LL | / enum Food { LL | | LL | | FoodGood, -LL | | ... | LL | | LL | | } diff --git a/src/tools/clippy/tests/ui/infinite_loops.stderr b/src/tools/clippy/tests/ui/infinite_loops.stderr index 3a3ed7d0fe8f..5b5cd78108e4 100644 --- a/src/tools/clippy/tests/ui/infinite_loops.stderr +++ b/src/tools/clippy/tests/ui/infinite_loops.stderr @@ -20,7 +20,6 @@ error: infinite loop detected LL | / loop { LL | | LL | | loop { -LL | | ... | LL | | do_something(); LL | | } @@ -37,8 +36,7 @@ error: infinite loop detected LL | / loop { LL | | LL | | loop { -LL | | -LL | | do_something(); +... | LL | | } LL | | } | |_________^ @@ -79,8 +77,7 @@ error: infinite loop detected LL | / loop { LL | | fn inner_fn() -> ! { LL | | std::process::exit(0); -LL | | } -LL | | do_something(); +... | LL | | } | |_____^ | diff --git a/src/tools/clippy/tests/ui/manual_find_fixable.stderr b/src/tools/clippy/tests/ui/manual_find_fixable.stderr index c3f48fb9f98a..5ed8be1b3eed 100644 --- a/src/tools/clippy/tests/ui/manual_find_fixable.stderr +++ b/src/tools/clippy/tests/ui/manual_find_fixable.stderr @@ -4,8 +4,7 @@ error: manual implementation of `Iterator::find` LL | / for &v in ARRAY { LL | | if v == n { LL | | return Some(v); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `ARRAY.iter().find(|&&v| v == n).copied()` | @@ -18,8 +17,7 @@ error: manual implementation of `Iterator::find` LL | / for (a, _) in arr { LL | | if a % 2 == 0 { LL | | return Some(a); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `arr.into_iter().map(|(a, _)| a).find(|&a| a % 2 == 0)` @@ -29,8 +27,7 @@ error: manual implementation of `Iterator::find` LL | / for el in arr { LL | | if el.name.len() == 10 { LL | | return Some(el); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `arr.into_iter().find(|el| el.name.len() == 10)` | @@ -42,8 +39,7 @@ error: manual implementation of `Iterator::find` LL | / for Tuple(a, _) in arr { LL | | if a >= 3 { LL | | return Some(a); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `arr.into_iter().map(|Tuple(a, _)| a).find(|&a| a >= 3)` @@ -53,8 +49,7 @@ error: manual implementation of `Iterator::find` LL | / for el in arr { LL | | if el.should_keep() { LL | | return Some(el); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `arr.into_iter().find(|el| el.should_keep())` | @@ -66,8 +61,7 @@ error: manual implementation of `Iterator::find` LL | / for el in arr { LL | | if f(el) == 20 { LL | | return Some(el); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `arr.into_iter().find(|&el| f(el) == 20)` @@ -77,8 +71,7 @@ error: manual implementation of `Iterator::find` LL | / for &el in arr.values() { LL | | if f(el) { LL | | return Some(el); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `arr.values().find(|&&el| f(el)).copied()` @@ -88,8 +81,7 @@ error: manual implementation of `Iterator::find` LL | / for el in arr { LL | | if el.is_true { LL | | return Some(el); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `arr.into_iter().find(|el| el.is_true)` | @@ -101,8 +93,7 @@ error: manual implementation of `Iterator::find` LL | / for (_, &x) in v { LL | | if x > 10 { LL | | return Some(x); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `v.into_iter().map(|(_, &x)| x).find(|&x| x > 10)` @@ -112,8 +103,7 @@ error: manual implementation of `Iterator::find` LL | / for &(_, &x) in v { LL | | if x > 10 { LL | | return Some(x); -LL | | } -LL | | } +... | LL | | None | |________^ help: replace with an iterator: `v.iter().map(|&(_, &x)| x).find(|&x| x > 10)` @@ -123,8 +113,7 @@ error: manual implementation of `Iterator::find` LL | / for x in arr { LL | | if x >= 5 { LL | | return Some(x); -LL | | } -LL | | } +... | LL | | return None; | |________________^ help: replace with an iterator: `arr.into_iter().find(|&x| x >= 5)` @@ -134,8 +123,7 @@ error: manual implementation of `Iterator::find` LL | / for x in arr { LL | | if x < 1 { LL | | return Some(x); -LL | | } -LL | | } +... | LL | | None | |____________^ help: replace with an iterator: `arr.into_iter().find(|&x| x < 1)` diff --git a/src/tools/clippy/tests/ui/map_flatten_fixable.stderr b/src/tools/clippy/tests/ui/map_flatten_fixable.stderr index 128c95146aa2..095bee52d6d7 100644 --- a/src/tools/clippy/tests/ui/map_flatten_fixable.stderr +++ b/src/tools/clippy/tests/ui/map_flatten_fixable.stderr @@ -77,9 +77,6 @@ error: called `map(..).flatten()` on `Option` | LL | .map(|_| { | __________^ -LL | | // we need some newlines -LL | | // so that the span is big enough -LL | | // for a split output of the diagnostic ... | LL | | }) LL | | .flatten(); diff --git a/src/tools/clippy/tests/ui/match_bool.stderr b/src/tools/clippy/tests/ui/match_bool.stderr index 1303e082daf2..fb24e67eceef 100644 --- a/src/tools/clippy/tests/ui/match_bool.stderr +++ b/src/tools/clippy/tests/ui/match_bool.stderr @@ -75,9 +75,6 @@ error: you seem to be trying to match on a boolean expression --> tests/ui/match_bool.rs:36:5 | LL | / match test && test { -LL | | -LL | | -LL | | ... | LL | | _ => (), LL | | }; diff --git a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr index 201b977e558e..ffe5772ece90 100644 --- a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr +++ b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr @@ -68,8 +68,7 @@ LL | let _ans = match x { | ____________________^ LL | | E::A(_) => { LL | | true -LL | | } -LL | | E::B(_) => true, +... | LL | | _ => false, LL | | }; | |_________^ help: try: `matches!(x, E::A(_) | E::B(_))` diff --git a/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr b/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr index a421fb986d3a..d6a4342c5031 100644 --- a/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr +++ b/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr @@ -2,9 +2,7 @@ error: missing documentation for the crate --> tests/ui/missing_doc_crate_missing.rs:1:1 | LL | / #![warn(clippy::missing_docs_in_private_items)] -LL | | -LL | | -LL | | +... | LL | | fn main() {} | |____________^ | diff --git a/src/tools/clippy/tests/ui/needless_doc_main.stderr b/src/tools/clippy/tests/ui/needless_doc_main.stderr index 7e362cf377ce..cfb389801db0 100644 --- a/src/tools/clippy/tests/ui/needless_doc_main.stderr +++ b/src/tools/clippy/tests/ui/needless_doc_main.stderr @@ -3,9 +3,7 @@ error: needless `fn main` in doctest | LL | /// fn main() { | _____^ -LL | | -LL | | -LL | | /// unimplemented!(); +... | LL | | /// } | |_____^ | @@ -17,8 +15,7 @@ error: needless `fn main` in doctest | LL | /// fn main() -> () { | _____^ -LL | | -LL | | /// unimplemented!(); +... | LL | | /// } | |_____^ @@ -27,8 +24,7 @@ error: needless `fn main` in doctest | LL | /// fn main() { | _____^ -LL | | -LL | | /// unimplemented!(); +... | LL | | /// } | |_____^ @@ -37,9 +33,7 @@ error: needless `fn main` in doctest | LL | /// // the fn is not always the first line | _____^ -LL | | -LL | | /// fn main() { -LL | | /// unimplemented!(); +... | LL | | /// } | |_____^ diff --git a/src/tools/clippy/tests/ui/needless_if.stderr b/src/tools/clippy/tests/ui/needless_if.stderr index 9beae596ee39..cbfeb979d2f2 100644 --- a/src/tools/clippy/tests/ui/needless_if.stderr +++ b/src/tools/clippy/tests/ui/needless_if.stderr @@ -34,7 +34,6 @@ error: this `if` branch is empty LL | / if { LL | | if let true = true LL | | && true -LL | | { ... | LL | | } && true LL | | {} diff --git a/src/tools/clippy/tests/ui/never_loop.stderr b/src/tools/clippy/tests/ui/never_loop.stderr index 440a2b5aabaa..bd9bdc4addbb 100644 --- a/src/tools/clippy/tests/ui/never_loop.stderr +++ b/src/tools/clippy/tests/ui/never_loop.stderr @@ -2,9 +2,6 @@ error: this loop never actually loops --> tests/ui/never_loop.rs:12:5 | LL | / loop { -LL | | -LL | | -LL | | // clippy::never_loop ... | LL | | break; LL | | } diff --git a/src/tools/clippy/tests/ui/option_if_let_else.stderr b/src/tools/clippy/tests/ui/option_if_let_else.stderr index 37ef791edb00..32ff22763234 100644 --- a/src/tools/clippy/tests/ui/option_if_let_else.stderr +++ b/src/tools/clippy/tests/ui/option_if_let_else.stderr @@ -115,8 +115,7 @@ LL | let _ = if let Some(x) = arg { | _____________^ LL | | x LL | | } else { -LL | | // map_or_else must be suggested -LL | | side_effect() +... | LL | | }; | |_____^ help: try: `arg.map_or_else(side_effect, |x| x)` diff --git a/src/tools/clippy/tests/ui/question_mark.stderr b/src/tools/clippy/tests/ui/question_mark.stderr index 0a48c4e80cb6..06a8bd0de349 100644 --- a/src/tools/clippy/tests/ui/question_mark.stderr +++ b/src/tools/clippy/tests/ui/question_mark.stderr @@ -183,8 +183,7 @@ error: this block may be rewritten with the `?` operator | LL | / if a.is_none() { LL | | return None; -LL | | // do lint here, the outer `try` is not relevant here -LL | | // https://github.com/rust-lang/rust-clippy/pull/11001#issuecomment-1610636867 +... | LL | | } | |_____________^ help: replace it with: `a?;` diff --git a/src/tools/clippy/tests/ui/significant_drop_tightening.stderr b/src/tools/clippy/tests/ui/significant_drop_tightening.stderr index 2d7da4f394d3..7d7e3ac7d0ae 100644 --- a/src/tools/clippy/tests/ui/significant_drop_tightening.stderr +++ b/src/tools/clippy/tests/ui/significant_drop_tightening.stderr @@ -5,8 +5,7 @@ LL | pub fn complex_return_triggers_the_lint() -> i32 { | __________________________________________________- LL | | fn foo() -> i32 { LL | | 1 -LL | | } -LL | | let mutex = Mutex::new(1); +... | LL | | let lock = mutex.lock().unwrap(); | | ^^^^ ... | diff --git a/src/tools/clippy/tests/ui/single_match.stderr b/src/tools/clippy/tests/ui/single_match.stderr index 9240b09c50a9..dd03737279ad 100644 --- a/src/tools/clippy/tests/ui/single_match.stderr +++ b/src/tools/clippy/tests/ui/single_match.stderr @@ -22,10 +22,7 @@ error: you seem to be trying to use `match` for destructuring a single pattern. --> tests/ui/single_match.rs:23:5 | LL | / match x { -LL | | // Note the missing block braces. -LL | | // We suggest `if let Some(y) = x { .. }` because the macro -LL | | // is expanded before we can do anything. -LL | | Some(y) => println!("{:?}", y), +... | LL | | _ => (), LL | | } | |_____^ help: try: `if let Some(y) = x { println!("{:?}", y) }` diff --git a/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr b/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr index d15f16f7c503..2209a63d2c0f 100644 --- a/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr +++ b/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr @@ -2,10 +2,7 @@ error: this is an outer doc comment and does not apply to the parent module or c --> tests/ui/suspicious_doc_comments_unfixable.rs:4:1 | LL | / ///! a -LL | | -LL | | -LL | | ///! b -LL | | /// c +... | LL | | ///! d | |______^ | @@ -25,9 +22,7 @@ error: this is an outer doc comment and does not apply to the parent module or c --> tests/ui/suspicious_doc_comments_unfixable.rs:12:1 | LL | / ///! a -LL | | -LL | | ///! b -LL | | /// c +... | LL | | ///! d | |______^ | diff --git a/src/tools/clippy/tests/ui/temporary_assignment.stderr b/src/tools/clippy/tests/ui/temporary_assignment.stderr index 8c2845940757..7e6529cb2134 100644 --- a/src/tools/clippy/tests/ui/temporary_assignment.stderr +++ b/src/tools/clippy/tests/ui/temporary_assignment.stderr @@ -13,8 +13,7 @@ error: assignment to temporary LL | / MultiStruct { LL | | LL | | structure: Struct { field: 0 }, -LL | | } -LL | | .structure +... | LL | | .field = 1; | |______________^ diff --git a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr index 6ef333f0cfd2..5925d2f902a7 100644 --- a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr +++ b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr @@ -2,9 +2,7 @@ error: first doc comment paragraph is too long --> tests/ui/too_long_first_doc_paragraph-fix.rs:3:1 | LL | / /// A very short summary. -LL | | /// A much longer explanation that goes into a lot more detail about -LL | | /// how the thing works, possibly with doclinks and so one, -LL | | /// and probably spanning a many rows. Blablabla, it needs to be over +... | LL | | /// 200 characters so I needed to write something longeeeeeeer. | |_^ | diff --git a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr index 95f42349b9b3..c40ee2fcb48f 100644 --- a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr +++ b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr @@ -2,9 +2,7 @@ error: first doc comment paragraph is too long --> tests/ui/too_long_first_doc_paragraph.rs:8:5 | LL | / //! A very short summary. -LL | | //! A much longer explanation that goes into a lot more detail about -LL | | //! how the thing works, possibly with doclinks and so one, -LL | | //! and probably spanning a many rows. Blablabla, it needs to be over +... | LL | | //! 200 characters so I needed to write something longeeeeeeer. | |____^ | @@ -29,8 +27,7 @@ error: first doc comment paragraph is too long --> tests/ui/too_long_first_doc_paragraph.rs:36:1 | LL | / /// Lorem -LL | | /// ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia -LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero, +... | LL | | /// gravida non lacinia at, rhoncus eu lacus. | |_^ diff --git a/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr b/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr index bcdf65b217e5..27c064b8b7fe 100644 --- a/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr @@ -434,9 +434,6 @@ error: unnecessary closure used to substitute value for `Result::Err` | LL | let _: Result = res. | ___________________________________^ -LL | | // some lines -LL | | // some lines -LL | | // some lines ... | LL | | // some lines LL | | or_else(|_| Ok(ext_str.some_field)); diff --git a/src/tools/clippy/tests/ui/vec_init_then_push.stderr b/src/tools/clippy/tests/ui/vec_init_then_push.stderr index 58720c9a1813..f35625c9b085 100644 --- a/src/tools/clippy/tests/ui/vec_init_then_push.stderr +++ b/src/tools/clippy/tests/ui/vec_init_then_push.stderr @@ -2,8 +2,7 @@ error: calls to `push` immediately after creation --> tests/ui/vec_init_then_push.rs:5:5 | LL | / let mut def_err: Vec = Default::default(); -LL | | -LL | | +... | LL | | def_err.push(0); | |____________________^ help: consider using the `vec![]` macro: `let def_err: Vec = vec![..];` | diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr index fc47404734ee..829be4805a53 100644 --- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr @@ -2,9 +2,6 @@ error: unclosed quote string `"` --> $DIR/custom_code_classes_in_docs-warning3.rs:8:1 | LL | / /// ```{class="} -LL | | /// main; -LL | | /// ``` -LL | | ... | LL | | /// main; LL | | /// ``` @@ -21,9 +18,6 @@ error: unclosed quote string `"` --> $DIR/custom_code_classes_in_docs-warning3.rs:8:1 | LL | / /// ```{class="} -LL | | /// main; -LL | | /// ``` -LL | | ... | LL | | /// main; LL | | /// ``` diff --git a/tests/rustdoc-ui/doctest/check-attr-test.stderr b/tests/rustdoc-ui/doctest/check-attr-test.stderr index 257136d1633d..2703885b1841 100644 --- a/tests/rustdoc-ui/doctest/check-attr-test.stderr +++ b/tests/rustdoc-ui/doctest/check-attr-test.stderr @@ -2,9 +2,7 @@ error: unknown attribute `compile-fail` --> $DIR/check-attr-test.rs:5:1 | 5 | / /// foo -6 | | /// -7 | | /// ```compile-fail,compilefail,comPile_fail -8 | | /// boo +... | 9 | | /// ``` | |_______^ | @@ -20,9 +18,7 @@ error: unknown attribute `compilefail` --> $DIR/check-attr-test.rs:5:1 | 5 | / /// foo -6 | | /// -7 | | /// ```compile-fail,compilefail,comPile_fail -8 | | /// boo +... | 9 | | /// ``` | |_______^ | @@ -33,9 +29,7 @@ error: unknown attribute `comPile_fail` --> $DIR/check-attr-test.rs:5:1 | 5 | / /// foo -6 | | /// -7 | | /// ```compile-fail,compilefail,comPile_fail -8 | | /// boo +... | 9 | | /// ``` | |_______^ | @@ -46,9 +40,7 @@ error: unknown attribute `should-panic` --> $DIR/check-attr-test.rs:12:1 | 12 | / /// bar -13 | | /// -14 | | /// ```should-panic,shouldpanic,shOuld_panic -15 | | /// boo +... | 16 | | /// ``` | |_______^ | @@ -59,9 +51,7 @@ error: unknown attribute `shouldpanic` --> $DIR/check-attr-test.rs:12:1 | 12 | / /// bar -13 | | /// -14 | | /// ```should-panic,shouldpanic,shOuld_panic -15 | | /// boo +... | 16 | | /// ``` | |_______^ | @@ -72,9 +62,7 @@ error: unknown attribute `shOuld_panic` --> $DIR/check-attr-test.rs:12:1 | 12 | / /// bar -13 | | /// -14 | | /// ```should-panic,shouldpanic,shOuld_panic -15 | | /// boo +... | 16 | | /// ``` | |_______^ | @@ -85,9 +73,7 @@ error: unknown attribute `no-run` --> $DIR/check-attr-test.rs:19:1 | 19 | / /// foobar -20 | | /// -21 | | /// ```no-run,norun,nO_run -22 | | /// boo +... | 23 | | /// ``` | |_______^ | @@ -98,9 +84,7 @@ error: unknown attribute `norun` --> $DIR/check-attr-test.rs:19:1 | 19 | / /// foobar -20 | | /// -21 | | /// ```no-run,norun,nO_run -22 | | /// boo +... | 23 | | /// ``` | |_______^ | @@ -111,9 +95,7 @@ error: unknown attribute `nO_run` --> $DIR/check-attr-test.rs:19:1 | 19 | / /// foobar -20 | | /// -21 | | /// ```no-run,norun,nO_run -22 | | /// boo +... | 23 | | /// ``` | |_______^ | @@ -124,9 +106,7 @@ error: unknown attribute `test-harness` --> $DIR/check-attr-test.rs:26:1 | 26 | / /// b -27 | | /// -28 | | /// ```test-harness,testharness,tesT_harness -29 | | /// boo +... | 30 | | /// ``` | |_______^ | @@ -137,9 +117,7 @@ error: unknown attribute `testharness` --> $DIR/check-attr-test.rs:26:1 | 26 | / /// b -27 | | /// -28 | | /// ```test-harness,testharness,tesT_harness -29 | | /// boo +... | 30 | | /// ``` | |_______^ | @@ -150,9 +128,7 @@ error: unknown attribute `tesT_harness` --> $DIR/check-attr-test.rs:26:1 | 26 | / /// b -27 | | /// -28 | | /// ```test-harness,testharness,tesT_harness -29 | | /// boo +... | 30 | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/doctest/private-item-doc-test.stderr b/tests/rustdoc-ui/doctest/private-item-doc-test.stderr index 5177057c7284..7ce1f0314991 100644 --- a/tests/rustdoc-ui/doctest/private-item-doc-test.stderr +++ b/tests/rustdoc-ui/doctest/private-item-doc-test.stderr @@ -2,9 +2,7 @@ error: documentation test in private item --> $DIR/private-item-doc-test.rs:4:5 | LL | / /// private doc test -LL | | /// -LL | | /// ``` -LL | | /// assert!(false); +... | LL | | /// ``` | |___________^ | diff --git a/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr b/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr index 38b8dd652d3e..aa01f39314c9 100644 --- a/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr +++ b/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr @@ -2,9 +2,7 @@ error: documentation test in private item --> $DIR/private-public-item-doc-test.rs:4:5 | LL | / /// private doc test -LL | | /// -LL | | /// ``` -LL | | /// assert!(false); +... | LL | | /// ``` | |___________^ | diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr index bfc1e9194045..02b6c6ee43c4 100644 --- a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr +++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr @@ -2,10 +2,7 @@ error: unknown attribute `standalone` --> $DIR/standalone-warning-2024.rs:11:1 | 11 | / //! ```standalone -12 | | //! bla -13 | | //! ``` -14 | | //! -15 | | //! ```standalone-crate +... | 16 | | //! bla 17 | | //! ``` | |_______^ @@ -23,10 +20,7 @@ error: unknown attribute `standalone-crate` --> $DIR/standalone-warning-2024.rs:11:1 | 11 | / //! ```standalone -12 | | //! bla -13 | | //! ``` -14 | | //! -15 | | //! ```standalone-crate +... | 16 | | //! bla 17 | | //! ``` | |_______^ diff --git a/tests/rustdoc-ui/invalid-syntax.stderr b/tests/rustdoc-ui/invalid-syntax.stderr index c6e1f6fd4138..f30660017d9d 100644 --- a/tests/rustdoc-ui/invalid-syntax.stderr +++ b/tests/rustdoc-ui/invalid-syntax.stderr @@ -21,9 +21,7 @@ warning: could not parse code block as Rust code | LL | /// ``` | _____^ -LL | | /// | -LL | | /// LL | use foobar::Baz; -LL | | /// | ^^^^^^ did you mean `baz::foobar`? +... | LL | | /// ``` | |_______^ | @@ -114,8 +112,7 @@ warning: Rust code block is empty | LL | /// ``` | _____^ -LL | | /// -LL | | /// +... | LL | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr index 06a1cf6b118d..5a718f46d952 100644 --- a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr +++ b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr @@ -308,13 +308,8 @@ LL | pub trait SVec: Index< | | | | | this trait cannot be made into an object... LL | | ::Item, -LL | | -LL | | ... | LL | |/ Output = ::Item, -LL | || -LL | || -LL | || ... || LL | || LL | || Output = ::Item> as SVec>::Item, diff --git a/tests/rustdoc-ui/lints/check-attr.stderr b/tests/rustdoc-ui/lints/check-attr.stderr index e23806e0bab9..c45e94d9566e 100644 --- a/tests/rustdoc-ui/lints/check-attr.stderr +++ b/tests/rustdoc-ui/lints/check-attr.stderr @@ -2,9 +2,6 @@ error: unknown attribute `compile-fail` --> $DIR/check-attr.rs:3:1 | LL | / /// foo -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -22,9 +19,6 @@ error: unknown attribute `compilefail` --> $DIR/check-attr.rs:3:1 | LL | / /// foo -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -37,9 +31,6 @@ error: unknown attribute `comPile_fail` --> $DIR/check-attr.rs:3:1 | LL | / /// foo -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -52,9 +43,6 @@ error: unknown attribute `should-panic` --> $DIR/check-attr.rs:13:1 | LL | / /// bar -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -67,9 +55,6 @@ error: unknown attribute `shouldpanic` --> $DIR/check-attr.rs:13:1 | LL | / /// bar -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -82,9 +67,6 @@ error: unknown attribute `sHould_panic` --> $DIR/check-attr.rs:13:1 | LL | / /// bar -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -97,9 +79,6 @@ error: unknown attribute `no-run` --> $DIR/check-attr.rs:23:1 | LL | / /// foobar -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -112,9 +91,6 @@ error: unknown attribute `norun` --> $DIR/check-attr.rs:23:1 | LL | / /// foobar -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -127,9 +103,6 @@ error: unknown attribute `no_Run` --> $DIR/check-attr.rs:23:1 | LL | / /// foobar -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -142,9 +115,6 @@ error: unknown attribute `test-harness` --> $DIR/check-attr.rs:33:1 | LL | / /// b -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -157,9 +127,6 @@ error: unknown attribute `testharness` --> $DIR/check-attr.rs:33:1 | LL | / /// b -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -172,9 +139,6 @@ error: unknown attribute `teSt_harness` --> $DIR/check-attr.rs:33:1 | LL | / /// b -LL | | -LL | | -LL | | ... | LL | | /// boo LL | | /// ``` @@ -187,10 +151,7 @@ error: unknown attribute `rust2018` --> $DIR/check-attr.rs:43:1 | LL | / /// b -LL | | -LL | | /// -LL | | /// ```rust2018 -LL | | /// boo +... | LL | | /// ``` | |_______^ | @@ -200,10 +161,7 @@ error: unknown attribute `rust2018` --> $DIR/check-attr.rs:51:1 | LL | / /// b -LL | | -LL | | -LL | | /// -LL | | /// ```rust2018 shouldpanic +... | LL | | /// boo LL | | /// ``` | |_______^ @@ -214,10 +172,7 @@ error: unknown attribute `shouldpanic` --> $DIR/check-attr.rs:51:1 | LL | / /// b -LL | | -LL | | -LL | | /// -LL | | /// ```rust2018 shouldpanic +... | LL | | /// boo LL | | /// ``` | |_______^ diff --git a/tests/rustdoc-ui/lints/check-fail.stderr b/tests/rustdoc-ui/lints/check-fail.stderr index 2eb9496e5dc9..f021f0c42e5a 100644 --- a/tests/rustdoc-ui/lints/check-fail.stderr +++ b/tests/rustdoc-ui/lints/check-fail.stderr @@ -26,8 +26,7 @@ error: unknown attribute `testharness` --> $DIR/check-fail.rs:8:1 | LL | / //! ```rust,testharness -LL | | -LL | | //! let x = 12; +... | LL | | //! ``` | |_______^ | @@ -44,10 +43,7 @@ error: unknown attribute `testharness` --> $DIR/check-fail.rs:17:1 | LL | / /// hello -LL | | -LL | | /// -LL | | /// ```rust,testharness -LL | | /// let x = 12; +... | LL | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/lints/lint-group.stderr b/tests/rustdoc-ui/lints/lint-group.stderr index 7ff09fcc45a1..4b5b64c4378f 100644 --- a/tests/rustdoc-ui/lints/lint-group.stderr +++ b/tests/rustdoc-ui/lints/lint-group.stderr @@ -14,9 +14,7 @@ error: documentation test in private item --> $DIR/lint-group.rs:22:1 | LL | / /// wait, this *does* have a doctest? -LL | | /// -LL | | /// ``` -LL | | /// println!("sup"); +... | LL | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/unescaped_backticks.stderr b/tests/rustdoc-ui/unescaped_backticks.stderr index 1e2b3528d4af..d93aaf5f3ca9 100644 --- a/tests/rustdoc-ui/unescaped_backticks.stderr +++ b/tests/rustdoc-ui/unescaped_backticks.stderr @@ -271,9 +271,6 @@ error: unescaped backtick --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], -LL | | -LL | | -LL | | ... | LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max LL | | /// level changes. @@ -290,9 +287,6 @@ error: unescaped backtick --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], -LL | | -LL | | -LL | | ... | LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max LL | | /// level changes. @@ -307,9 +301,6 @@ error: unescaped backtick --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], -LL | | -LL | | -LL | | ... | LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max LL | | /// level changes. @@ -326,9 +317,6 @@ error: unescaped backtick --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], -LL | | -LL | | -LL | | ... | LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max LL | | /// level changes. diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr index de92841d7f18..80ff10e13d88 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr @@ -7,8 +7,7 @@ LL | // fn oom( LL | || info: &Layout, LL | || ) -> () | ||_______- arguments to this function are incorrect -LL | | { -LL | | loop {} +... | LL | | } | |__^ expected `&Layout`, found `Layout` | @@ -30,8 +29,7 @@ LL | // fn oom( LL | || info: &Layout, LL | || ) -> () | ||_______^ expected `!`, found `()` -LL | | { -LL | | loop {} +... | LL | | } | |__- expected `!` because of return type | diff --git a/tests/ui/associated-types/associated-types-eq-2.stderr b/tests/ui/associated-types/associated-types-eq-2.stderr index e5013a35d453..ccd13123d704 100644 --- a/tests/ui/associated-types/associated-types-eq-2.stderr +++ b/tests/ui/associated-types/associated-types-eq-2.stderr @@ -3,8 +3,7 @@ error[E0658]: associated const equality is incomplete | LL | impl Tr3 for Bar { | |____^ | @@ -198,8 +197,7 @@ error[E0229]: associated item constraints are not allowed here | LL | impl Tr3 for Bar { | |____^ associated item constraint not allowed here | diff --git a/tests/ui/associated-types/issue-59324.stderr b/tests/ui/associated-types/issue-59324.stderr index ec2890cc8e7f..51379d678f1a 100644 --- a/tests/ui/associated-types/issue-59324.stderr +++ b/tests/ui/associated-types/issue-59324.stderr @@ -2,8 +2,7 @@ error[E0277]: the trait bound `Bug: Foo` is not satisfied --> $DIR/issue-59324.rs:11:1 | LL | / pub trait ThriftService: -LL | | -LL | | +... | LL | | Service::OnlyFoo> | |______________________________________________^ the trait `Foo` is not implemented for `Bug` | diff --git a/tests/ui/async-await/issue-84841.stderr b/tests/ui/async-await/issue-84841.stderr index 1e22373ba6ea..69c1c882d60a 100644 --- a/tests/ui/async-await/issue-84841.stderr +++ b/tests/ui/async-await/issue-84841.stderr @@ -14,8 +14,7 @@ LL | async fn foo() { LL | | // Adding an .await here avoids the ICE LL | | test()?; | | ^ cannot use the `?` operator in an async function that returns `()` -LL | | -LL | | +... | LL | | } | |_- this function should return `Result` or `Option` to accept `?` | diff --git a/tests/ui/async-await/issues/issue-72312.stderr b/tests/ui/async-await/issues/issue-72312.stderr index cd93f8a3c559..8e6fb138a1fa 100644 --- a/tests/ui/async-await/issues/issue-72312.stderr +++ b/tests/ui/async-await/issues/issue-72312.stderr @@ -8,10 +8,7 @@ LL | pub async fn start(&self) { | let's call the lifetime of this reference `'1` ... LL | / require_static(async move { -LL | | -LL | | -LL | | -LL | | &self; +... | LL | | }); | | ^ | | | diff --git a/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr b/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr index 8344b7a07dc6..6887a904211e 100644 --- a/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr +++ b/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr @@ -66,8 +66,7 @@ LL | fn foo3() { LL | / async { LL | | LL | | let _ = #[track_caller] || { -LL | | -LL | | }; +... | LL | | } | |_____^ expected `()`, found `async` block | diff --git a/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr b/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr index 8344b7a07dc6..6887a904211e 100644 --- a/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr +++ b/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr @@ -66,8 +66,7 @@ LL | fn foo3() { LL | / async { LL | | LL | | let _ = #[track_caller] || { -LL | | -LL | | }; +... | LL | | } | |_____^ expected `()`, found `async` block | diff --git a/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr b/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr index a66281a188d7..aa4e5fb2f691 100644 --- a/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr +++ b/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr @@ -40,8 +40,6 @@ LL | v.call(|(), this: &mut S| { | | | | _____| first borrow later used by call | | -LL | | -LL | | ... | LL | | v.set(); | | - first borrow occurs due to use of `v` in closure diff --git a/tests/ui/closures/2229_closure_analysis/issue-88476.stderr b/tests/ui/closures/2229_closure_analysis/issue-88476.stderr index 1c0e254dbf70..69b83f21a95a 100644 --- a/tests/ui/closures/2229_closure_analysis/issue-88476.stderr +++ b/tests/ui/closures/2229_closure_analysis/issue-88476.stderr @@ -23,9 +23,6 @@ error: First Pass analysis includes: | LL | let x = #[rustc_capture_analysis] move || { | _______________________________________^ -LL | | -LL | | -LL | | ... | LL | | LL | | }; @@ -42,9 +39,6 @@ error: Min Capture analysis includes: | LL | let x = #[rustc_capture_analysis] move || { | _______________________________________^ -LL | | -LL | | -LL | | ... | LL | | LL | | }; @@ -61,9 +55,6 @@ error: First Pass analysis includes: | LL | let c = #[rustc_capture_analysis] move || { | _______________________________________^ -LL | | -LL | | -LL | | ... | LL | | LL | | }; @@ -80,9 +71,6 @@ error: Min Capture analysis includes: | LL | let c = #[rustc_capture_analysis] move || { | _______________________________________^ -LL | | -LL | | -LL | | ... | LL | | LL | | }; diff --git a/tests/ui/closures/2229_closure_analysis/wild_patterns.stderr b/tests/ui/closures/2229_closure_analysis/wild_patterns.stderr index 4d6d85649da1..0b54b00ab303 100644 --- a/tests/ui/closures/2229_closure_analysis/wild_patterns.stderr +++ b/tests/ui/closures/2229_closure_analysis/wild_patterns.stderr @@ -32,9 +32,6 @@ error: First Pass analysis includes: --> $DIR/wild_patterns.rs:26:5 | LL | / || { -LL | | -LL | | -LL | | // FIXME(arora-aman): Change `_x` to `_` ... | LL | | LL | | }; @@ -50,9 +47,6 @@ error: Min Capture analysis includes: --> $DIR/wild_patterns.rs:26:5 | LL | / || { -LL | | -LL | | -LL | | // FIXME(arora-aman): Change `_x` to `_` ... | LL | | LL | | }; @@ -68,9 +62,6 @@ error: First Pass analysis includes: --> $DIR/wild_patterns.rs:45:5 | LL | / || { -LL | | -LL | | -LL | | // FIXME(arora-aman): Change `_x` to `_` ... | LL | | LL | | }; @@ -86,9 +77,6 @@ error: Min Capture analysis includes: --> $DIR/wild_patterns.rs:45:5 | LL | / || { -LL | | -LL | | -LL | | // FIXME(arora-aman): Change `_x` to `_` ... | LL | | LL | | }; @@ -104,9 +92,6 @@ error: First Pass analysis includes: --> $DIR/wild_patterns.rs:64:5 | LL | / || { -LL | | -LL | | -LL | | // FIXME(arora-aman): Change `_x` to `_` ... | LL | | LL | | }; @@ -122,9 +107,6 @@ error: Min Capture analysis includes: --> $DIR/wild_patterns.rs:64:5 | LL | / || { -LL | | -LL | | -LL | | // FIXME(arora-aman): Change `_x` to `_` ... | LL | | LL | | }; diff --git a/tests/ui/codemap_tests/huge_multispan_highlight.ascii.svg b/tests/ui/codemap_tests/huge_multispan_highlight.ascii.svg index 6f46df0101e7..fe1eb753430d 100644 --- a/tests/ui/codemap_tests/huge_multispan_highlight.ascii.svg +++ b/tests/ui/codemap_tests/huge_multispan_highlight.ascii.svg @@ -1,4 +1,4 @@ - + { let (coordinator_send, coordinator_receive) = channel(); - let sess = tcx.sess; let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID); let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins); @@ -477,7 +476,6 @@ pub(crate) fn start_async_codegen( shared_emitter, codegen_worker_send, coordinator_receive, - sess.jobserver.clone(), Arc::new(regular_config), Arc::new(metadata_config), Arc::new(allocator_config), @@ -1093,7 +1091,6 @@ fn start_executing_work( shared_emitter: SharedEmitter, codegen_worker_send: Sender, coordinator_receive: Receiver>, - jobserver: Client, regular_config: Arc, metadata_config: Arc, allocator_config: Arc, @@ -1145,7 +1142,7 @@ fn start_executing_work( // get tokens on `coordinator_receive` which will // get managed in the main loop below. let coordinator_send2 = coordinator_send.clone(); - let helper = jobserver + let helper = jobserver::client() .into_helper_thread(move |token| { drop(coordinator_send2.send(Box::new(Message::Token::(token)))); }) diff --git a/compiler/rustc_data_structures/src/jobserver.rs b/compiler/rustc_data_structures/src/jobserver.rs index d09f7efc8fff..1204f2d692d6 100644 --- a/compiler/rustc_data_structures/src/jobserver.rs +++ b/compiler/rustc_data_structures/src/jobserver.rs @@ -1,6 +1,6 @@ use std::sync::{LazyLock, OnceLock}; -pub use jobserver_crate::Client; +pub use jobserver_crate::{Acquired, Client, HelperThread}; use jobserver_crate::{FromEnv, FromEnvErrorKind}; // We can only call `from_env_ext` once per process diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 993d111466be..160525cead03 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -8,7 +8,6 @@ use std::{env, fmt, io}; use rustc_data_structures::flock; use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; -use rustc_data_structures::jobserver::{self, Client}; use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef}; use rustc_data_structures::sync::{ DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock, @@ -154,10 +153,6 @@ pub struct Session { /// Data about code being compiled, gathered during compilation. pub code_stats: CodeStats, - /// Loaded up early on in the initialization of this `Session` to avoid - /// false positives about a job server in our environment. - pub jobserver: Client, - /// This only ever stores a `LintStore` but we don't want a dependency on that type here. pub lint_store: Option>, @@ -1072,7 +1067,6 @@ pub fn build_session( incr_comp_session: RwLock::new(IncrCompSession::NotInitialized), prof, code_stats: Default::default(), - jobserver: jobserver::client(), lint_store: None, registered_lints: false, driver_lint_caps, From 981f625ba7c8e8ddcf6e470eb54d822eaf9fb300 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:45:10 +0000 Subject: [PATCH 08/19] Remove registered_lints field from Session It only exists to pass some information from one part of the driver to another part. We can directly pass this information to the function that needs it to reduce the amount of mutation of the Session. --- compiler/rustc_driver_impl/src/lib.rs | 8 +++++--- compiler/rustc_interface/src/interface.rs | 1 - compiler/rustc_session/src/session.rs | 4 ---- src/librustdoc/lib.rs | 4 +++- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 2e01c385a667..b8d5281087ef 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -350,6 +350,8 @@ fn run_compiler( callbacks.config(&mut config); + let registered_lints = config.register_lints.is_some(); + interface::run_compiler(config, |compiler| { let sess = &compiler.sess; let codegen_backend = &*compiler.codegen_backend; @@ -365,7 +367,7 @@ fn run_compiler( // `--help`/`-Zhelp`/`-Chelp`. This is the earliest it can run, because // it must happen after lints are registered, during session creation. if sess.opts.describe_lints { - describe_lints(sess); + describe_lints(sess, registered_lints); return early_exit(); } @@ -982,7 +984,7 @@ the command line flag directly. } /// Write to stdout lint command options, together with a list of all available lints -pub fn describe_lints(sess: &Session) { +pub fn describe_lints(sess: &Session, registered_lints: bool) { safe_println!( " Available lint options: @@ -1086,7 +1088,7 @@ Available lint options: print_lint_groups(builtin_groups, true); - match (sess.registered_lints, loaded.len(), loaded_groups.len()) { + match (registered_lints, loaded.len(), loaded_groups.len()) { (false, 0, _) | (false, _, 0) => { safe_println!("Lint tools like Clippy can load additional lints and lint groups."); } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 07ae24ee6d32..7ad893f61ab5 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -479,7 +479,6 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints()); if let Some(register_lints) = config.register_lints.as_deref() { register_lints(&sess, &mut lint_store); - sess.registered_lints = true; } sess.lint_store = Some(Lrc::new(lint_store)); diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 160525cead03..9f6106f9cfb7 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -156,9 +156,6 @@ pub struct Session { /// This only ever stores a `LintStore` but we don't want a dependency on that type here. pub lint_store: Option>, - /// Should be set if any lints are registered in `lint_store`. - pub registered_lints: bool, - /// Cap lint level specified by a driver specifically. pub driver_lint_caps: FxHashMap, @@ -1068,7 +1065,6 @@ pub fn build_session( prof, code_stats: Default::default(), lint_store: None, - registered_lints: false, driver_lint_caps, ctfe_backtrace, miri_unleashed_features: Lock::new(Default::default()), diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index a384c286039d..5d82b8e309a6 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -846,11 +846,13 @@ fn main_args( let config = core::create_config(input, options, &render_options, using_internal_features); + let registered_lints = config.register_lints.is_some(); + interface::run_compiler(config, |compiler| { let sess = &compiler.sess; if sess.opts.describe_lints { - rustc_driver::describe_lints(sess); + rustc_driver::describe_lints(sess, registered_lints); return; } From ea9e8c13dc94949ab38370c39559110da33c878f Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:46:16 +0000 Subject: [PATCH 09/19] Explain why an untranslatable_diagnostic occurs --- compiler/rustc_interface/src/interface.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 7ad893f61ab5..91f190c6a28d 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -371,7 +371,6 @@ pub(crate) fn initialize_checked_jobserver(early_dcx: &EarlyDiagCtxt) { // JUSTIFICATION: before session exists, only config #[allow(rustc::bad_opt_access)] -#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R { trace!("run_compiler"); @@ -425,7 +424,11 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se config.opts.unstable_opts.translate_directionality_markers, ) { Ok(bundle) => bundle, - Err(e) => early_dcx.early_fatal(format!("failed to load fluent bundle: {e}")), + Err(e) => { + // We can't translate anything if we failed to load translations + #[allow(rustc::untranslatable_diagnostic)] + early_dcx.early_fatal(format!("failed to load fluent bundle: {e}")) + } }; let mut locale_resources = config.locale_resources; From 3198496385cd8fdd89818e0bf14bacd8db6292d9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:44:18 +0000 Subject: [PATCH 10/19] Make dependency_formats an FxIndexMap rather than a list of tuples It is treated as a map already. This is using FxIndexMap rather than UnordMap because the latter doesn't provide an api to pick a single value iff all values are equal, which each_linked_rlib depends on. --- .../rustc_codegen_cranelift/src/driver/jit.rs | 7 +--- compiler/rustc_codegen_ssa/src/back/link.rs | 34 +++++++------------ compiler/rustc_codegen_ssa/src/back/linker.rs | 2 +- .../rustc_metadata/src/dependency_format.rs | 2 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 5 +-- .../src/middle/dependency_format.rs | 3 +- src/tools/miri/src/helpers.rs | 5 ++- 7 files changed, 21 insertions(+), 37 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/driver/jit.rs b/compiler/rustc_codegen_cranelift/src/driver/jit.rs index d68948966eae..4be4291021df 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/jit.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/jit.rs @@ -287,12 +287,7 @@ fn dep_symbol_lookup_fn( let mut dylib_paths = Vec::new(); - let data = &crate_info - .dependency_formats - .iter() - .find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable) - .unwrap() - .1; + let data = &crate_info.dependency_formats[&rustc_session::config::CrateType::Executable].1; // `used_crates` is in reverse postorder in terms of dependencies. Reverse the order here to // get a postorder which ensures that all dependencies of a dylib are loaded before the dylib // itself. This helps the dynamic linker to find dylibs not in the regular dynamic library diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 35d18d0206db..31ac8c6e66aa 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -236,7 +236,13 @@ pub fn each_linked_rlib( ) -> Result<(), errors::LinkRlibError> { let crates = info.used_crates.iter(); - let fmts = if crate_type.is_none() { + let fmts = if let Some(crate_type) = crate_type { + let Some(fmts) = info.dependency_formats.get(&crate_type) else { + return Err(errors::LinkRlibError::MissingFormat); + }; + + fmts + } else { for combination in info.dependency_formats.iter().combinations(2) { let (ty1, list1) = &combination[0]; let (ty2, list2) = &combination[1]; @@ -252,18 +258,7 @@ pub fn each_linked_rlib( if info.dependency_formats.is_empty() { return Err(errors::LinkRlibError::MissingFormat); } - &info.dependency_formats[0].1 - } else { - let fmts = info - .dependency_formats - .iter() - .find_map(|&(ty, ref list)| if Some(ty) == crate_type { Some(list) } else { None }); - - let Some(fmts) = fmts else { - return Err(errors::LinkRlibError::MissingFormat); - }; - - fmts + info.dependency_formats.first().unwrap().1 }; for &cnum in crates { @@ -624,8 +619,7 @@ fn link_staticlib( let fmts = codegen_results .crate_info .dependency_formats - .iter() - .find_map(|&(ty, ref list)| if ty == CrateType::Staticlib { Some(list) } else { None }) + .get(&CrateType::Staticlib) .expect("no dependency formats for staticlib"); let mut all_rust_dylibs = vec![]; @@ -2355,11 +2349,10 @@ fn linker_with_args( // they are used within inlined functions or instantiated generic functions. We do this *after* // handling the raw-dylib symbols in the current crate to make sure that those are chosen first // by the linker. - let (_, dependency_linkage) = codegen_results + let dependency_linkage = codegen_results .crate_info .dependency_formats - .iter() - .find(|(ty, _)| *ty == crate_type) + .get(&crate_type) .expect("failed to find crate type in dependency format list"); // We sort the libraries below @@ -2738,11 +2731,10 @@ fn add_upstream_rust_crates( // Linking to a rlib involves just passing it to the linker (the linker // will slurp up the object files inside), and linking to a dynamic library // involves just passing the right -l flag. - let (_, data) = codegen_results + let data = codegen_results .crate_info .dependency_formats - .iter() - .find(|(ty, _)| *ty == crate_type) + .get(&crate_type) .expect("failed to find crate type in dependency format list"); if sess.target.is_like_aix { diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 4c5eb98e890e..301b22f2be4f 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1749,7 +1749,7 @@ fn for_each_exported_symbols_include_dep<'tcx>( } let formats = tcx.dependency_formats(()); - let deps = formats.iter().find_map(|(t, list)| (*t == crate_type).then_some(list)).unwrap(); + let deps = &formats[&crate_type]; for (index, dep_format) in deps.iter().enumerate() { let cnum = CrateNum::new(index + 1); diff --git a/compiler/rustc_metadata/src/dependency_format.rs b/compiler/rustc_metadata/src/dependency_format.rs index 641d1d8e7981..e8de0acb7c9f 100644 --- a/compiler/rustc_metadata/src/dependency_format.rs +++ b/compiler/rustc_metadata/src/dependency_format.rs @@ -77,7 +77,7 @@ pub(crate) fn calculate(tcx: TyCtxt<'_>) -> Dependencies { verify_ok(tcx, &linkage); (ty, linkage) }) - .collect::>() + .collect() } fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 5c80d24f502d..5548406502b4 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -2164,10 +2164,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { fn encode_dylib_dependency_formats(&mut self) -> LazyArray> { empty_proc_macro!(self); let formats = self.tcx.dependency_formats(()); - for (ty, arr) in formats.iter() { - if *ty != CrateType::Dylib { - continue; - } + if let Some(arr) = formats.get(&CrateType::Dylib) { return self.lazy_array(arr.iter().map(|slot| match *slot { Linkage::NotLinked | Linkage::IncludedFromDylib => None, diff --git a/compiler/rustc_middle/src/middle/dependency_format.rs b/compiler/rustc_middle/src/middle/dependency_format.rs index a3aff9a11013..e3b40b641578 100644 --- a/compiler/rustc_middle/src/middle/dependency_format.rs +++ b/compiler/rustc_middle/src/middle/dependency_format.rs @@ -7,6 +7,7 @@ // FIXME: move this file to rustc_metadata::dependency_format, but // this will introduce circular dependency between rustc_metadata and rustc_middle +use rustc_data_structures::fx::FxIndexMap; use rustc_macros::{Decodable, Encodable, HashStable}; use rustc_session::config::CrateType; @@ -18,7 +19,7 @@ pub type DependencyList = Vec; /// A mapping of all required dependencies for a particular flavor of output. /// /// This is local to the tcx, and is generally relevant to one session. -pub type Dependencies = Vec<(CrateType, DependencyList)>; +pub type Dependencies = FxIndexMap; #[derive(Copy, Clone, PartialEq, Debug, HashStable, Encodable, Decodable)] pub enum Linkage { diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index b57ce4e070c3..1f7c60ad1bdf 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -149,10 +149,9 @@ pub fn iter_exported_symbols<'tcx>( let dependency_formats = tcx.dependency_formats(()); // Find the dependencies of the executable we are running. let dependency_format = dependency_formats - .iter() - .find(|(crate_type, _)| *crate_type == CrateType::Executable) + .get(&CrateType::Executable) .expect("interpreting a non-executable crate"); - for cnum in dependency_format.1.iter().enumerate().filter_map(|(num, &linkage)| { + for cnum in dependency_format.iter().enumerate().filter_map(|(num, &linkage)| { // We add 1 to the number because that's what rustc also does everywhere it // calls `CrateNum::new`... #[expect(clippy::arithmetic_side_effects)] From af530c4927d4b6018662c092ebcf629f17eb7191 Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Fri, 13 Dec 2024 12:32:35 +0100 Subject: [PATCH 11/19] Use a more precise span in placeholder_type_error_diag Closes: https://github.com/rust-lang/rust/issues/123861 --- compiler/rustc_hir_analysis/src/collect.rs | 7 +-- tests/crashes/123861.rs | 5 -- .../overlapping-errors-span-issue-123861.rs | 8 +++ ...verlapping-errors-span-issue-123861.stderr | 52 +++++++++++++++++++ 4 files changed, 64 insertions(+), 8 deletions(-) delete mode 100644 tests/crashes/123861.rs create mode 100644 tests/ui/generics/overlapping-errors-span-issue-123861.rs create mode 100644 tests/ui/generics/overlapping-errors-span-issue-123861.stderr diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 96d2714252af..0bbf6aa5116e 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -201,12 +201,13 @@ pub(crate) fn placeholder_type_error_diag<'cx, 'tcx>( placeholder_types.iter().map(|sp| (*sp, (*type_name).to_string())).collect(); if let Some(generics) = generics { - if let Some(arg) = params.iter().find(|arg| { - matches!(arg.name, hir::ParamName::Plain(Ident { name: kw::Underscore, .. })) + if let Some(span) = params.iter().find_map(|arg| match arg.name { + hir::ParamName::Plain(Ident { name: kw::Underscore, span }) => Some(span), + _ => None, }) { // Account for `_` already present in cases like `struct S<_>(_);` and suggest // `struct S(T);` instead of `struct S<_, T>(T);`. - sugg.push((arg.span, (*type_name).to_string())); + sugg.push((span, (*type_name).to_string())); } else if let Some(span) = generics.span_for_param_suggestion() { // Account for bounds, we want `fn foo(_: K)` not `fn foo(_: K)`. sugg.push((span, format!(", {type_name}"))); diff --git a/tests/crashes/123861.rs b/tests/crashes/123861.rs deleted file mode 100644 index 60245960af0d..000000000000 --- a/tests/crashes/123861.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ known-bug: #123861 -//@ needs-rustc-debug-assertions - -struct _; -fn mainIterator<_ = _> {} diff --git a/tests/ui/generics/overlapping-errors-span-issue-123861.rs b/tests/ui/generics/overlapping-errors-span-issue-123861.rs new file mode 100644 index 000000000000..e0a27f687487 --- /dev/null +++ b/tests/ui/generics/overlapping-errors-span-issue-123861.rs @@ -0,0 +1,8 @@ +fn mainIterator<_ = _> {} +//~^ ERROR expected identifier, found reserved identifier `_` +//~| ERROR missing parameters for function definition +//~| ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions [invalid_type_param_default] +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//~| ERROR the placeholder `_` is not allowed within types on item signatures for functions [E0121] + +fn main() {} diff --git a/tests/ui/generics/overlapping-errors-span-issue-123861.stderr b/tests/ui/generics/overlapping-errors-span-issue-123861.stderr new file mode 100644 index 000000000000..e0a49343b0e0 --- /dev/null +++ b/tests/ui/generics/overlapping-errors-span-issue-123861.stderr @@ -0,0 +1,52 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/overlapping-errors-span-issue-123861.rs:1:17 + | +LL | fn mainIterator<_ = _> {} + | ^ expected identifier, found reserved identifier + +error: missing parameters for function definition + --> $DIR/overlapping-errors-span-issue-123861.rs:1:23 + | +LL | fn mainIterator<_ = _> {} + | ^ + | +help: add a parameter list + | +LL | fn mainIterator<_ = _>() {} + | ++ + +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/overlapping-errors-span-issue-123861.rs:1:17 + | +LL | fn mainIterator<_ = _> {} + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 + = note: `#[deny(invalid_type_param_default)]` on by default + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/overlapping-errors-span-issue-123861.rs:1:21 + | +LL | fn mainIterator<_ = _> {} + | ^ not allowed in type signatures + | +help: use type parameters instead + | +LL | fn mainIterator {} + | ~ ~ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0121`. +Future incompatibility report: Future breakage diagnostic: +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/overlapping-errors-span-issue-123861.rs:1:17 + | +LL | fn mainIterator<_ = _> {} + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 + = note: `#[deny(invalid_type_param_default)]` on by default + From e17ca31b22f26209bbdf28a95e045aa0da337733 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 13 Dec 2024 06:56:49 +0100 Subject: [PATCH 12/19] rustc_borrowck: Make suggest_ampmut() return type match its use So that it becomes easy for a later commit to return `None`. --- .../src/diagnostics/mutability_errors.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index c5ebf3c547e9..48fc0c331b8b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -1150,7 +1150,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { None } None => { - let (has_sugg, decl_span, sugg) = if name != kw::SelfLower { + if name != kw::SelfLower { suggest_ampmut( self.infcx.tcx, local_decl.ty, @@ -1165,7 +1165,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { .. })) => { let sugg = suggest_ampmut_self(self.infcx.tcx, decl_span); - (true, decl_span, sugg) + Some((true, decl_span, sugg, None)) } // explicit self (eg `self: &'a Self`) _ => suggest_ampmut( @@ -1176,8 +1176,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { opt_ty_info, ), } - }; - Some((has_sugg, decl_span, sugg, None)) + } } } } @@ -1443,7 +1442,7 @@ fn suggest_ampmut<'tcx>( decl_span: Span, opt_assignment_rhs_span: Option, opt_ty_info: Option, -) -> (bool, Span, String) { +) -> Option<(bool, Span, String, Option<(Span, String)>)> { // if there is a RHS and it starts with a `&` from it, then check if it is // mutable, and if not, put suggest putting `mut ` to make it mutable. // we don't have to worry about lifetime annotations here because they are @@ -1479,7 +1478,7 @@ fn suggest_ampmut<'tcx>( // FIXME(Ezrashaw): returning is bad because we still might want to // update the annotated type, see #106857. - return (true, span, "mut ".to_owned()); + return Some((true, span, "mut ".to_owned(), None)); } } @@ -1504,18 +1503,18 @@ fn suggest_ampmut<'tcx>( && let Some(ws_pos) = src.find(char::is_whitespace) { let span = span.with_lo(span.lo() + BytePos(ws_pos as u32)).shrink_to_lo(); - (true, span, " mut".to_owned()) + Some((true, span, " mut".to_owned(), None)) // if there is already a binding, we modify it to be `mut` } else if binding_exists { // shrink the span to just after the `&` in `&variable` let span = span.with_lo(span.lo() + BytePos(1)).shrink_to_lo(); - (true, span, "mut ".to_owned()) + Some((true, span, "mut ".to_owned(), None)) } else { // otherwise, suggest that the user annotates the binding; we provide the // type of the local. let ty = decl_ty.builtin_deref(true).unwrap(); - (false, span, format!("{}mut {}", if decl_ty.is_ref() { "&" } else { "*" }, ty)) + Some((false, span, format!("{}mut {}", if decl_ty.is_ref() { "&" } else { "*" }, ty), None)) } } From d7fa8ee6802a2c1121dca0925d3db143dd1a793c Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 13 Dec 2024 06:44:52 +0100 Subject: [PATCH 13/19] Add regression test for issue 127562 The test fails in this commit. The next commit fixes it. --- ...-mut-suggestion-for-raw-pointer-issue-127562.rs | 8 ++++++++ ...-suggestion-for-raw-pointer-issue-127562.stderr | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.rs create mode 100644 tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr diff --git a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.rs b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.rs new file mode 100644 index 000000000000..5425e571af06 --- /dev/null +++ b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.rs @@ -0,0 +1,8 @@ +//! Regression test for invalid suggestion for `&raw const expr` reported in +//! . + +fn main() { + let val = 2; + let ptr = &raw const val; + unsafe { *ptr = 3; } //~ ERROR cannot assign to `*ptr`, which is behind a `*const` pointer +} diff --git a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr new file mode 100644 index 000000000000..0da5d15cf7f8 --- /dev/null +++ b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr @@ -0,0 +1,14 @@ +error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer + --> $DIR/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.rs:7:14 + | +LL | unsafe { *ptr = 3; } + | ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written + | +help: consider changing this to be a mutable pointer + | +LL | let ptr = &mut raw const val; + | +++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0594`. From 2d2c6f2a80167d9f244d8c926fdf3b3aebf3f42f Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 13 Dec 2024 07:00:08 +0100 Subject: [PATCH 14/19] rustc_borrowck: Stop suggesting the invalid syntax `&mut raw const` A legitimate suggestion would be to change from &raw const val to &raw mut val But until we have figured out how to make that happen we should at least stop suggesting invalid syntax. --- compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs | 5 +++++ ...nvalid-mut-suggestion-for-raw-pointer-issue-127562.stderr | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 48fc0c331b8b..044a828b3467 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -1455,6 +1455,11 @@ fn suggest_ampmut<'tcx>( && let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span) && let Some(stripped) = src.strip_prefix('&') { + let is_raw_ref = stripped.trim_start().starts_with("raw "); + // We don't support raw refs yet + if is_raw_ref { + return None; + } let is_mut = if let Some(rest) = stripped.trim_start().strip_prefix("mut") { match rest.chars().next() { // e.g. `&mut x` diff --git a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr index 0da5d15cf7f8..c27dcc19827d 100644 --- a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr +++ b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr @@ -3,11 +3,6 @@ error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer | LL | unsafe { *ptr = 3; } | ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written - | -help: consider changing this to be a mutable pointer - | -LL | let ptr = &mut raw const val; - | +++ error: aborting due to 1 previous error From f6cb227f6151abfd44536e613cbf4b800e814a2b Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 13 Dec 2024 06:51:17 +0100 Subject: [PATCH 15/19] rustc_borrowck: Convert suggest_ampmut() 4-tuple to struct for readability --- .../src/diagnostics/mutability_errors.rs | 59 +++++++++++++++---- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 044a828b3467..4fb7b22f2896 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -1100,12 +1100,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { } let decl_span = local_decl.source_info.span; - let label = match *local_decl.local_info() { + let amp_mut_sugg = match *local_decl.local_info() { LocalInfo::User(mir::BindingForm::ImplicitSelf(_)) => { let suggestion = suggest_ampmut_self(self.infcx.tcx, decl_span); let additional = local_trait.map(|span| (span, suggest_ampmut_self(self.infcx.tcx, span))); - Some((true, decl_span, suggestion, additional)) + Some(AmpMutSugg { has_sugg: true, span: decl_span, suggestion, additional }) } LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm { @@ -1165,7 +1165,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { .. })) => { let sugg = suggest_ampmut_self(self.infcx.tcx, decl_span); - Some((true, decl_span, sugg, None)) + Some(AmpMutSugg { + has_sugg: true, + span: decl_span, + suggestion: sugg, + additional: None, + }) } // explicit self (eg `self: &'a Self`) _ => suggest_ampmut( @@ -1186,15 +1191,24 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { .. })) => { let pattern_span: Span = local_decl.source_info.span; - suggest_ref_mut(self.infcx.tcx, pattern_span) - .map(|span| (true, span, "mut ".to_owned(), None)) + suggest_ref_mut(self.infcx.tcx, pattern_span).map(|span| AmpMutSugg { + has_sugg: true, + span, + suggestion: "mut ".to_owned(), + additional: None, + }) } _ => unreachable!(), }; - match label { - Some((true, err_help_span, suggested_code, additional)) => { + match amp_mut_sugg { + Some(AmpMutSugg { + has_sugg: true, + span: err_help_span, + suggestion: suggested_code, + additional, + }) => { let mut sugg = vec![(err_help_span, suggested_code)]; if let Some(s) = additional { sugg.push(s); @@ -1216,7 +1230,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { ); } } - Some((false, err_label_span, message, _)) => { + Some(AmpMutSugg { + has_sugg: false, span: err_label_span, suggestion: message, .. + }) => { let def_id = self.body.source.def_id(); let hir_id = if let Some(local_def_id) = def_id.as_local() && let Some(body) = self.infcx.tcx.hir().maybe_body_owned_by(local_def_id) @@ -1421,6 +1437,13 @@ fn suggest_ampmut_self<'tcx>(tcx: TyCtxt<'tcx>, span: Span) -> String { } } +struct AmpMutSugg { + has_sugg: bool, + span: Span, + suggestion: String, + additional: Option<(Span, String)>, +} + // When we want to suggest a user change a local variable to be a `&mut`, there // are three potential "obvious" things to highlight: // @@ -1442,7 +1465,7 @@ fn suggest_ampmut<'tcx>( decl_span: Span, opt_assignment_rhs_span: Option, opt_ty_info: Option, -) -> Option<(bool, Span, String, Option<(Span, String)>)> { +) -> Option { // if there is a RHS and it starts with a `&` from it, then check if it is // mutable, and if not, put suggest putting `mut ` to make it mutable. // we don't have to worry about lifetime annotations here because they are @@ -1483,7 +1506,12 @@ fn suggest_ampmut<'tcx>( // FIXME(Ezrashaw): returning is bad because we still might want to // update the annotated type, see #106857. - return Some((true, span, "mut ".to_owned(), None)); + return Some(AmpMutSugg { + has_sugg: true, + span, + suggestion: "mut ".to_owned(), + additional: None, + }); } } @@ -1508,18 +1536,23 @@ fn suggest_ampmut<'tcx>( && let Some(ws_pos) = src.find(char::is_whitespace) { let span = span.with_lo(span.lo() + BytePos(ws_pos as u32)).shrink_to_lo(); - Some((true, span, " mut".to_owned(), None)) + Some(AmpMutSugg { has_sugg: true, span, suggestion: " mut".to_owned(), additional: None }) // if there is already a binding, we modify it to be `mut` } else if binding_exists { // shrink the span to just after the `&` in `&variable` let span = span.with_lo(span.lo() + BytePos(1)).shrink_to_lo(); - Some((true, span, "mut ".to_owned(), None)) + Some(AmpMutSugg { has_sugg: true, span, suggestion: "mut ".to_owned(), additional: None }) } else { // otherwise, suggest that the user annotates the binding; we provide the // type of the local. let ty = decl_ty.builtin_deref(true).unwrap(); - Some((false, span, format!("{}mut {}", if decl_ty.is_ref() { "&" } else { "*" }, ty), None)) + Some(AmpMutSugg { + has_sugg: false, + span, + suggestion: format!("{}mut {}", if decl_ty.is_ref() { "&" } else { "*" }, ty), + additional: None, + }) } } From 98318c5e66d5a56d8741186a876a84ffe33ea814 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 13 Dec 2024 09:08:44 -0700 Subject: [PATCH 16/19] rustdoc-search: update test with now-shorter function path Both paths are correct. This one's better. --- tests/rustdoc-js-std/osstring-to-string.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rustdoc-js-std/osstring-to-string.js b/tests/rustdoc-js-std/osstring-to-string.js index 3fdc0b9f24a3..17bb602a502a 100644 --- a/tests/rustdoc-js-std/osstring-to-string.js +++ b/tests/rustdoc-js-std/osstring-to-string.js @@ -4,6 +4,6 @@ const EXPECTED = { 'query': 'OsString -> String', 'others': [ - { 'path': 'std::ffi::os_str::OsString', 'name': 'into_string' }, + { 'path': 'std::ffi::OsString', 'name': 'into_string' }, ] }; From ad82d9f6986c9801b1d6a60a7f86c71dc16c112f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 12 Dec 2024 23:56:39 +0000 Subject: [PATCH 17/19] Fix miri tests --- .../miri/tests/fail-dep/concurrency/windows_join_main.stderr | 3 +-- .../tests/fail/function_calls/arg_inplace_mutate.stack.stderr | 1 - .../tests/fail/function_calls/arg_inplace_mutate.tree.stderr | 1 - .../function_calls/arg_inplace_observe_during.stack.stderr | 1 - .../fail/function_calls/arg_inplace_observe_during.tree.stderr | 1 - .../function_calls/return_pointer_aliasing_read.stack.stderr | 1 - .../function_calls/return_pointer_aliasing_read.tree.stderr | 1 - .../function_calls/return_pointer_aliasing_write.stack.stderr | 1 - .../function_calls/return_pointer_aliasing_write.tree.stderr | 1 - .../return_pointer_aliasing_write_tail_call.stack.stderr | 1 - .../return_pointer_aliasing_write_tail_call.tree.stderr | 1 - 11 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/tools/miri/tests/fail-dep/concurrency/windows_join_main.stderr b/src/tools/miri/tests/fail-dep/concurrency/windows_join_main.stderr index 23a9f8f9c288..6540543d8da3 100644 --- a/src/tools/miri/tests/fail-dep/concurrency/windows_join_main.stderr +++ b/src/tools/miri/tests/fail-dep/concurrency/windows_join_main.stderr @@ -24,8 +24,7 @@ note: inside `main` LL | / thread::spawn(|| { LL | | unsafe { LL | | assert_eq!(WaitForSingleObject(MAIN_THREAD, INFINITE), WAIT_OBJECT_0); -LL | | } -LL | | }) +... | LL | | .join() | |___________^ diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr index d9ab782986fb..2875a5be2854 100644 --- a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr @@ -14,7 +14,6 @@ LL | | let _unit: (); LL | | { LL | | let non_copy = S(42); ... | -LL | | } LL | | } | |_____^ help: is this argument diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr index 677952b39da1..c699987b7960 100644 --- a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr @@ -16,7 +16,6 @@ LL | | let _unit: (); LL | | { LL | | let non_copy = S(42); ... | -LL | | } LL | | } | |_____^ help: the protected tag was created here, in the initial state Reserved diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.stack.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.stack.stderr index efdd6129d744..f20ec00f97bd 100644 --- a/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.stack.stderr +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.stack.stderr @@ -14,7 +14,6 @@ LL | | let _unit: (); LL | | { LL | | let non_copy = S(42); ... | -LL | | LL | | } | |_____^ help: is this argument diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.tree.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.tree.stderr index 5746ad1e13d1..8996c3643db7 100644 --- a/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.tree.stderr +++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.tree.stderr @@ -16,7 +16,6 @@ LL | | let _unit: (); LL | | { LL | | let non_copy = S(42); ... | -LL | | LL | | } | |_____^ help: the protected tag was created here, in the initial state Reserved diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.stack.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.stack.stderr index b009b0901c41..47e5ee48292f 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.stack.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.stack.stderr @@ -14,7 +14,6 @@ LL | | { LL | | let x = 0; LL | | let ptr = &raw mut x; ... | -LL | | } LL | | } | |_____^ help: is this argument diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.tree.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.tree.stderr index 6d2cbe9b7cd6..7eb237ca1a72 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.tree.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.tree.stderr @@ -16,7 +16,6 @@ LL | | { LL | | let x = 0; LL | | let ptr = &raw mut x; ... | -LL | | } LL | | } | |_____^ help: the protected tag was created here, in the initial state Reserved diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write.stack.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write.stack.stderr index 54f9a7aebd60..813042f06a6c 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write.stack.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write.stack.stderr @@ -14,7 +14,6 @@ LL | | { LL | | let _x = 0; LL | | let ptr = &raw mut _x; ... | -LL | | } LL | | } | |_____^ help: is this argument diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write.tree.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write.tree.stderr index 693534be2e00..5090ec06b780 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write.tree.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write.tree.stderr @@ -16,7 +16,6 @@ LL | | { LL | | let _x = 0; LL | | let ptr = &raw mut _x; ... | -LL | | } LL | | } | |_____^ help: the protected tag was created here, in the initial state Reserved diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write_tail_call.stack.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write_tail_call.stack.stderr index 520937beaeb8..a6a0362a2266 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write_tail_call.stack.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write_tail_call.stack.stderr @@ -14,7 +14,6 @@ LL | | { LL | | let _x = 0; LL | | let ptr = &raw mut _x; ... | -LL | | } LL | | } | |_____^ help: is this argument diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write_tail_call.tree.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write_tail_call.tree.stderr index a879189d0c13..26a54fe87486 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write_tail_call.tree.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_write_tail_call.tree.stderr @@ -16,7 +16,6 @@ LL | | { LL | | let _x = 0; LL | | let ptr = &raw mut _x; ... | -LL | | } LL | | } | |_____^ help: the protected tag was created here, in the initial state Reserved From 9f1044ef76de2ae88ac5c38a27b2bd49f5507d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 13 Dec 2024 18:18:19 +0000 Subject: [PATCH 18/19] Account for `///` when rendering multiline spans Don't consider `///` and `//!` docstrings to be empty for the purposes of multiline span rendering. --- compiler/rustc_errors/src/emitter.rs | 17 +++---- .../tests/ui/doc/unbalanced_ticks.stderr | 4 +- .../ui/empty_line_after/doc_comments.stderr | 3 ++ .../clippy/tests/ui/needless_doc_main.stderr | 14 ++++-- .../suspicious_doc_comments_unfixable.stderr | 9 +++- .../too_long_first_doc_paragraph-fix.stderr | 4 +- .../ui/too_long_first_doc_paragraph.stderr | 7 ++- ...ustom_code_classes_in_docs-warning3.stderr | 6 +++ .../rustdoc-ui/doctest/check-attr-test.stderr | 48 ++++++++++++++----- .../doctest/private-item-doc-test.stderr | 4 +- .../private-public-item-doc-test.stderr | 4 +- .../doctest/standalone-warning-2024.stderr | 12 ++++- tests/rustdoc-ui/invalid-syntax.stderr | 7 ++- tests/rustdoc-ui/lints/check-attr.stderr | 29 +++++++++-- tests/rustdoc-ui/lints/check-fail.stderr | 8 +++- tests/rustdoc-ui/lints/lint-group.stderr | 4 +- tests/rustdoc-ui/unescaped_backticks.stderr | 4 ++ tests/ui/macros/issue-112342-1.stderr | 3 +- 18 files changed, 144 insertions(+), 43 deletions(-) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 04b18b92a0c8..ac2f91cdeb3f 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -3050,13 +3050,17 @@ impl FileWithAnnotatedLines { // We'll show up to 4 lines past the beginning of the multispan start. // We will *not* include the tail of lines that are only whitespace, a comment or // a bare delimiter. + let filter = |s: &str| { + let s = s.trim(); + // Consider comments as empty, but don't consider docstrings to be empty. + !(s.starts_with("//") && !(s.starts_with("///") || s.starts_with("//!"))) + // Consider lines with nothing but whitespace, a single delimiter as empty. + && !["", "{", "}", "(", ")", "[", "]"].contains(&s) + }; let until = (ann.line_start..middle) .rev() .filter_map(|line| file.get_line(line - 1).map(|s| (line + 1, s))) - .find(|(_, s)| { - let s = s.trim(); - !["", "{", "}", "(", ")", "[", "]"].contains(&s) && !s.starts_with("//") - }) + .find(|(_, s)| filter(s)) .map(|(line, _)| line) .unwrap_or(ann.line_start); for line in ann.line_start + 1..until { @@ -3064,10 +3068,7 @@ impl FileWithAnnotatedLines { add_annotation_to_file(&mut output, Lrc::clone(&file), line, ann.as_line()); } let line_end = ann.line_end - 1; - let end_is_empty = file.get_line(line_end - 1).map_or(false, |s| { - let s = s.trim(); - ["", "{", "}", "(", ")", "[", "]"].contains(&s) || s.starts_with("//") - }); + let end_is_empty = file.get_line(line_end - 1).map_or(false, |s| !filter(&s)); if middle < line_end && !end_is_empty { add_annotation_to_file(&mut output, Lrc::clone(&file), line_end, ann.as_line()); } diff --git a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr index 3bcf65c4595d..50324010e97f 100644 --- a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr +++ b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr @@ -3,7 +3,9 @@ error: backticks are unbalanced | LL | /// This is a doc comment with `unbalanced_tick marks and several words that | _____^ -... | +LL | | +LL | | /// should be `encompassed_by` tick marks because they `contain_underscores`. +LL | | /// Because of the initial `unbalanced_tick` pair, the error message is LL | | /// very `confusing_and_misleading`. | |____________________________________^ | diff --git a/src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr b/src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr index c4d4dde7f73f..c5d5f3d37594 100644 --- a/src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr +++ b/src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr @@ -96,6 +96,9 @@ error: empty lines after doc comment --> tests/ui/empty_line_after/doc_comments.rs:63:5 | LL | / /// for OldA +LL | | // struct OldA; +LL | | +LL | | /// Docs ... | LL | | | |_^ diff --git a/src/tools/clippy/tests/ui/needless_doc_main.stderr b/src/tools/clippy/tests/ui/needless_doc_main.stderr index cfb389801db0..7e362cf377ce 100644 --- a/src/tools/clippy/tests/ui/needless_doc_main.stderr +++ b/src/tools/clippy/tests/ui/needless_doc_main.stderr @@ -3,7 +3,9 @@ error: needless `fn main` in doctest | LL | /// fn main() { | _____^ -... | +LL | | +LL | | +LL | | /// unimplemented!(); LL | | /// } | |_____^ | @@ -15,7 +17,8 @@ error: needless `fn main` in doctest | LL | /// fn main() -> () { | _____^ -... | +LL | | +LL | | /// unimplemented!(); LL | | /// } | |_____^ @@ -24,7 +27,8 @@ error: needless `fn main` in doctest | LL | /// fn main() { | _____^ -... | +LL | | +LL | | /// unimplemented!(); LL | | /// } | |_____^ @@ -33,7 +37,9 @@ error: needless `fn main` in doctest | LL | /// // the fn is not always the first line | _____^ -... | +LL | | +LL | | /// fn main() { +LL | | /// unimplemented!(); LL | | /// } | |_____^ diff --git a/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr b/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr index 2209a63d2c0f..d15f16f7c503 100644 --- a/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr +++ b/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr @@ -2,7 +2,10 @@ error: this is an outer doc comment and does not apply to the parent module or c --> tests/ui/suspicious_doc_comments_unfixable.rs:4:1 | LL | / ///! a -... | +LL | | +LL | | +LL | | ///! b +LL | | /// c LL | | ///! d | |______^ | @@ -22,7 +25,9 @@ error: this is an outer doc comment and does not apply to the parent module or c --> tests/ui/suspicious_doc_comments_unfixable.rs:12:1 | LL | / ///! a -... | +LL | | +LL | | ///! b +LL | | /// c LL | | ///! d | |______^ | diff --git a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr index 5925d2f902a7..6ef333f0cfd2 100644 --- a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr +++ b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr @@ -2,7 +2,9 @@ error: first doc comment paragraph is too long --> tests/ui/too_long_first_doc_paragraph-fix.rs:3:1 | LL | / /// A very short summary. -... | +LL | | /// A much longer explanation that goes into a lot more detail about +LL | | /// how the thing works, possibly with doclinks and so one, +LL | | /// and probably spanning a many rows. Blablabla, it needs to be over LL | | /// 200 characters so I needed to write something longeeeeeeer. | |_^ | diff --git a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr index c40ee2fcb48f..95f42349b9b3 100644 --- a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr +++ b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr @@ -2,7 +2,9 @@ error: first doc comment paragraph is too long --> tests/ui/too_long_first_doc_paragraph.rs:8:5 | LL | / //! A very short summary. -... | +LL | | //! A much longer explanation that goes into a lot more detail about +LL | | //! how the thing works, possibly with doclinks and so one, +LL | | //! and probably spanning a many rows. Blablabla, it needs to be over LL | | //! 200 characters so I needed to write something longeeeeeeer. | |____^ | @@ -27,7 +29,8 @@ error: first doc comment paragraph is too long --> tests/ui/too_long_first_doc_paragraph.rs:36:1 | LL | / /// Lorem -... | +LL | | /// ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia +LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero, LL | | /// gravida non lacinia at, rhoncus eu lacus. | |_^ diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr index a72e21fed855..385b2ccacc1b 100644 --- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr @@ -2,7 +2,10 @@ error: unclosed quote string `"` --> $DIR/custom_code_classes_in_docs-warning3.rs:8:1 | LL | / /// ```{class="} +LL | | /// main; +LL | | /// ``` ... | +LL | | /// main; LL | | /// ``` | |_______^ | @@ -17,7 +20,10 @@ error: unclosed quote string `"` --> $DIR/custom_code_classes_in_docs-warning3.rs:8:1 | LL | / /// ```{class="} +LL | | /// main; +LL | | /// ``` ... | +LL | | /// main; LL | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/doctest/check-attr-test.stderr b/tests/rustdoc-ui/doctest/check-attr-test.stderr index 2703885b1841..257136d1633d 100644 --- a/tests/rustdoc-ui/doctest/check-attr-test.stderr +++ b/tests/rustdoc-ui/doctest/check-attr-test.stderr @@ -2,7 +2,9 @@ error: unknown attribute `compile-fail` --> $DIR/check-attr-test.rs:5:1 | 5 | / /// foo -... | +6 | | /// +7 | | /// ```compile-fail,compilefail,comPile_fail +8 | | /// boo 9 | | /// ``` | |_______^ | @@ -18,7 +20,9 @@ error: unknown attribute `compilefail` --> $DIR/check-attr-test.rs:5:1 | 5 | / /// foo -... | +6 | | /// +7 | | /// ```compile-fail,compilefail,comPile_fail +8 | | /// boo 9 | | /// ``` | |_______^ | @@ -29,7 +33,9 @@ error: unknown attribute `comPile_fail` --> $DIR/check-attr-test.rs:5:1 | 5 | / /// foo -... | +6 | | /// +7 | | /// ```compile-fail,compilefail,comPile_fail +8 | | /// boo 9 | | /// ``` | |_______^ | @@ -40,7 +46,9 @@ error: unknown attribute `should-panic` --> $DIR/check-attr-test.rs:12:1 | 12 | / /// bar -... | +13 | | /// +14 | | /// ```should-panic,shouldpanic,shOuld_panic +15 | | /// boo 16 | | /// ``` | |_______^ | @@ -51,7 +59,9 @@ error: unknown attribute `shouldpanic` --> $DIR/check-attr-test.rs:12:1 | 12 | / /// bar -... | +13 | | /// +14 | | /// ```should-panic,shouldpanic,shOuld_panic +15 | | /// boo 16 | | /// ``` | |_______^ | @@ -62,7 +72,9 @@ error: unknown attribute `shOuld_panic` --> $DIR/check-attr-test.rs:12:1 | 12 | / /// bar -... | +13 | | /// +14 | | /// ```should-panic,shouldpanic,shOuld_panic +15 | | /// boo 16 | | /// ``` | |_______^ | @@ -73,7 +85,9 @@ error: unknown attribute `no-run` --> $DIR/check-attr-test.rs:19:1 | 19 | / /// foobar -... | +20 | | /// +21 | | /// ```no-run,norun,nO_run +22 | | /// boo 23 | | /// ``` | |_______^ | @@ -84,7 +98,9 @@ error: unknown attribute `norun` --> $DIR/check-attr-test.rs:19:1 | 19 | / /// foobar -... | +20 | | /// +21 | | /// ```no-run,norun,nO_run +22 | | /// boo 23 | | /// ``` | |_______^ | @@ -95,7 +111,9 @@ error: unknown attribute `nO_run` --> $DIR/check-attr-test.rs:19:1 | 19 | / /// foobar -... | +20 | | /// +21 | | /// ```no-run,norun,nO_run +22 | | /// boo 23 | | /// ``` | |_______^ | @@ -106,7 +124,9 @@ error: unknown attribute `test-harness` --> $DIR/check-attr-test.rs:26:1 | 26 | / /// b -... | +27 | | /// +28 | | /// ```test-harness,testharness,tesT_harness +29 | | /// boo 30 | | /// ``` | |_______^ | @@ -117,7 +137,9 @@ error: unknown attribute `testharness` --> $DIR/check-attr-test.rs:26:1 | 26 | / /// b -... | +27 | | /// +28 | | /// ```test-harness,testharness,tesT_harness +29 | | /// boo 30 | | /// ``` | |_______^ | @@ -128,7 +150,9 @@ error: unknown attribute `tesT_harness` --> $DIR/check-attr-test.rs:26:1 | 26 | / /// b -... | +27 | | /// +28 | | /// ```test-harness,testharness,tesT_harness +29 | | /// boo 30 | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/doctest/private-item-doc-test.stderr b/tests/rustdoc-ui/doctest/private-item-doc-test.stderr index 7ce1f0314991..5177057c7284 100644 --- a/tests/rustdoc-ui/doctest/private-item-doc-test.stderr +++ b/tests/rustdoc-ui/doctest/private-item-doc-test.stderr @@ -2,7 +2,9 @@ error: documentation test in private item --> $DIR/private-item-doc-test.rs:4:5 | LL | / /// private doc test -... | +LL | | /// +LL | | /// ``` +LL | | /// assert!(false); LL | | /// ``` | |___________^ | diff --git a/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr b/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr index aa01f39314c9..38b8dd652d3e 100644 --- a/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr +++ b/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr @@ -2,7 +2,9 @@ error: documentation test in private item --> $DIR/private-public-item-doc-test.rs:4:5 | LL | / /// private doc test -... | +LL | | /// +LL | | /// ``` +LL | | /// assert!(false); LL | | /// ``` | |___________^ | diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr index 662f07f3a4cc..bfc1e9194045 100644 --- a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr +++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr @@ -2,7 +2,11 @@ error: unknown attribute `standalone` --> $DIR/standalone-warning-2024.rs:11:1 | 11 | / //! ```standalone -... | +12 | | //! bla +13 | | //! ``` +14 | | //! +15 | | //! ```standalone-crate +16 | | //! bla 17 | | //! ``` | |_______^ | @@ -19,7 +23,11 @@ error: unknown attribute `standalone-crate` --> $DIR/standalone-warning-2024.rs:11:1 | 11 | / //! ```standalone -... | +12 | | //! bla +13 | | //! ``` +14 | | //! +15 | | //! ```standalone-crate +16 | | //! bla 17 | | //! ``` | |_______^ | diff --git a/tests/rustdoc-ui/invalid-syntax.stderr b/tests/rustdoc-ui/invalid-syntax.stderr index f30660017d9d..c6e1f6fd4138 100644 --- a/tests/rustdoc-ui/invalid-syntax.stderr +++ b/tests/rustdoc-ui/invalid-syntax.stderr @@ -21,7 +21,9 @@ warning: could not parse code block as Rust code | LL | /// ``` | _____^ -... | +LL | | /// | +LL | | /// LL | use foobar::Baz; +LL | | /// | ^^^^^^ did you mean `baz::foobar`? LL | | /// ``` | |_______^ | @@ -112,7 +114,8 @@ warning: Rust code block is empty | LL | /// ``` | _____^ -... | +LL | | /// +LL | | /// LL | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/lints/check-attr.stderr b/tests/rustdoc-ui/lints/check-attr.stderr index 4576dea79cbd..3366c021727c 100644 --- a/tests/rustdoc-ui/lints/check-attr.stderr +++ b/tests/rustdoc-ui/lints/check-attr.stderr @@ -3,6 +3,7 @@ error: unknown attribute `compile-fail` | LL | / /// foo ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -19,6 +20,7 @@ error: unknown attribute `compilefail` | LL | / /// foo ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -30,6 +32,7 @@ error: unknown attribute `comPile_fail` | LL | / /// foo ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -41,6 +44,7 @@ error: unknown attribute `should-panic` | LL | / /// bar ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -52,6 +56,7 @@ error: unknown attribute `shouldpanic` | LL | / /// bar ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -63,6 +68,7 @@ error: unknown attribute `sHould_panic` | LL | / /// bar ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -74,6 +80,7 @@ error: unknown attribute `no-run` | LL | / /// foobar ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -85,6 +92,7 @@ error: unknown attribute `norun` | LL | / /// foobar ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -96,6 +104,7 @@ error: unknown attribute `no_Run` | LL | / /// foobar ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -107,6 +116,7 @@ error: unknown attribute `test-harness` | LL | / /// b ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -118,6 +128,7 @@ error: unknown attribute `testharness` | LL | / /// b ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -129,6 +140,7 @@ error: unknown attribute `teSt_harness` | LL | / /// b ... | +LL | | /// boo LL | | /// ``` | |_______^ | @@ -139,7 +151,10 @@ error: unknown attribute `rust2018` --> $DIR/check-attr.rs:43:1 | LL | / /// b -... | +LL | | +LL | | /// +LL | | /// ```rust2018 +LL | | /// boo LL | | /// ``` | |_______^ | @@ -149,7 +164,11 @@ error: unknown attribute `rust2018` --> $DIR/check-attr.rs:51:1 | LL | / /// b -... | +LL | | +LL | | +LL | | /// +LL | | /// ```rust2018 shouldpanic +LL | | /// boo LL | | /// ``` | |_______^ | @@ -159,7 +178,11 @@ error: unknown attribute `shouldpanic` --> $DIR/check-attr.rs:51:1 | LL | / /// b -... | +LL | | +LL | | +LL | | /// +LL | | /// ```rust2018 shouldpanic +LL | | /// boo LL | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/lints/check-fail.stderr b/tests/rustdoc-ui/lints/check-fail.stderr index f021f0c42e5a..2eb9496e5dc9 100644 --- a/tests/rustdoc-ui/lints/check-fail.stderr +++ b/tests/rustdoc-ui/lints/check-fail.stderr @@ -26,7 +26,8 @@ error: unknown attribute `testharness` --> $DIR/check-fail.rs:8:1 | LL | / //! ```rust,testharness -... | +LL | | +LL | | //! let x = 12; LL | | //! ``` | |_______^ | @@ -43,7 +44,10 @@ error: unknown attribute `testharness` --> $DIR/check-fail.rs:17:1 | LL | / /// hello -... | +LL | | +LL | | /// +LL | | /// ```rust,testharness +LL | | /// let x = 12; LL | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/lints/lint-group.stderr b/tests/rustdoc-ui/lints/lint-group.stderr index 4b5b64c4378f..7ff09fcc45a1 100644 --- a/tests/rustdoc-ui/lints/lint-group.stderr +++ b/tests/rustdoc-ui/lints/lint-group.stderr @@ -14,7 +14,9 @@ error: documentation test in private item --> $DIR/lint-group.rs:22:1 | LL | / /// wait, this *does* have a doctest? -... | +LL | | /// +LL | | /// ``` +LL | | /// println!("sup"); LL | | /// ``` | |_______^ | diff --git a/tests/rustdoc-ui/unescaped_backticks.stderr b/tests/rustdoc-ui/unescaped_backticks.stderr index 01b2fd1fa272..d93aaf5f3ca9 100644 --- a/tests/rustdoc-ui/unescaped_backticks.stderr +++ b/tests/rustdoc-ui/unescaped_backticks.stderr @@ -272,6 +272,7 @@ error: unescaped backtick | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], ... | +LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max LL | | /// level changes. | |______________________^ | @@ -287,6 +288,7 @@ error: unescaped backtick | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], ... | +LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max LL | | /// level changes. | |______________________^ | @@ -300,6 +302,7 @@ error: unescaped backtick | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], ... | +LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max LL | | /// level changes. | |______________________^ | @@ -315,6 +318,7 @@ error: unescaped backtick | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], ... | +LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max LL | | /// level changes. | |______________________^ | diff --git a/tests/ui/macros/issue-112342-1.stderr b/tests/ui/macros/issue-112342-1.stderr index 73a7fe3a1277..f2d82bf599e9 100644 --- a/tests/ui/macros/issue-112342-1.stderr +++ b/tests/ui/macros/issue-112342-1.stderr @@ -55,7 +55,8 @@ error: repetition matches empty token tree | LL | $( | __________^ -... | +LL | | /// +LL | | /// LL | | )* | |_________^ From af3721e8132a8d5268a1e263f7058cdb65fbbac2 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:39:11 +0100 Subject: [PATCH 19/19] Document the symbol Visibility enum --- compiler/rustc_middle/src/mir/mono.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index 1f50b67cb50d..266dc7ad2b3b 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -294,10 +294,22 @@ pub enum Linkage { Common, } +/// Specifies the symbol visibility with regards to dynamic linking. +/// +/// Visibility doesn't have any effect when linkage is internal. +/// +/// DSO means dynamic shared object, that is a dynamically linked executable or dylib. #[derive(Copy, Clone, PartialEq, Debug, HashStable)] pub enum Visibility { + /// Export the symbol from the DSO and apply overrides of the symbol by outside DSOs to within + /// the DSO if the object file format supports this. Default, + /// Hide the symbol outside of the defining DSO even when external linkage is used to export it + /// from the object file. Hidden, + /// Export the symbol from the DSO, but don't apply overrides of the symbol by outside DSOs to + /// within the DSO. Equivalent to default visibility with object file formats that don't support + /// overriding exported symbols by another DSO. Protected, }