From 41e6f767b64cebd08e1a25b18dfea7c13bf36a6a Mon Sep 17 00:00:00 2001 From: dianne Date: Wed, 16 Jul 2025 01:44:02 -0700 Subject: [PATCH 01/28] future-incompat lints: don't link to the nightly edition-guide version --- compiler/rustc_hir_typeck/src/upvar.rs | 2 +- compiler/rustc_lint/messages.ftl | 2 +- compiler/rustc_lint/src/builtin.rs | 4 +- compiler/rustc_lint/src/if_let_rescope.rs | 2 +- .../rustc_lint/src/impl_trait_overcaptures.rs | 2 +- ..._expr_fragment_specifier_2024_migration.rs | 4 +- compiler/rustc_lint/src/shadowed_into_iter.rs | 4 +- compiler/rustc_lint/src/static_mut_refs.rs | 2 +- compiler/rustc_lint_defs/src/builtin.rs | 26 +++++----- .../checked_unwrap/simple_conditionals.stderr | 2 +- ...rowck-unsafe-static-mutable-borrows.stderr | 2 +- .../2229_closure_analysis/issue-90465.stderr | 2 +- .../migrations/auto_traits.stderr | 6 +-- .../closure-body-macro-fragment.stderr | 2 +- .../insignificant_drop_attr_migrations.stderr | 4 +- .../migrations/macro.stderr | 2 +- .../migrations/migrations_rustfix.stderr | 4 +- .../migrations/mir_calls_to_shims.stderr | 2 +- .../migrations/multi_diagnostics.stderr | 10 ++-- .../migrations/precise.stderr | 4 +- .../migrations/significant_drop.stderr | 20 +++---- .../const_panic_stability.e2018.stderr | 2 +- tests/ui/consts/const_let_assign2.stderr | 2 +- .../const_refs_to_static-ice-121413.stderr | 2 +- .../bad-assoc-ty.edition2015.stderr | 2 +- .../drop/drop-order-comparisons.e2021.stderr | 30 +++++------ ...nt-if-let-rescope-gated.edition2021.stderr | 2 +- .../lint-if-let-rescope-with-macro.stderr | 2 +- tests/ui/drop/lint-if-let-rescope.stderr | 16 +++--- .../lint-tail-expr-drop-order-borrowck.stderr | 8 +-- .../ui/drop/lint-tail-expr-drop-order.stderr | 16 +++--- ...expr_drop_order-on-coroutine-unwind.stderr | 2 +- .../avoid-ice-on-warning-2.old.stderr | 4 +- .../avoid-ice-on-warning-3.old.stderr | 12 ++--- .../avoid-ice-on-warning.old.stderr | 2 +- .../bare-trait-dont-suggest-dyn.old.stderr | 2 +- .../dyn-keyword/dyn-2018-edition-lint.stderr | 6 +-- .../ui/dyn-keyword/dyn-angle-brackets.stderr | 2 +- .../never-type-fallback-breaking.e2021.stderr | 20 +++---- .../closure/rfc2229-migration.stderr | 2 +- ...dynless-turbofish-e0191-issue-91997.stderr | 2 +- ...lifetime-from-bare-trait-obj-114664.stderr | 4 +- ...vercaptures-2024-machine-applicable.stderr | 2 +- .../overcaptures-2024.stderr | 16 +++--- tests/ui/issues/issue-28344.stderr | 4 +- tests/ui/issues/issue-39367.stderr | 2 +- tests/ui/issues/issue-58734.stderr | 2 +- tests/ui/issues/issue-86756.stderr | 2 +- .../iterators/into-iter-on-arrays-2018.stderr | 10 ++-- .../iterators/into-iter-on-arrays-lint.stderr | 24 ++++----- .../into-iter-on-boxed-slices-2021.stderr | 10 ++-- .../into-iter-on-boxed-slices-lint.stderr | 6 +-- tests/ui/lint/bare-trait-objects-path.stderr | 8 +-- .../allowed-group-warn-by-default-lint.stderr | 2 +- .../ui/lint/force-warn/cap-lints-allow.stderr | 2 +- ...s-warn-allowed-warn-by-default-lint.stderr | 2 +- ...up-allowed-cli-warn-by-default-lint.stderr | 2 +- .../lint-group-allowed-lint-group.stderr | 2 +- ...-group-allowed-warn-by-default-lint.stderr | 2 +- .../inclusive-range-pattern-syntax.stderr | 4 +- .../ui/lint/lint-attr-everywhere-early.stderr | 4 +- tests/ui/lint/static-mut-refs.e2021.stderr | 24 ++++----- tests/ui/lint/static-mut-refs.e2024.stderr | 24 ++++----- .../macros/expr_2021_cargo_fix_edition.stderr | 4 +- .../macro-or-patterns-back-compat.stderr | 8 +-- tests/ui/macros/non-fmt-panic.stderr | 52 +++++++++---------- .../defaulted-never-note.nofallback.stderr | 4 +- .../dependency-on-fallback-to-unit.stderr | 8 +-- ...ng-fallback-control-flow.nofallback.stderr | 8 +-- ...verging-fallback-no-leak.nofallback.stderr | 4 +- ...ack-unconstrained-return.nofallback.stderr | 4 +- ...nt-suggest-turbofish-from-expansion.stderr | 4 +- .../fallback-closure-ret.nofallback.stderr | 4 +- .../ui/never_type/impl_trait_fallback.stderr | 4 +- ...int-breaking-2024-assign-underscore.stderr | 4 +- ...-fallback-flowing-into-unsafe.e2015.stderr | 40 +++++++------- ...-fallback-flowing-into-unsafe.e2024.stderr | 40 +++++++------- ...local-static-mut-borrow-outlives-fn.stderr | 2 +- .../parser/recover/recover-pat-ranges.stderr | 2 +- .../parser/recover/recover-range-pats.stderr | 18 +++---- .../parser/trait-object-trait-parens.stderr | 6 +-- .../range-inclusive-pattern-precedence.stderr | 2 +- ...range-inclusive-pattern-precedence2.stderr | 2 +- .../safe-calls.stderr | 2 +- .../array-into-iter-ambiguous.stderr | 2 +- ...ure-prelude-collision-generic-trait.stderr | 2 +- .../future-prelude-collision-generic.stderr | 6 +-- .../future-prelude-collision-imported.stderr | 8 +-- .../future-prelude-collision-macros.stderr | 4 +- .../future-prelude-collision-turbofish.stderr | 4 +- .../rust-2021/future-prelude-collision.stderr | 16 +++--- .../rust-2021/generic-type-collision.stderr | 2 +- .../rust-2021/inherent-dyn-collision.stderr | 2 +- .../reserved-prefixes-migration.stderr | 10 ++-- .../box-slice-into-iter-ambiguous.stderr | 2 +- tests/ui/rust-2024/gen-kw.e2015.stderr | 16 +++--- tests/ui/rust-2024/gen-kw.e2018.stderr | 16 +++--- .../future-poll-async-block.e2021.stderr | 2 +- ...future-poll-not-future-pinned.e2021.stderr | 2 +- .../in_2024_compatibility.stderr | 2 +- .../into-future-adt.e2021.stderr | 2 +- .../into-future-not-into-future.e2021.stderr | 2 +- .../reserved-guarded-strings-lexing.stderr | 36 ++++++------- .../reserved-guarded-strings-migration.stderr | 44 ++++++++-------- .../in_2024_compatibility.stderr | 2 +- .../unsafe-attributes-fix.stderr | 14 ++--- .../ui/rust-2024/unsafe-env-suggestion.stderr | 4 +- tests/ui/rust-2024/unsafe-env.e2021.stderr | 2 +- tests/ui/rust-2024/unsafe-env.e2024.stderr | 6 +-- .../unsafe-extern-suggestion.stderr | 2 +- tests/ui/statics/issue-15261.stderr | 2 +- .../statics/static-mut-shared-parens.stderr | 4 +- tests/ui/statics/static-mut-xc.stderr | 14 ++--- tests/ui/statics/static-recursive.stderr | 4 +- tests/ui/suggestions/issue-116434-2015.stderr | 8 +-- tests/ui/suggestions/issue-61963.stderr | 4 +- .../suggest-swapping-self-ty-and-trait.stderr | 6 +-- .../ui/traits/bound/not-on-bare-trait.stderr | 2 +- .../missing-for-type-in-impl.e2015.stderr | 4 +- .../unspecified-self-in-trait-ref.stderr | 10 ++-- ...edition-2024-unsafe_op_in_unsafe_fn.stderr | 2 +- .../edition_2024_default.stderr | 2 +- .../in_2024_compatibility.stderr | 2 +- .../rfc-2585-unsafe_op_in_unsafe_fn.stderr | 12 ++--- .../wrapping-unsafe-block-sugg.stderr | 16 +++--- ...ir-wf-check-anon-const-issue-122989.stderr | 4 +- 126 files changed, 465 insertions(+), 465 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index be774106abf8f..df38c3a121436 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -1047,7 +1047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } } - lint.note("for more information, see "); + lint.note("for more information, see "); let diagnostic_msg = format!( "add a dummy let to cause {migrated_variables_concat} to be fully captured" diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 8d9f2385b710f..1ff253a20210f 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -569,7 +569,7 @@ lint_non_camel_case_type = {$sort} `{$name}` should have an upper camel case nam lint_non_fmt_panic = panic message is not a string literal .note = this usage of `{$name}!()` is deprecated; it will be a hard error in Rust 2021 - .more_info_note = for more information, see + .more_info_note = for more information, see .supports_fmt_note = the `{$name}!()` macro supports formatting, so there's no need for the `format!()` macro here .supports_fmt_suggestion = remove the `format!(..)` macro call .display_suggestion = add a "{"{"}{"}"}" format string to `Display` the message diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 255ff56f62b1d..c736775d7f83d 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1651,7 +1651,7 @@ declare_lint! { "`...` range patterns are deprecated", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021), - reference: "", + reference: "", }; } @@ -1832,7 +1832,7 @@ declare_lint! { "detects edition keywords being used as an identifier", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024), - reference: "", + reference: "", }; } diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 263ea6fa07080..ff67ed1bc5532 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -87,7 +87,7 @@ declare_lint! { rewriting in `match` is an option to preserve the semantics up to Edition 2021", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), - reference: "", + reference: "", }; } diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index c17281deff4e4..b9afb62cf1c64 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -71,7 +71,7 @@ declare_lint! { "`impl Trait` will capture more lifetimes than possibly intended in edition 2024", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), - reference: "", + reference: "", }; } diff --git a/compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs b/compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs index ce280fef8b623..7de6fbd941b44 100644 --- a/compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs +++ b/compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs @@ -65,7 +65,7 @@ declare_lint! { /// to ensure the macros implement the desired behavior. /// /// [editions]: https://doc.rust-lang.org/edition-guide/ - /// [macro matcher fragment specifiers]: https://doc.rust-lang.org/nightly/edition-guide/rust-2024/macro-fragment-specifiers.html + /// [macro matcher fragment specifiers]: https://doc.rust-lang.org/edition-guide/rust-2024/macro-fragment-specifiers.html /// [`cargo fix`]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html pub EDITION_2024_EXPR_FRAGMENT_SPECIFIER, Allow, @@ -73,7 +73,7 @@ declare_lint! { To keep the existing behavior, use the `expr_2021` fragment specifier.", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), - reference: "Migration Guide ", + reference: "Migration Guide ", }; } diff --git a/compiler/rustc_lint/src/shadowed_into_iter.rs b/compiler/rustc_lint/src/shadowed_into_iter.rs index 00fa0499556cb..d296ae46f43e7 100644 --- a/compiler/rustc_lint/src/shadowed_into_iter.rs +++ b/compiler/rustc_lint/src/shadowed_into_iter.rs @@ -32,7 +32,7 @@ declare_lint! { "detects calling `into_iter` on arrays in Rust 2015 and 2018", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021), - reference: "", + reference: "", }; } @@ -61,7 +61,7 @@ declare_lint! { "detects calling `into_iter` on boxed slices in Rust 2015, 2018, and 2021", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), - reference: "" + reference: "" }; } diff --git a/compiler/rustc_lint/src/static_mut_refs.rs b/compiler/rustc_lint/src/static_mut_refs.rs index 4dda3c7951b87..16e1fb0192b32 100644 --- a/compiler/rustc_lint/src/static_mut_refs.rs +++ b/compiler/rustc_lint/src/static_mut_refs.rs @@ -54,7 +54,7 @@ declare_lint! { "creating a shared reference to mutable static", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024), - reference: "", + reference: "", explain_reason: false, }; @edition Edition2024 => Deny; diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index a08d68e2d1532..b1edb5c304425 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1814,7 +1814,7 @@ declare_lint! { "suggest using `dyn Trait` for trait objects", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021), - reference: "", + reference: "", }; } @@ -2472,7 +2472,7 @@ declare_lint! { "unsafe operations in unsafe functions without an explicit unsafe block are deprecated", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), - reference: "", + reference: "", explain_reason: false }; @edition Edition2024 => Warn; @@ -3445,7 +3445,7 @@ declare_lint! { "detects usage of old versions of or-patterns", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021), - reference: "", + reference: "", }; } @@ -3494,7 +3494,7 @@ declare_lint! { prelude in future editions", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021), - reference: "", + reference: "", }; } @@ -3534,7 +3534,7 @@ declare_lint! { prelude in future editions", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024), - reference: "", + reference: "", }; } @@ -3571,7 +3571,7 @@ declare_lint! { "identifiers that will be parsed as a prefix in Rust 2021", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021), - reference: "", + reference: "", }; crate_level_only } @@ -4100,7 +4100,7 @@ declare_lint! { "never type fallback affecting unsafe function calls", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(Edition::Edition2024), - reference: "", + reference: "", report_in_deps: true, }; @edition Edition2024 => Deny; @@ -4155,7 +4155,7 @@ declare_lint! { "never type fallback affecting unsafe function calls", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024), - reference: "", + reference: "", report_in_deps: true, }; report_in_external_macro @@ -4740,7 +4740,7 @@ declare_lint! { "detects unsafe functions being used as safe functions", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024), - reference: "", + reference: "", }; } @@ -4776,7 +4776,7 @@ declare_lint! { "detects missing unsafe keyword on extern declarations", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024), - reference: "", + reference: "", }; } @@ -4817,7 +4817,7 @@ declare_lint! { "detects unsafe attributes outside of unsafe", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024), - reference: "", + reference: "", }; } @@ -5014,7 +5014,7 @@ declare_lint! { "Detect and warn on significant change in drop order in tail expression location", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), - reference: "", + reference: "", }; } @@ -5053,7 +5053,7 @@ declare_lint! { "will be parsed as a guarded string in Rust 2024", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024), - reference: "", + reference: "", }; crate_level_only } diff --git a/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr b/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr index a4bf00992445e..26e360112b6b3 100644 --- a/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr +++ b/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr @@ -328,7 +328,7 @@ error: creating a shared reference to mutable static LL | if X.is_some() { | ^^^^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives = note: `#[deny(static_mut_refs)]` on by default diff --git a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr index 4e19fd81735e1..c55923097fcd2 100644 --- a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr +++ b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr @@ -4,7 +4,7 @@ warning: creating a mutable reference to mutable static LL | let sfoo: *mut Foo = &mut SFOO; | ^^^^^^^^^ mutable reference to mutable static | - = note: for more information, see + = note: for more information, see = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives = note: `#[warn(static_mut_refs)]` on by default help: use `&raw mut` instead to create a raw pointer diff --git a/tests/ui/closures/2229_closure_analysis/issue-90465.stderr b/tests/ui/closures/2229_closure_analysis/issue-90465.stderr index ccca24764e42a..94bbd79cbb4f3 100644 --- a/tests/ui/closures/2229_closure_analysis/issue-90465.stderr +++ b/tests/ui/closures/2229_closure_analysis/issue-90465.stderr @@ -10,7 +10,7 @@ LL | let _ = f0; LL | } | - in Rust 2018, `f0` is dropped here along with the closure, but in Rust 2021 `f0` is not part of the closure | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/issue-90465.rs:3:9 | diff --git a/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr b/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr index fdcada468e093..b981ef69b4fa8 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr @@ -7,7 +7,7 @@ LL | thread::spawn(move || unsafe { LL | *fptr.0 = 20; | ------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0` | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/auto_traits.rs:2:9 | @@ -34,7 +34,7 @@ LL | thread::spawn(move || unsafe { LL | *fptr.0.0 = 20; | --------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0.0` | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `fptr` to be fully captured | LL ~ thread::spawn(move || { let _ = &fptr; unsafe { @@ -56,7 +56,7 @@ LL | let f_1 = f.1; LL | } | - in Rust 2018, `f` is dropped here, but in Rust 2021, only `f.1` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `f` to be fully captured | LL ~ let c = || { diff --git a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr index bb17e3a34af61..c49b1d2d0e069 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/closure-body-macro-fragment.stderr @@ -15,7 +15,7 @@ LL | | println!("{:?}", x); LL | | }); | |______- in this macro invocation | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/closure-body-macro-fragment.rs:4:9 | diff --git a/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr b/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr index a0795c12928ff..3381b9e334b47 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr @@ -10,7 +10,7 @@ LL | let _t = t.0; LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/insignificant_drop_attr_migrations.rs:3:9 | @@ -34,7 +34,7 @@ LL | let _t = t.1; LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `t` to be fully captured | LL ~ let c = move || { diff --git a/tests/ui/closures/2229_closure_analysis/migrations/macro.stderr b/tests/ui/closures/2229_closure_analysis/migrations/macro.stderr index 7ea5136d11910..7d90b7bf72bd9 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/macro.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/macro.stderr @@ -7,7 +7,7 @@ LL | let _ = || dbg!(a.0); LL | } | - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/macro.rs:5:9 | diff --git a/tests/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr b/tests/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr index 94526487e6792..7d937f512493a 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr @@ -10,7 +10,7 @@ LL | let _t = t.0; LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/migrations_rustfix.rs:2:9 | @@ -31,7 +31,7 @@ LL | let c = || t.0; LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `t` to be fully captured | LL | let c = || { let _ = &t; t.0 }; diff --git a/tests/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr b/tests/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr index 2b76deca37708..6a9266ecc544a 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr @@ -10,7 +10,7 @@ LL | let result = panic::catch_unwind(move || { LL | f.0() | --- in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.0` | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/mir_calls_to_shims.rs:4:9 | diff --git a/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr b/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr index 138778ff5d723..81ffe866c8376 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr @@ -13,7 +13,7 @@ LL | let _f_2 = f2.1; LL | } | - in Rust 2018, `f2` is dropped here, but in Rust 2021, only `f2.1` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/multi_diagnostics.rs:2:9 | @@ -34,7 +34,7 @@ LL | let c = || { LL | let _f_1 = f1.0; | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.0` | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `f1` to be fully captured | LL ~ let c = || { @@ -56,7 +56,7 @@ LL | LL | let _f_2 = f1.2; | ---- in Rust 2018, this closure captures all of `f1`, but in Rust 2021, it will only capture `f1.2` | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `f1` to be fully captured | LL ~ let c = || { @@ -81,7 +81,7 @@ LL | } | in Rust 2018, `f1` is dropped here, but in Rust 2021, only `f1.0` will be dropped here as part of the closure | in Rust 2018, `f1` is dropped here, but in Rust 2021, only `f1.1` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `f1` to be fully captured | LL ~ let c = || { @@ -104,7 +104,7 @@ LL | LL | *fptr2.0 = 20; | -------- in Rust 2018, this closure captures all of `fptr2`, but in Rust 2021, it will only capture `fptr2.0` | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `fptr1`, `fptr2` to be fully captured | LL ~ thread::spawn(move || { let _ = (&fptr1, &fptr2); unsafe { diff --git a/tests/ui/closures/2229_closure_analysis/migrations/precise.stderr b/tests/ui/closures/2229_closure_analysis/migrations/precise.stderr index eff26a4d6f5f6..5fb7675207f4d 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/precise.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/precise.stderr @@ -10,7 +10,7 @@ LL | let _t = t.0; LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/precise.rs:3:9 | @@ -44,7 +44,7 @@ LL | } | in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.0.1` will be dropped here as part of the closure | in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.1.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `u` to be fully captured | LL ~ let c = || { diff --git a/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr b/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr index 54ad20f898338..3f4d38aefe7a6 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr @@ -20,7 +20,7 @@ LL | } | in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.0` will be dropped here as part of the closure | in Rust 2018, `t2` is dropped here, but in Rust 2021, only `t2.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/significant_drop.rs:2:9 | @@ -50,7 +50,7 @@ LL | } | in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `t`, `t1` to be fully captured | LL ~ let c = || { @@ -69,7 +69,7 @@ LL | let _t = t.0; LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { @@ -88,7 +88,7 @@ LL | let _t = t.0; LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { @@ -107,7 +107,7 @@ LL | let _t = t.0; LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { @@ -126,7 +126,7 @@ LL | let _t = t.1; LL | } | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { @@ -150,7 +150,7 @@ LL | } | in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.1` will be dropped here as part of the closure | in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `t1`, `t` to be fully captured | LL ~ let c = move || { @@ -169,7 +169,7 @@ LL | tuple.0; LL | } | - in Rust 2018, `tuple` is dropped here, but in Rust 2021, only `tuple.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `tuple` to be fully captured | LL ~ let c = || { @@ -188,7 +188,7 @@ LL | tuple.0; LL | }; | - in Rust 2018, `tuple` is dropped here, but in Rust 2021, only `tuple.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `tuple` to be fully captured | LL ~ let c = || { @@ -204,7 +204,7 @@ LL | let _c = || tup.0; LL | } | - in Rust 2018, `tup` is dropped here, but in Rust 2021, only `tup.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see help: add a dummy let to cause `tup` to be fully captured | LL | let _c = || { let _ = &tup; tup.0 }; diff --git a/tests/ui/consts/const-eval/const_panic_stability.e2018.stderr b/tests/ui/consts/const-eval/const_panic_stability.e2018.stderr index 3553a18d3883c..b3ccd2459aacc 100644 --- a/tests/ui/consts/const-eval/const_panic_stability.e2018.stderr +++ b/tests/ui/consts/const-eval/const_panic_stability.e2018.stderr @@ -5,7 +5,7 @@ LL | panic!({ "foo" }); | ^^^^^^^^^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see = note: `#[warn(non_fmt_panics)]` on by default help: add a "{}" format string to `Display` the message | diff --git a/tests/ui/consts/const_let_assign2.stderr b/tests/ui/consts/const_let_assign2.stderr index 1bb560437b60e..e8bed6d07246b 100644 --- a/tests/ui/consts/const_let_assign2.stderr +++ b/tests/ui/consts/const_let_assign2.stderr @@ -4,7 +4,7 @@ warning: creating a mutable reference to mutable static LL | let ptr = unsafe { &mut BB }; | ^^^^^^^ mutable reference to mutable static | - = note: for more information, see + = note: for more information, see = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives = note: `#[warn(static_mut_refs)]` on by default help: use `&raw mut` instead to create a raw pointer diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.stderr b/tests/ui/consts/const_refs_to_static-ice-121413.stderr index 1263deebf76de..e354110f2930c 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.stderr +++ b/tests/ui/consts/const_refs_to_static-ice-121413.stderr @@ -16,7 +16,7 @@ LL | static FOO: Sync = AtomicUsize::new(0); | ^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr index ed6e5c3e0c016..416ff358d5382 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr @@ -186,7 +186,7 @@ LL | type H = Fn(u8) -> (u8)::Output; | ^^^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/drop/drop-order-comparisons.e2021.stderr b/tests/ui/drop/drop-order-comparisons.e2021.stderr index 15a3f27451435..d928403d2e34b 100644 --- a/tests/ui/drop/drop-order-comparisons.e2021.stderr +++ b/tests/ui/drop/drop-order-comparisons.e2021.stderr @@ -27,7 +27,7 @@ LL | | }, e.mark(3), e.ok(4)); | `#1` will be dropped later as of Edition 2024 | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#3` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -75,7 +75,7 @@ LL | | }, e.mark(1), e.ok(4)); | `#1` will be dropped later as of Edition 2024 | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -107,7 +107,7 @@ LL | | }, e.mark(1), e.ok(4)); | `#1` will be dropped later as of Edition 2024 | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -139,7 +139,7 @@ LL | | }, e.mark(2), e.ok(3)); | `#1` will be dropped later as of Edition 2024 | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -171,7 +171,7 @@ LL | | }, e.mark(2), e.ok(3)); | `#1` will be dropped later as of Edition 2024 | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -193,7 +193,7 @@ LL | _ = (if let Ok(_) = e.ok(4).as_ref() { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -223,7 +223,7 @@ LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -252,7 +252,7 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -281,7 +281,7 @@ LL | if let true = e.err(9).is_ok() {} else { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -310,7 +310,7 @@ LL | if let Ok(_v) = e.err(8) {} else { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -339,7 +339,7 @@ LL | if let Ok(_) = e.err(7) {} else { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -368,7 +368,7 @@ LL | if let Ok(_) = e.err(6).as_ref() {} else { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -397,7 +397,7 @@ LL | if let Ok(_v) = e.err(5) {} else { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -426,7 +426,7 @@ LL | if let Ok(_) = e.err(4) {} else { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | @@ -455,7 +455,7 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:504:1 | diff --git a/tests/ui/drop/lint-if-let-rescope-gated.edition2021.stderr b/tests/ui/drop/lint-if-let-rescope-gated.edition2021.stderr index 0d6974d516b6e..5f04273d336d6 100644 --- a/tests/ui/drop/lint-if-let-rescope-gated.edition2021.stderr +++ b/tests/ui/drop/lint-if-let-rescope-gated.edition2021.stderr @@ -7,7 +7,7 @@ LL | if let Some(_value) = Droppy.get() { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope-gated.rs:14:1 | diff --git a/tests/ui/drop/lint-if-let-rescope-with-macro.stderr b/tests/ui/drop/lint-if-let-rescope-with-macro.stderr index a0afb8eddb532..63e30f1ab92e4 100644 --- a/tests/ui/drop/lint-if-let-rescope-with-macro.stderr +++ b/tests/ui/drop/lint-if-let-rescope-with-macro.stderr @@ -14,7 +14,7 @@ LL | | }; | |_____- in this macro invocation | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope-with-macro.rs:22:1 | diff --git a/tests/ui/drop/lint-if-let-rescope.stderr b/tests/ui/drop/lint-if-let-rescope.stderr index ca2416efcb1a2..7cab7339fe1e5 100644 --- a/tests/ui/drop/lint-if-let-rescope.stderr +++ b/tests/ui/drop/lint-if-let-rescope.stderr @@ -7,7 +7,7 @@ LL | if let Some(_value) = droppy().get() { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -47,7 +47,7 @@ LL | } else if let Some(_value) = droppy().get() { | -------- this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -89,7 +89,7 @@ LL | } else if let Some(_value) = droppy().get() { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -120,7 +120,7 @@ LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -146,7 +146,7 @@ LL | if (if let Some(_value) = droppy().get() { true } else { false }) { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -172,7 +172,7 @@ LL | } else if (((if let Some(_value) = droppy().get() { true } else { false | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -198,7 +198,7 @@ LL | while (if let Some(_value) = droppy().get() { false } else { true }) { | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -224,7 +224,7 @@ LL | if let Some(_value) = Some((droppy(), ()).1) {} else {} | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see help: the value is now dropped here in Edition 2024 --> $DIR/lint-if-let-rescope.rs:97:51 | diff --git a/tests/ui/drop/lint-tail-expr-drop-order-borrowck.stderr b/tests/ui/drop/lint-tail-expr-drop-order-borrowck.stderr index a55e366dd0be1..2eeda8ac387fd 100644 --- a/tests/ui/drop/lint-tail-expr-drop-order-borrowck.stderr +++ b/tests/ui/drop/lint-tail-expr-drop-order-borrowck.stderr @@ -7,7 +7,7 @@ LL | let _ = { String::new().as_str() }.len(); | this temporary value will be dropped at the end of the block | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/lint-tail-expr-drop-order-borrowck.rs:6:9 | @@ -23,7 +23,7 @@ LL | f(unsafe { String::new().as_str() }.len()); | this temporary value will be dropped at the end of the block | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see error: relative drop order changing in Rust 2024 --> $DIR/lint-tail-expr-drop-order-borrowck.rs:31:9 @@ -35,7 +35,7 @@ LL | &mut || 0 | borrow later used here | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see error: relative drop order changing in Rust 2024 --> $DIR/lint-tail-expr-drop-order-borrowck.rs:43:9 @@ -46,7 +46,7 @@ LL | g({ &f() }); | borrow later used by call | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see error: aborting due to 4 previous errors diff --git a/tests/ui/drop/lint-tail-expr-drop-order.stderr b/tests/ui/drop/lint-tail-expr-drop-order.stderr index e124e9874d0b4..c69c58aa1ab77 100644 --- a/tests/ui/drop/lint-tail-expr-drop-order.stderr +++ b/tests/ui/drop/lint-tail-expr-drop-order.stderr @@ -17,7 +17,7 @@ LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -54,7 +54,7 @@ LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -86,7 +86,7 @@ LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -118,7 +118,7 @@ LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -145,7 +145,7 @@ LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages error: relative drop order changing in Rust 2024 @@ -167,7 +167,7 @@ LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -199,7 +199,7 @@ LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:193:5 | @@ -231,7 +231,7 @@ LL | )); | - now the temporary value is dropped here, before the local variables in the block or statement | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | diff --git a/tests/ui/drop/tail_expr_drop_order-on-coroutine-unwind.stderr b/tests/ui/drop/tail_expr_drop_order-on-coroutine-unwind.stderr index 7bf452e2496cb..94977185ced82 100644 --- a/tests/ui/drop/tail_expr_drop_order-on-coroutine-unwind.stderr +++ b/tests/ui/drop/tail_expr_drop_order-on-coroutine-unwind.stderr @@ -23,7 +23,7 @@ LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:9:1 | diff --git a/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.old.stderr b/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.old.stderr index b811ef40c26b4..687799c668833 100644 --- a/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.old.stderr +++ b/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.old.stderr @@ -5,7 +5,7 @@ LL | fn id(f: Copy) -> usize { | ^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -19,7 +19,7 @@ LL | fn id(f: Copy) -> usize { | ^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr b/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr index 8b4f3f52ee934..4cfac9433753a 100644 --- a/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr +++ b/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr @@ -5,7 +5,7 @@ LL | trait B { fn f(a: A) -> A; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -19,7 +19,7 @@ LL | trait B { fn f(a: A) -> A; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | trait B { fn f(a: A) -> dyn A; } @@ -32,7 +32,7 @@ LL | trait A { fn g(b: B) -> B; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | trait A { fn g(b: dyn B) -> B; } @@ -45,7 +45,7 @@ LL | trait A { fn g(b: B) -> B; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | trait A { fn g(b: B) -> dyn B; } @@ -58,7 +58,7 @@ LL | trait B { fn f(a: A) -> A; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: if this is a dyn-compatible trait, use `dyn` | @@ -100,7 +100,7 @@ LL | trait A { fn g(b: B) -> B; } | ^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/dyn-compatibility/avoid-ice-on-warning.old.stderr b/tests/ui/dyn-compatibility/avoid-ice-on-warning.old.stderr index dbfe91e181149..4645b35f8f152 100644 --- a/tests/ui/dyn-compatibility/avoid-ice-on-warning.old.stderr +++ b/tests/ui/dyn-compatibility/avoid-ice-on-warning.old.stderr @@ -23,7 +23,7 @@ LL | fn call_this(f: F) : Fn(&str) + call_that {} | ^^^^^^^^^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.old.stderr b/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.old.stderr index 7be6cb0d03bbb..3cbdd19111d6c 100644 --- a/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.old.stderr +++ b/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.old.stderr @@ -5,7 +5,7 @@ LL | fn ord_prefer_dot(s: String) -> Ord { | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/bare-trait-dont-suggest-dyn.rs:5:9 | diff --git a/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr b/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr index b930815d13bb1..b034c5dac16ad 100644 --- a/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr +++ b/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr @@ -5,7 +5,7 @@ LL | fn function(x: &SomeTrait, y: Box) { | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/dyn-2018-edition-lint.rs:2:8 | @@ -23,7 +23,7 @@ LL | fn function(x: &SomeTrait, y: Box) { | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | fn function(x: &SomeTrait, y: Box) { @@ -36,7 +36,7 @@ LL | let _x: &SomeTrait = todo!(); | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | let _x: &dyn SomeTrait = todo!(); diff --git a/tests/ui/dyn-keyword/dyn-angle-brackets.stderr b/tests/ui/dyn-keyword/dyn-angle-brackets.stderr index 6a29dab04868d..30069633cf5f6 100644 --- a/tests/ui/dyn-keyword/dyn-angle-brackets.stderr +++ b/tests/ui/dyn-keyword/dyn-angle-brackets.stderr @@ -5,7 +5,7 @@ LL | ::fmt(self, f) | ^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/dyn-angle-brackets.rs:4:9 | diff --git a/tests/ui/editions/never-type-fallback-breaking.e2021.stderr b/tests/ui/editions/never-type-fallback-breaking.e2021.stderr index 6b84a64fffe2d..e30c0adb79df2 100644 --- a/tests/ui/editions/never-type-fallback-breaking.e2021.stderr +++ b/tests/ui/editions/never-type-fallback-breaking.e2021.stderr @@ -5,7 +5,7 @@ LL | fn m() { | ^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/never-type-fallback-breaking.rs:22:17 @@ -25,7 +25,7 @@ LL | fn q() -> Option<()> { | ^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/never-type-fallback-breaking.rs:37:5 @@ -44,7 +44,7 @@ LL | fn meow() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `(): From` will fail --> $DIR/never-type-fallback-breaking.rs:50:5 @@ -63,7 +63,7 @@ LL | pub fn fallback_return() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/never-type-fallback-breaking.rs:62:19 @@ -82,7 +82,7 @@ LL | fn fully_apit() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/never-type-fallback-breaking.rs:76:17 @@ -104,7 +104,7 @@ LL | fn m() { | ^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/never-type-fallback-breaking.rs:22:17 @@ -125,7 +125,7 @@ LL | fn q() -> Option<()> { | ^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/never-type-fallback-breaking.rs:37:5 @@ -146,7 +146,7 @@ LL | fn meow() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `(): From` will fail --> $DIR/never-type-fallback-breaking.rs:50:5 @@ -167,7 +167,7 @@ LL | pub fn fallback_return() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/never-type-fallback-breaking.rs:62:19 @@ -188,7 +188,7 @@ LL | fn fully_apit() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/never-type-fallback-breaking.rs:76:17 diff --git a/tests/ui/ergonomic-clones/closure/rfc2229-migration.stderr b/tests/ui/ergonomic-clones/closure/rfc2229-migration.stderr index b980be6cb86bf..f4f3e518014b3 100644 --- a/tests/ui/ergonomic-clones/closure/rfc2229-migration.stderr +++ b/tests/ui/ergonomic-clones/closure/rfc2229-migration.stderr @@ -10,7 +10,7 @@ LL | let x = a.0; LL | } | - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure | - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/rfc2229-migration.rs:5:9 | diff --git a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr index 7f3022c29233e..0004ea82facce 100644 --- a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr +++ b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr @@ -5,7 +5,7 @@ LL | let _ = MyIterator::next; | ^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr index 418f9acf5899a..46b677202efa0 100644 --- a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr +++ b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr @@ -5,7 +5,7 @@ LL | fn ice() -> impl AsRef { | ^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -19,7 +19,7 @@ LL | fn ice() -> impl AsRef { | ^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.stderr b/tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.stderr index 35fff9ef170e1..980ddedc255bf 100644 --- a/tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.stderr +++ b/tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.stderr @@ -5,7 +5,7 @@ LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024-machine-applicable.rs:9:10 | diff --git a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr index 3f8511a21a06a..dc9f1c218d9f3 100644 --- a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr +++ b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr @@ -5,7 +5,7 @@ LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:7:10 | @@ -29,7 +29,7 @@ LL | fn implicit(x: &i32) -> impl Sized { *x } | ^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:11:16 | @@ -48,7 +48,7 @@ LL | fn hello(&self, x: &i32) -> impl Sized + '_ { self } | ^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:17:24 | @@ -67,7 +67,7 @@ LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {} | ^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:29:23 | @@ -86,7 +86,7 @@ LL | fn apit(_: &impl Sized) -> impl Sized {} | ^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:33:12 | @@ -111,7 +111,7 @@ LL | fn apit2(_: &impl Sized, _: U) -> impl Sized {} | ^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:37:16 | @@ -136,7 +136,7 @@ LL | async fn async_fn<'a>(x: &'a ()) -> impl Sized {} | ^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:41:19 | @@ -155,7 +155,7 @@ LL | pub fn parens(x: &i32) -> &impl Clone { x } | ^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:45:18 | diff --git a/tests/ui/issues/issue-28344.stderr b/tests/ui/issues/issue-28344.stderr index 7bc965536e9a1..dfd4951f172c6 100644 --- a/tests/ui/issues/issue-28344.stderr +++ b/tests/ui/issues/issue-28344.stderr @@ -5,7 +5,7 @@ LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); | ^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -25,7 +25,7 @@ LL | let g = BitXor::bitor; | ^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | let g = ::bitor; diff --git a/tests/ui/issues/issue-39367.stderr b/tests/ui/issues/issue-39367.stderr index df21c09983e26..65076375e96ee 100644 --- a/tests/ui/issues/issue-39367.stderr +++ b/tests/ui/issues/issue-39367.stderr @@ -9,7 +9,7 @@ LL | | (Box::new(__static_ref_initialize())); LL | | }); | |______________^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives = note: `#[warn(static_mut_refs)]` on by default diff --git a/tests/ui/issues/issue-58734.stderr b/tests/ui/issues/issue-58734.stderr index e5dad000b510a..c246d1fc11119 100644 --- a/tests/ui/issues/issue-58734.stderr +++ b/tests/ui/issues/issue-58734.stderr @@ -5,7 +5,7 @@ LL | Trait::nonexistent(()); | ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/issues/issue-86756.stderr b/tests/ui/issues/issue-86756.stderr index 0f68b7648503c..b650b32c2a367 100644 --- a/tests/ui/issues/issue-86756.stderr +++ b/tests/ui/issues/issue-86756.stderr @@ -19,7 +19,7 @@ LL | eq:: | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/iterators/into-iter-on-arrays-2018.stderr b/tests/ui/iterators/into-iter-on-arrays-2018.stderr index d4055c74f7cef..8818ef80f76e5 100644 --- a/tests/ui/iterators/into-iter-on-arrays-2018.stderr +++ b/tests/ui/iterators/into-iter-on-arrays-2018.stderr @@ -5,7 +5,7 @@ LL | let _: Iter<'_, i32> = array.into_iter(); | ^^^^^^^^^ | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see = note: `#[warn(array_into_iter)]` on by default help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | @@ -25,7 +25,7 @@ LL | let _: Iter<'_, i32> = Box::new(array).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-2018.rs:22:43 @@ -34,7 +34,7 @@ LL | let _: Iter<'_, i32> = Rc::new(array).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-2018.rs:25:41 @@ -43,7 +43,7 @@ LL | let _: Iter<'_, i32> = Array(array).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-2018.rs:32:24 @@ -52,7 +52,7 @@ LL | for _ in [1, 2, 3].into_iter() {} | ^^^^^^^^^ | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | LL - for _ in [1, 2, 3].into_iter() {} diff --git a/tests/ui/iterators/into-iter-on-arrays-lint.stderr b/tests/ui/iterators/into-iter-on-arrays-lint.stderr index fb8fe79c7c966..a9dfa5819c145 100644 --- a/tests/ui/iterators/into-iter-on-arrays-lint.stderr +++ b/tests/ui/iterators/into-iter-on-arrays-lint.stderr @@ -5,7 +5,7 @@ LL | small.into_iter(); | ^^^^^^^^^ | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see = note: `#[warn(array_into_iter)]` on by default help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | @@ -25,7 +25,7 @@ LL | [1, 2].into_iter(); | ^^^^^^^^^ | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | LL - [1, 2].into_iter(); @@ -44,7 +44,7 @@ LL | big.into_iter(); | ^^^^^^^^^ | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | LL - big.into_iter(); @@ -63,7 +63,7 @@ LL | [0u8; 33].into_iter(); | ^^^^^^^^^ | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | LL - [0u8; 33].into_iter(); @@ -82,7 +82,7 @@ LL | Box::new(small).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-lint.rs:27:22 @@ -91,7 +91,7 @@ LL | Box::new([1, 2]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-lint.rs:30:19 @@ -100,7 +100,7 @@ LL | Box::new(big).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-lint.rs:33:25 @@ -109,7 +109,7 @@ LL | Box::new([0u8; 33]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-lint.rs:37:31 @@ -118,7 +118,7 @@ LL | Box::new(Box::new(small)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-lint.rs:40:32 @@ -127,7 +127,7 @@ LL | Box::new(Box::new([1, 2])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-lint.rs:43:29 @@ -136,7 +136,7 @@ LL | Box::new(Box::new(big)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 --> $DIR/into-iter-on-arrays-lint.rs:46:35 @@ -145,7 +145,7 @@ LL | Box::new(Box::new([0u8; 33])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see warning: 12 warnings emitted diff --git a/tests/ui/iterators/into-iter-on-boxed-slices-2021.stderr b/tests/ui/iterators/into-iter-on-boxed-slices-2021.stderr index 7a5a2be5ef068..a0c1432756d4d 100644 --- a/tests/ui/iterators/into-iter-on-boxed-slices-2021.stderr +++ b/tests/ui/iterators/into-iter-on-boxed-slices-2021.stderr @@ -5,7 +5,7 @@ LL | let _: Iter<'_, i32> = boxed_slice.into_iter(); | ^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see = note: `#[warn(boxed_slice_into_iter)]` on by default help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | @@ -25,7 +25,7 @@ LL | let _: Iter<'_, i32> = Box::new(boxed_slice.clone()).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&Box<[T]> as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to ` as IntoIterator>::into_iter` in Rust 2024 --> $DIR/into-iter-on-boxed-slices-2021.rs:22:57 @@ -34,7 +34,7 @@ LL | let _: Iter<'_, i32> = Rc::new(boxed_slice.clone()).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&Box<[T]> as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to ` as IntoIterator>::into_iter` in Rust 2024 --> $DIR/into-iter-on-boxed-slices-2021.rs:25:55 @@ -43,7 +43,7 @@ LL | let _: Iter<'_, i32> = Array(boxed_slice.clone()).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&Box<[T]> as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to ` as IntoIterator>::into_iter` in Rust 2024 --> $DIR/into-iter-on-boxed-slices-2021.rs:32:48 @@ -52,7 +52,7 @@ LL | for _ in (Box::new([1, 2, 3]) as Box<[_]>).into_iter() {} | ^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | LL - for _ in (Box::new([1, 2, 3]) as Box<[_]>).into_iter() {} diff --git a/tests/ui/iterators/into-iter-on-boxed-slices-lint.stderr b/tests/ui/iterators/into-iter-on-boxed-slices-lint.stderr index 6762ed28d368a..377455d6a2606 100644 --- a/tests/ui/iterators/into-iter-on-boxed-slices-lint.stderr +++ b/tests/ui/iterators/into-iter-on-boxed-slices-lint.stderr @@ -5,7 +5,7 @@ LL | boxed.into_iter(); | ^^^^^^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see = note: `#[warn(boxed_slice_into_iter)]` on by default help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | @@ -25,7 +25,7 @@ LL | Box::new(boxed.clone()).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see warning: this method call resolves to `<&Box<[T]> as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to ` as IntoIterator>::into_iter` in Rust 2024 --> $DIR/into-iter-on-boxed-slices-lint.rs:16:39 @@ -34,7 +34,7 @@ LL | Box::new(Box::new(boxed.clone())).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see warning: 3 warnings emitted diff --git a/tests/ui/lint/bare-trait-objects-path.stderr b/tests/ui/lint/bare-trait-objects-path.stderr index 25f3e857806f2..8da63a9c546f3 100644 --- a/tests/ui/lint/bare-trait-objects-path.stderr +++ b/tests/ui/lint/bare-trait-objects-path.stderr @@ -5,7 +5,7 @@ LL | Dyn::func(); | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -19,7 +19,7 @@ LL | ::Dyn::func(); | ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | ::func(); @@ -32,7 +32,7 @@ LL | Dyn::CONST; | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | ::CONST; @@ -45,7 +45,7 @@ LL | let _: Dyn::Ty; | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | let _: ::Ty; diff --git a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr index a1aa29dd6977e..2be7416711e04 100644 --- a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr @@ -5,7 +5,7 @@ LL | pub fn function(_x: Box) {} | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: requested on the command line with `--force-warn bare-trait-objects` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/lint/force-warn/cap-lints-allow.stderr b/tests/ui/lint/force-warn/cap-lints-allow.stderr index 0d10a43a14d77..92bcde11415f6 100644 --- a/tests/ui/lint/force-warn/cap-lints-allow.stderr +++ b/tests/ui/lint/force-warn/cap-lints-allow.stderr @@ -5,7 +5,7 @@ LL | pub fn function(_x: Box) {} | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: requested on the command line with `--force-warn bare-trait-objects` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr index d1b764b341435..74b34de90f17c 100644 --- a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr @@ -5,7 +5,7 @@ LL | 0...100 => true, | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `--force-warn ellipsis-inclusive-range-patterns` implied by `--force-warn rust-2021-compatibility` warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr index d52bd67e36af3..5bfbc9599bc3f 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr @@ -5,7 +5,7 @@ LL | pub fn function(_x: Box) {} | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr index 22483a3d874de..dabf12be5ff77 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr @@ -5,7 +5,7 @@ LL | pub fn function(_x: Box) {} | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr index aa183b9ba54cf..23a3a9107a13f 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr @@ -5,7 +5,7 @@ LL | pub fn function(_x: Box) {} | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/lint/inclusive-range-pattern-syntax.stderr b/tests/ui/lint/inclusive-range-pattern-syntax.stderr index ed9fa0d4101b2..a41082bb13b12 100644 --- a/tests/ui/lint/inclusive-range-pattern-syntax.stderr +++ b/tests/ui/lint/inclusive-range-pattern-syntax.stderr @@ -5,7 +5,7 @@ LL | 1...2 => {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/inclusive-range-pattern-syntax.rs:4:9 | @@ -19,7 +19,7 @@ LL | &1...2 => {} | ^^^^^^ help: use `..=` for an inclusive range: `&(1..=2)` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: 2 warnings emitted diff --git a/tests/ui/lint/lint-attr-everywhere-early.stderr b/tests/ui/lint/lint-attr-everywhere-early.stderr index fac0eb4faff82..2389b698c83c6 100644 --- a/tests/ui/lint/lint-attr-everywhere-early.stderr +++ b/tests/ui/lint/lint-attr-everywhere-early.stderr @@ -391,7 +391,7 @@ LL | Match{f1: 0...100} => {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/lint-attr-everywhere-early.rs:138:16 | @@ -489,7 +489,7 @@ LL | f1: 0...100, | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/lint-attr-everywhere-early.rs:174:20 | diff --git a/tests/ui/lint/static-mut-refs.e2021.stderr b/tests/ui/lint/static-mut-refs.e2021.stderr index 320e0cee8e8b7..75a7e60690cf2 100644 --- a/tests/ui/lint/static-mut-refs.e2021.stderr +++ b/tests/ui/lint/static-mut-refs.e2021.stderr @@ -4,7 +4,7 @@ warning: creating a shared reference to mutable static LL | let _y = &X; | ^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives = note: `#[warn(static_mut_refs)]` on by default help: use `&raw const` instead to create a raw pointer @@ -18,7 +18,7 @@ warning: creating a mutable reference to mutable static LL | let _y = &mut X; | ^^^^^^ mutable reference to mutable static | - = note: for more information, see + = note: for more information, see = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives help: use `&raw mut` instead to create a raw pointer | @@ -31,7 +31,7 @@ warning: creating a shared reference to mutable static LL | let ref _a = X; | ^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives warning: creating a shared reference to mutable static @@ -40,7 +40,7 @@ warning: creating a shared reference to mutable static LL | let (_b, _c) = (&X, &Y); | ^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -53,7 +53,7 @@ warning: creating a shared reference to mutable static LL | let (_b, _c) = (&X, &Y); | ^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -66,7 +66,7 @@ warning: creating a shared reference to mutable static LL | foo(&X); | ^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -79,7 +79,7 @@ warning: creating a shared reference to mutable static LL | let _ = Z.len(); | ^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives warning: creating a shared reference to mutable static @@ -88,7 +88,7 @@ warning: creating a shared reference to mutable static LL | let _ = format!("{:?}", Z); | ^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives warning: creating a shared reference to mutable static @@ -97,7 +97,7 @@ warning: creating a shared reference to mutable static LL | let _v = &A.value; | ^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -110,7 +110,7 @@ warning: creating a shared reference to mutable static LL | let _s = &A.s.value; | ^^^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -123,7 +123,7 @@ warning: creating a shared reference to mutable static LL | let ref _v = A.value; | ^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives warning: creating a mutable reference to mutable static @@ -135,7 +135,7 @@ LL | &mut ($x.0) LL | let _x = bar!(FOO); | --------- in this macro invocation | - = note: for more information, see + = note: for more information, see = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives = note: this warning originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/lint/static-mut-refs.e2024.stderr b/tests/ui/lint/static-mut-refs.e2024.stderr index bf7ffc62ce17b..42a96bafc8827 100644 --- a/tests/ui/lint/static-mut-refs.e2024.stderr +++ b/tests/ui/lint/static-mut-refs.e2024.stderr @@ -4,7 +4,7 @@ error: creating a shared reference to mutable static LL | let _y = &X; | ^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives = note: `#[deny(static_mut_refs)]` on by default help: use `&raw const` instead to create a raw pointer @@ -18,7 +18,7 @@ error: creating a mutable reference to mutable static LL | let _y = &mut X; | ^^^^^^ mutable reference to mutable static | - = note: for more information, see + = note: for more information, see = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives help: use `&raw mut` instead to create a raw pointer | @@ -31,7 +31,7 @@ error: creating a shared reference to mutable static LL | let ref _a = X; | ^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives error: creating a shared reference to mutable static @@ -40,7 +40,7 @@ error: creating a shared reference to mutable static LL | let (_b, _c) = (&X, &Y); | ^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -53,7 +53,7 @@ error: creating a shared reference to mutable static LL | let (_b, _c) = (&X, &Y); | ^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -66,7 +66,7 @@ error: creating a shared reference to mutable static LL | foo(&X); | ^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -79,7 +79,7 @@ error: creating a shared reference to mutable static LL | let _ = Z.len(); | ^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives error: creating a shared reference to mutable static @@ -88,7 +88,7 @@ error: creating a shared reference to mutable static LL | let _ = format!("{:?}", Z); | ^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives error: creating a shared reference to mutable static @@ -97,7 +97,7 @@ error: creating a shared reference to mutable static LL | let _v = &A.value; | ^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -110,7 +110,7 @@ error: creating a shared reference to mutable static LL | let _s = &A.s.value; | ^^^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -123,7 +123,7 @@ error: creating a shared reference to mutable static LL | let ref _v = A.value; | ^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives error: creating a mutable reference to mutable static @@ -135,7 +135,7 @@ LL | &mut ($x.0) LL | let _x = bar!(FOO); | --------- in this macro invocation | - = note: for more information, see + = note: for more information, see = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives = note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/macros/expr_2021_cargo_fix_edition.stderr b/tests/ui/macros/expr_2021_cargo_fix_edition.stderr index a2c281d9c0a11..795d99449c266 100644 --- a/tests/ui/macros/expr_2021_cargo_fix_edition.stderr +++ b/tests/ui/macros/expr_2021_cargo_fix_edition.stderr @@ -5,7 +5,7 @@ LL | ($e:expr) => { | ^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see Migration Guide + = note: for more information, see Migration Guide note: the lint level is defined here --> $DIR/expr_2021_cargo_fix_edition.rs:4:9 | @@ -23,7 +23,7 @@ LL | ($($i:expr)*) => { }; | ^^^^ | = warning: this changes meaning in Rust 2024 - = note: for more information, see Migration Guide + = note: for more information, see Migration Guide help: to keep the existing behavior, use the `expr_2021` fragment specifier | LL | ($($i:expr_2021)*) => { }; diff --git a/tests/ui/macros/macro-or-patterns-back-compat.stderr b/tests/ui/macros/macro-or-patterns-back-compat.stderr index e04dfefa4e8e7..67794f0a8b233 100644 --- a/tests/ui/macros/macro-or-patterns-back-compat.stderr +++ b/tests/ui/macros/macro-or-patterns-back-compat.stderr @@ -5,7 +5,7 @@ LL | macro_rules! foo { ($x:pat | $y:pat) => {} } | ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/macro-or-patterns-back-compat.rs:4:9 | @@ -19,7 +19,7 @@ LL | macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } | ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro --> $DIR/macro-or-patterns-back-compat.rs:19:21 @@ -28,7 +28,7 @@ LL | macro_rules! ogg { ($x:pat | $y:pat_param) => {} } | ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro --> $DIR/macro-or-patterns-back-compat.rs:23:26 @@ -37,7 +37,7 @@ LL | ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { | ^^^^^^^^ help: use pat_param to preserve semantics: `$pat:pat_param` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: aborting due to 4 previous errors diff --git a/tests/ui/macros/non-fmt-panic.stderr b/tests/ui/macros/non-fmt-panic.stderr index 30b63cb46e22b..83410d365864c 100644 --- a/tests/ui/macros/non-fmt-panic.stderr +++ b/tests/ui/macros/non-fmt-panic.stderr @@ -74,7 +74,7 @@ LL | assert!(false, S); | ^ | = note: this usage of `assert!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | assert!(false, "{}", S); @@ -87,7 +87,7 @@ LL | assert!(false, 123); | ^^^ | = note: this usage of `assert!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | assert!(false, "{}", 123); @@ -100,7 +100,7 @@ LL | assert!(false, Some(123)); | ^^^^^^^^^ | = note: this usage of `assert!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{:?}" format string to use the `Debug` implementation of `Option` | LL | assert!(false, "{:?}", Some(123)); @@ -125,7 +125,7 @@ LL | panic!(C); | ^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | panic!("{}", C); @@ -138,7 +138,7 @@ LL | panic!(S); | ^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | panic!("{}", S); @@ -151,7 +151,7 @@ LL | unreachable!(S); | ^ | = note: this usage of `unreachable!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | unreachable!("{}", S); @@ -164,7 +164,7 @@ LL | unreachable!(S); | ^ | = note: this usage of `unreachable!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | unreachable!("{}", S); @@ -177,7 +177,7 @@ LL | std::panic!(123); | ^^^ | = note: this usage of `std::panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | std::panic!("{}", 123); @@ -195,7 +195,7 @@ LL | core::panic!(&*"abc"); | ^^^^^^^ | = note: this usage of `core::panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | core::panic!("{}", &*"abc"); @@ -208,7 +208,7 @@ LL | panic!(Some(123)); | ^^^^^^^^^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{:?}" format string to use the `Debug` implementation of `Option` | LL | panic!("{:?}", Some(123)); @@ -262,7 +262,7 @@ LL | panic!(a!()); | ^^^^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | panic!("{}", a!()); @@ -280,7 +280,7 @@ LL | unreachable!(a!()); | ^^^^ | = note: this usage of `unreachable!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | unreachable!("{}", a!()); @@ -293,7 +293,7 @@ LL | panic!(format!("{}", 1)); | ^^^^^^^^^^^^^^^^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see = note: the `panic!()` macro supports formatting, so there's no need for the `format!()` macro here help: remove the `format!(..)` macro call | @@ -308,7 +308,7 @@ LL | unreachable!(format!("{}", 1)); | ^^^^^^^^^^^^^^^^ | = note: this usage of `unreachable!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see = note: the `unreachable!()` macro supports formatting, so there's no need for the `format!()` macro here help: remove the `format!(..)` macro call | @@ -323,7 +323,7 @@ LL | assert!(false, format!("{}", 1)); | ^^^^^^^^^^^^^^^^ | = note: this usage of `assert!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see = note: the `assert!()` macro supports formatting, so there's no need for the `format!()` macro here help: remove the `format!(..)` macro call | @@ -338,7 +338,7 @@ LL | debug_assert!(false, format!("{}", 1)); | ^^^^^^^^^^^^^^^^ | = note: this usage of `debug_assert!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see = note: the `debug_assert!()` macro supports formatting, so there's no need for the `format!()` macro here help: remove the `format!(..)` macro call | @@ -353,7 +353,7 @@ LL | panic![123]; | ^^^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | panic!["{}", 123]; @@ -371,7 +371,7 @@ LL | panic!{123}; | ^^^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | panic!{"{}", 123}; @@ -391,7 +391,7 @@ LL | panic!(v); | help: use std::panic::panic_any instead: `std::panic::panic_any` | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see warning: panic message is not a string literal --> $DIR/non-fmt-panic.rs:79:20 @@ -400,7 +400,7 @@ LL | assert!(false, v); | ^ | = note: this usage of `assert!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see warning: panic message is not a string literal --> $DIR/non-fmt-panic.rs:83:12 @@ -409,7 +409,7 @@ LL | panic!(v); | ^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{:?}" format string to use the `Debug` implementation of `T` | LL | panic!("{:?}", v); @@ -427,7 +427,7 @@ LL | assert!(false, v); | ^ | = note: this usage of `assert!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{:?}" format string to use the `Debug` implementation of `T` | LL | assert!(false, "{:?}", v); @@ -440,7 +440,7 @@ LL | panic!(v); | ^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | panic!("{}", v); @@ -458,7 +458,7 @@ LL | assert!(false, v); | ^ | = note: this usage of `assert!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | assert!(false, "{}", v); @@ -471,7 +471,7 @@ LL | panic!(v); | ^ | = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | panic!("{}", v); @@ -489,7 +489,7 @@ LL | assert!(false, v); | ^ | = note: this usage of `assert!()` is deprecated; it will be a hard error in Rust 2021 - = note: for more information, see + = note: for more information, see help: add a "{}" format string to `Display` the message | LL | assert!(false, "{}", v); diff --git a/tests/ui/never_type/defaulted-never-note.nofallback.stderr b/tests/ui/never_type/defaulted-never-note.nofallback.stderr index 6de323ad12c26..b7df6fb7a67ab 100644 --- a/tests/ui/never_type/defaulted-never-note.nofallback.stderr +++ b/tests/ui/never_type/defaulted-never-note.nofallback.stderr @@ -5,7 +5,7 @@ LL | fn smeg() { | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: ImplementedForUnitButNotNever` will fail --> $DIR/defaulted-never-note.rs:32:9 @@ -28,7 +28,7 @@ LL | fn smeg() { | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: ImplementedForUnitButNotNever` will fail --> $DIR/defaulted-never-note.rs:32:9 diff --git a/tests/ui/never_type/dependency-on-fallback-to-unit.stderr b/tests/ui/never_type/dependency-on-fallback-to-unit.stderr index be8075662e0cf..6ee57d531fb29 100644 --- a/tests/ui/never_type/dependency-on-fallback-to-unit.stderr +++ b/tests/ui/never_type/dependency-on-fallback-to-unit.stderr @@ -5,7 +5,7 @@ LL | fn def() { | ^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/dependency-on-fallback-to-unit.rs:12:19 @@ -26,7 +26,7 @@ LL | fn question_mark() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/dependency-on-fallback-to-unit.rs:22:5 @@ -48,7 +48,7 @@ LL | fn def() { | ^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/dependency-on-fallback-to-unit.rs:12:19 @@ -70,7 +70,7 @@ LL | fn question_mark() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/dependency-on-fallback-to-unit.rs:22:5 diff --git a/tests/ui/never_type/diverging-fallback-control-flow.nofallback.stderr b/tests/ui/never_type/diverging-fallback-control-flow.nofallback.stderr index 44ebdb4351043..64a8ecdf5464b 100644 --- a/tests/ui/never_type/diverging-fallback-control-flow.nofallback.stderr +++ b/tests/ui/never_type/diverging-fallback-control-flow.nofallback.stderr @@ -5,7 +5,7 @@ LL | fn assignment() { | ^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: UnitDefault` will fail --> $DIR/diverging-fallback-control-flow.rs:36:13 @@ -25,7 +25,7 @@ LL | fn assignment_rev() { | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: UnitDefault` will fail --> $DIR/diverging-fallback-control-flow.rs:50:13 @@ -47,7 +47,7 @@ LL | fn assignment() { | ^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: UnitDefault` will fail --> $DIR/diverging-fallback-control-flow.rs:36:13 @@ -68,7 +68,7 @@ LL | fn assignment_rev() { | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: UnitDefault` will fail --> $DIR/diverging-fallback-control-flow.rs:50:13 diff --git a/tests/ui/never_type/diverging-fallback-no-leak.nofallback.stderr b/tests/ui/never_type/diverging-fallback-no-leak.nofallback.stderr index 4a8dea42a4d60..ec48c38b6d761 100644 --- a/tests/ui/never_type/diverging-fallback-no-leak.nofallback.stderr +++ b/tests/ui/never_type/diverging-fallback-no-leak.nofallback.stderr @@ -5,7 +5,7 @@ LL | fn main() { | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Test` will fail --> $DIR/diverging-fallback-no-leak.rs:20:23 @@ -28,7 +28,7 @@ LL | fn main() { | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Test` will fail --> $DIR/diverging-fallback-no-leak.rs:20:23 diff --git a/tests/ui/never_type/diverging-fallback-unconstrained-return.nofallback.stderr b/tests/ui/never_type/diverging-fallback-unconstrained-return.nofallback.stderr index 803af39fd86f2..48debdd61c840 100644 --- a/tests/ui/never_type/diverging-fallback-unconstrained-return.nofallback.stderr +++ b/tests/ui/never_type/diverging-fallback-unconstrained-return.nofallback.stderr @@ -5,7 +5,7 @@ LL | fn main() { | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: UnitReturn` will fail --> $DIR/diverging-fallback-unconstrained-return.rs:39:23 @@ -28,7 +28,7 @@ LL | fn main() { | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: UnitReturn` will fail --> $DIR/diverging-fallback-unconstrained-return.rs:39:23 diff --git a/tests/ui/never_type/dont-suggest-turbofish-from-expansion.stderr b/tests/ui/never_type/dont-suggest-turbofish-from-expansion.stderr index 365e8869897ce..d2d108edb4dbd 100644 --- a/tests/ui/never_type/dont-suggest-turbofish-from-expansion.stderr +++ b/tests/ui/never_type/dont-suggest-turbofish-from-expansion.stderr @@ -5,7 +5,7 @@ LL | fn main() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/dont-suggest-turbofish-from-expansion.rs:14:23 @@ -32,7 +32,7 @@ LL | fn main() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/dont-suggest-turbofish-from-expansion.rs:14:23 diff --git a/tests/ui/never_type/fallback-closure-ret.nofallback.stderr b/tests/ui/never_type/fallback-closure-ret.nofallback.stderr index cf19363a7d8b1..5651a2658885e 100644 --- a/tests/ui/never_type/fallback-closure-ret.nofallback.stderr +++ b/tests/ui/never_type/fallback-closure-ret.nofallback.stderr @@ -5,7 +5,7 @@ LL | fn main() { | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Bar` will fail --> $DIR/fallback-closure-ret.rs:24:5 @@ -28,7 +28,7 @@ LL | fn main() { | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Bar` will fail --> $DIR/fallback-closure-ret.rs:24:5 diff --git a/tests/ui/never_type/impl_trait_fallback.stderr b/tests/ui/never_type/impl_trait_fallback.stderr index 7250db127cd6f..36d2eae1df24a 100644 --- a/tests/ui/never_type/impl_trait_fallback.stderr +++ b/tests/ui/never_type/impl_trait_fallback.stderr @@ -5,7 +5,7 @@ LL | fn should_ret_unit() -> impl T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: T` will fail --> $DIR/impl_trait_fallback.rs:8:25 @@ -24,7 +24,7 @@ LL | fn should_ret_unit() -> impl T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: T` will fail --> $DIR/impl_trait_fallback.rs:8:25 diff --git a/tests/ui/never_type/lint-breaking-2024-assign-underscore.stderr b/tests/ui/never_type/lint-breaking-2024-assign-underscore.stderr index 945db40782ecc..6a85b9923d3e9 100644 --- a/tests/ui/never_type/lint-breaking-2024-assign-underscore.stderr +++ b/tests/ui/never_type/lint-breaking-2024-assign-underscore.stderr @@ -5,7 +5,7 @@ LL | fn test() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/lint-breaking-2024-assign-underscore.rs:13:9 @@ -32,7 +32,7 @@ LL | fn test() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the types explicitly note: in edition 2024, the requirement `!: Default` will fail --> $DIR/lint-breaking-2024-assign-underscore.rs:13:9 diff --git a/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2015.stderr b/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2015.stderr index c90efd2778459..48734f3b3f8b3 100644 --- a/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2015.stderr +++ b/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2015.stderr @@ -5,7 +5,7 @@ LL | unsafe { mem::zeroed() } | ^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -20,7 +20,7 @@ LL | core::mem::transmute(Zst) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -34,7 +34,7 @@ LL | unsafe { Union { a: () }.b } | ^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly warning: never type fallback affects this raw pointer dereference @@ -44,7 +44,7 @@ LL | unsafe { *ptr::from_ref(&()).cast() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -58,7 +58,7 @@ LL | unsafe { internally_create(x) } | ^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -72,7 +72,7 @@ LL | unsafe { zeroed() } | ^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -86,7 +86,7 @@ LL | let zeroed = mem::zeroed; | ^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -100,7 +100,7 @@ LL | let f = internally_create; | ^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -114,7 +114,7 @@ LL | S(marker::PhantomData).create_out_of_thin_air() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly warning: never type fallback affects this call to an `unsafe` function @@ -127,7 +127,7 @@ LL | msg_send!(); | ----------- in this macro invocation | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: this warning originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -141,7 +141,7 @@ LL | unsafe { mem::zeroed() } | ^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -157,7 +157,7 @@ LL | core::mem::transmute(Zst) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -173,7 +173,7 @@ LL | unsafe { Union { a: () }.b } | ^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default @@ -185,7 +185,7 @@ LL | unsafe { *ptr::from_ref(&()).cast() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -201,7 +201,7 @@ LL | unsafe { internally_create(x) } | ^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -217,7 +217,7 @@ LL | unsafe { zeroed() } | ^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -233,7 +233,7 @@ LL | let zeroed = mem::zeroed; | ^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -249,7 +249,7 @@ LL | let f = internally_create; | ^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -265,7 +265,7 @@ LL | S(marker::PhantomData).create_out_of_thin_air() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default @@ -280,7 +280,7 @@ LL | msg_send!(); | ----------- in this macro invocation | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default = note: this warning originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.stderr b/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.stderr index 858d7381eeda6..8039ef427c19f 100644 --- a/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.stderr +++ b/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.stderr @@ -5,7 +5,7 @@ LL | unsafe { mem::zeroed() } | ^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -20,7 +20,7 @@ LL | core::mem::transmute(Zst) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -34,7 +34,7 @@ LL | unsafe { Union { a: () }.b } | ^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly error: never type fallback affects this raw pointer dereference @@ -44,7 +44,7 @@ LL | unsafe { *ptr::from_ref(&()).cast() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -58,7 +58,7 @@ LL | unsafe { internally_create(x) } | ^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -72,7 +72,7 @@ LL | unsafe { zeroed() } | ^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -86,7 +86,7 @@ LL | let zeroed = mem::zeroed; | ^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -100,7 +100,7 @@ LL | let f = internally_create; | ^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly help: use `()` annotations to avoid fallback changes | @@ -114,7 +114,7 @@ LL | S(marker::PhantomData).create_out_of_thin_air() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly error: never type fallback affects this call to an `unsafe` function @@ -127,7 +127,7 @@ LL | msg_send!(); | ----------- in this macro invocation | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -150,7 +150,7 @@ LL | unsafe { mem::zeroed() } | ^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -166,7 +166,7 @@ LL | core::mem::transmute(Zst) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -182,7 +182,7 @@ LL | unsafe { Union { a: () }.b } | ^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default @@ -194,7 +194,7 @@ LL | unsafe { *ptr::from_ref(&()).cast() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -210,7 +210,7 @@ LL | unsafe { internally_create(x) } | ^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -226,7 +226,7 @@ LL | unsafe { zeroed() } | ^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -242,7 +242,7 @@ LL | let zeroed = mem::zeroed; | ^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -258,7 +258,7 @@ LL | let f = internally_create; | ^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default help: use `()` annotations to avoid fallback changes @@ -274,7 +274,7 @@ LL | S(marker::PhantomData).create_out_of_thin_air() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default @@ -289,7 +289,7 @@ LL | msg_send!(); | ----------- in this macro invocation | = warning: this changes meaning in Rust 2024 and in a future release in all editions! - = note: for more information, see + = note: for more information, see = help: specify the type explicitly = note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default = note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr index 8268f5df23655..331c6510ce733 100644 --- a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr +++ b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr @@ -4,7 +4,7 @@ warning: creating a mutable reference to mutable static LL | S1 { a: unsafe { &mut X1 } } | ^^^^^^^ mutable reference to mutable static | - = note: for more information, see + = note: for more information, see = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives = note: `#[warn(static_mut_refs)]` on by default help: use `&raw mut` instead to create a raw pointer diff --git a/tests/ui/parser/recover/recover-pat-ranges.stderr b/tests/ui/parser/recover/recover-pat-ranges.stderr index 6c17182618b5e..246c704d53fab 100644 --- a/tests/ui/parser/recover/recover-pat-ranges.stderr +++ b/tests/ui/parser/recover/recover-pat-ranges.stderr @@ -191,7 +191,7 @@ LL | (1 + 4)...1 * 2 => (), | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(ellipsis_inclusive_range_patterns)]` on by default error: aborting due to 13 previous errors; 1 warning emitted diff --git a/tests/ui/parser/recover/recover-range-pats.stderr b/tests/ui/parser/recover/recover-range-pats.stderr index a2f3ba4dd94ff..1570475a0989b 100644 --- a/tests/ui/parser/recover/recover-range-pats.stderr +++ b/tests/ui/parser/recover/recover-range-pats.stderr @@ -339,7 +339,7 @@ LL | if let 0...3 = 0 {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/recover-range-pats.rs:6:9 | @@ -353,7 +353,7 @@ LL | if let 0...Y = 0 {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: `...` range patterns are deprecated --> $DIR/recover-range-pats.rs:46:13 @@ -362,7 +362,7 @@ LL | if let X...3 = 0 {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: `...` range patterns are deprecated --> $DIR/recover-range-pats.rs:49:13 @@ -371,7 +371,7 @@ LL | if let X...Y = 0 {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: `...` range patterns are deprecated --> $DIR/recover-range-pats.rs:52:16 @@ -380,7 +380,7 @@ LL | if let true...Y = 0 {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: `...` range patterns are deprecated --> $DIR/recover-range-pats.rs:55:13 @@ -389,7 +389,7 @@ LL | if let X...true = 0 {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: `...` range patterns are deprecated --> $DIR/recover-range-pats.rs:58:14 @@ -398,7 +398,7 @@ LL | if let .0...Y = 0 {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: `...` range patterns are deprecated --> $DIR/recover-range-pats.rs:62:13 @@ -407,7 +407,7 @@ LL | if let X... .0 = 0 {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see error: `...` range patterns are deprecated --> $DIR/recover-range-pats.rs:137:20 @@ -419,7 +419,7 @@ LL | mac2!(0, 1); | ----------- in this macro invocation | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0029]: only `char` and numeric types are allowed in range patterns diff --git a/tests/ui/parser/trait-object-trait-parens.stderr b/tests/ui/parser/trait-object-trait-parens.stderr index d75352b6811ea..671fd27052047 100644 --- a/tests/ui/parser/trait-object-trait-parens.stderr +++ b/tests/ui/parser/trait-object-trait-parens.stderr @@ -32,7 +32,7 @@ LL | let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -57,7 +57,7 @@ LL | let _: Box Trait<'a>) + (Obj)>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | let _: Box Trait<'a>) + (Obj)>; @@ -81,7 +81,7 @@ LL | let _: Box Trait<'a> + (Obj) + (?Sized)>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | let _: Box Trait<'a> + (Obj) + (?Sized)>; diff --git a/tests/ui/range/range-inclusive-pattern-precedence.stderr b/tests/ui/range/range-inclusive-pattern-precedence.stderr index 9df20fc45456e..15237b0a499c1 100644 --- a/tests/ui/range/range-inclusive-pattern-precedence.stderr +++ b/tests/ui/range/range-inclusive-pattern-precedence.stderr @@ -16,7 +16,7 @@ LL | &0...9 => {} | ^^^^^^ help: use `..=` for an inclusive range: `&(0..=9)` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/range-inclusive-pattern-precedence.rs:7:9 | diff --git a/tests/ui/range/range-inclusive-pattern-precedence2.stderr b/tests/ui/range/range-inclusive-pattern-precedence2.stderr index fd2fa78e92b55..4c5016b8ae45d 100644 --- a/tests/ui/range/range-inclusive-pattern-precedence2.stderr +++ b/tests/ui/range/range-inclusive-pattern-precedence2.stderr @@ -16,7 +16,7 @@ LL | box 0...9 => {} | ^^^ help: use `..=` for an inclusive range | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/range-inclusive-pattern-precedence2.rs:5:9 | diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr index ea4626092340b..e16841b369db9 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr @@ -79,7 +79,7 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req LL | sse2(); | ^^^^^^ call to function with `#[target_feature]` | - = note: for more information, see + = note: for more information, see = help: in order for the call to be safe, the context requires the following additional target feature: sse2 = note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]` note: an unsafe function restricts its caller, but its body is safe by default diff --git a/tests/ui/rust-2021/array-into-iter-ambiguous.stderr b/tests/ui/rust-2021/array-into-iter-ambiguous.stderr index 2a724bd307200..6e510df027ca9 100644 --- a/tests/ui/rust-2021/array-into-iter-ambiguous.stderr +++ b/tests/ui/rust-2021/array-into-iter-ambiguous.stderr @@ -5,7 +5,7 @@ LL | let y = points.into_iter(); | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `MyIntoIter::into_iter(points)` | = warning: this changes meaning in Rust 2021 - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/array-into-iter-ambiguous.rs:5:9 | diff --git a/tests/ui/rust-2021/future-prelude-collision-generic-trait.stderr b/tests/ui/rust-2021/future-prelude-collision-generic-trait.stderr index f38da132b5e87..bbc85d5bf45eb 100644 --- a/tests/ui/rust-2021/future-prelude-collision-generic-trait.stderr +++ b/tests/ui/rust-2021/future-prelude-collision-generic-trait.stderr @@ -5,7 +5,7 @@ LL | U::try_from(self) | ^^^^^^^^^^^ help: disambiguate the associated function: `>::try_from` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/future-prelude-collision-generic-trait.rs:5:9 | diff --git a/tests/ui/rust-2021/future-prelude-collision-generic.stderr b/tests/ui/rust-2021/future-prelude-collision-generic.stderr index 9893b3ebaa657..06ee6b40f115b 100644 --- a/tests/ui/rust-2021/future-prelude-collision-generic.stderr +++ b/tests/ui/rust-2021/future-prelude-collision-generic.stderr @@ -5,7 +5,7 @@ LL | Generic::from_iter(1); | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: ` as MyFromIter>::from_iter` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/future-prelude-collision-generic.rs:5:9 | @@ -19,7 +19,7 @@ LL | Generic::<'static, i32>::from_iter(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: ` as MyFromIter>::from_iter` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: trait-associated function `from_iter` will become ambiguous in Rust 2021 --> $DIR/future-prelude-collision-generic.rs:34:5 @@ -28,7 +28,7 @@ LL | Generic::<'_, _>::from_iter(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: ` as MyFromIter>::from_iter` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: 3 warnings emitted diff --git a/tests/ui/rust-2021/future-prelude-collision-imported.stderr b/tests/ui/rust-2021/future-prelude-collision-imported.stderr index c1d72d0df2187..8f650e9ee519c 100644 --- a/tests/ui/rust-2021/future-prelude-collision-imported.stderr +++ b/tests/ui/rust-2021/future-prelude-collision-imported.stderr @@ -5,7 +5,7 @@ LL | let _: u32 = 3u8.try_into().unwrap(); | ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(3u8)` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/future-prelude-collision-imported.rs:4:9 | @@ -19,7 +19,7 @@ LL | let _: u32 = 3u8.try_into().unwrap(); | ^^^^^^^^^^^^^^ help: disambiguate the associated function: `crate::m::TryIntoU32::try_into(3u8)` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: trait method `try_into` will become ambiguous in Rust 2021 --> $DIR/future-prelude-collision-imported.rs:53:22 @@ -28,7 +28,7 @@ LL | let _: u32 = 3u8.try_into().unwrap(); | ^^^^^^^^^^^^^^ help: disambiguate the associated function: `super::m::TryIntoU32::try_into(3u8)` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: trait method `try_into` will become ambiguous in Rust 2021 --> $DIR/future-prelude-collision-imported.rs:64:22 @@ -37,7 +37,7 @@ LL | let _: u32 = 3u8.try_into().unwrap(); | ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(3u8)` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: 4 warnings emitted diff --git a/tests/ui/rust-2021/future-prelude-collision-macros.stderr b/tests/ui/rust-2021/future-prelude-collision-macros.stderr index 4d4a076995805..c2d8c8540ad8f 100644 --- a/tests/ui/rust-2021/future-prelude-collision-macros.stderr +++ b/tests/ui/rust-2021/future-prelude-collision-macros.stderr @@ -5,7 +5,7 @@ LL | foo!().try_into(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `MyTry::try_into(foo!(), todo!())` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/future-prelude-collision-macros.rs:4:9 | @@ -19,7 +19,7 @@ LL | ::try_from(0); | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `::try_from` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: 2 warnings emitted diff --git a/tests/ui/rust-2021/future-prelude-collision-turbofish.stderr b/tests/ui/rust-2021/future-prelude-collision-turbofish.stderr index c0ef80fd84153..73ed238e5f7dc 100644 --- a/tests/ui/rust-2021/future-prelude-collision-turbofish.stderr +++ b/tests/ui/rust-2021/future-prelude-collision-turbofish.stderr @@ -5,7 +5,7 @@ LL | x.try_into::().or(Err("foo"))?.checked_sub(1); | ^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `AnnotatableTryInto::try_into::(x)` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/future-prelude-collision-turbofish.rs:6:9 | @@ -19,7 +19,7 @@ LL | x.try_into::().or(Err("foo"))?; | ^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `AnnotatableTryInto::try_into::(x)` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: 2 warnings emitted diff --git a/tests/ui/rust-2021/future-prelude-collision.stderr b/tests/ui/rust-2021/future-prelude-collision.stderr index cae113ff7113b..0b25145475635 100644 --- a/tests/ui/rust-2021/future-prelude-collision.stderr +++ b/tests/ui/rust-2021/future-prelude-collision.stderr @@ -5,7 +5,7 @@ LL | let _: u32 = 3u8.try_into().unwrap(); | ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(3u8)` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/future-prelude-collision.rs:4:9 | @@ -19,7 +19,7 @@ LL | let _ = u32::try_from(3u8).unwrap(); | ^^^^^^^^^^^^^ help: disambiguate the associated function: `::try_from` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: trait-associated function `from_iter` will become ambiguous in Rust 2021 --> $DIR/future-prelude-collision.rs:66:13 @@ -28,7 +28,7 @@ LL | let _ = >::from_iter(vec![1u8, 2, 3, 4, 5, 6].into_iter()); | ^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: ` as FromByteIterator>::from_iter` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: trait-associated function `try_from` will become ambiguous in Rust 2021 --> $DIR/future-prelude-collision.rs:74:18 @@ -37,7 +37,7 @@ LL | let _: u32 = <_>::try_from(3u8).unwrap(); | ^^^^^^^^^^^^^ help: disambiguate the associated function: `<_ as TryFromU8>::try_from` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: trait method `try_into` will become ambiguous in Rust 2021 --> $DIR/future-prelude-collision.rs:79:18 @@ -46,7 +46,7 @@ LL | let _: u32 = (&3u8).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(*(&3u8))` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: trait method `try_into` will become ambiguous in Rust 2021 --> $DIR/future-prelude-collision.rs:84:18 @@ -55,7 +55,7 @@ LL | let _: u32 = 3.0.try_into().unwrap(); | ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(&3.0)` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: trait method `try_into` will become ambiguous in Rust 2021 --> $DIR/future-prelude-collision.rs:90:18 @@ -64,7 +64,7 @@ LL | let _: u32 = mut_ptr.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(mut_ptr as *const _)` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: trait-associated function `try_from` will become ambiguous in Rust 2021 --> $DIR/future-prelude-collision.rs:95:13 @@ -73,7 +73,7 @@ LL | let _ = U32Alias::try_from(3u8).unwrap(); | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `::try_from` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see warning: 8 warnings emitted diff --git a/tests/ui/rust-2021/generic-type-collision.stderr b/tests/ui/rust-2021/generic-type-collision.stderr index 1ec61044f4a57..c2d296822c043 100644 --- a/tests/ui/rust-2021/generic-type-collision.stderr +++ b/tests/ui/rust-2021/generic-type-collision.stderr @@ -5,7 +5,7 @@ LL | >::from_iter(None); | ^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: ` as MyTrait<_>>::from_iter` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/generic-type-collision.rs:4:9 | diff --git a/tests/ui/rust-2021/inherent-dyn-collision.stderr b/tests/ui/rust-2021/inherent-dyn-collision.stderr index d9e720dd9af8f..d582e4aedcb90 100644 --- a/tests/ui/rust-2021/inherent-dyn-collision.stderr +++ b/tests/ui/rust-2021/inherent-dyn-collision.stderr @@ -5,7 +5,7 @@ LL | get_dyn_trait().try_into().unwrap() | ^^^^^^^^^^^^^^^ help: disambiguate the method call: `(&*get_dyn_trait())` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/inherent-dyn-collision.rs:8:9 | diff --git a/tests/ui/rust-2021/reserved-prefixes-migration.stderr b/tests/ui/rust-2021/reserved-prefixes-migration.stderr index 20914d1b9d14a..8092c63687784 100644 --- a/tests/ui/rust-2021/reserved-prefixes-migration.stderr +++ b/tests/ui/rust-2021/reserved-prefixes-migration.stderr @@ -5,7 +5,7 @@ LL | m2!(z"hey"); | ^ unknown prefix | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/reserved-prefixes-migration.rs:5:9 | @@ -23,7 +23,7 @@ LL | m2!(prefix"hey"); | ^^^^^^ unknown prefix | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 | LL | m2!(prefix "hey"); @@ -36,7 +36,7 @@ LL | m3!(hey#123); | ^^^ unknown prefix | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 | LL | m3!(hey #123); @@ -49,7 +49,7 @@ LL | m3!(hey#hey); | ^^^ unknown prefix | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 | LL | m3!(hey #hey); @@ -62,7 +62,7 @@ LL | #name = #kind#value | ^^^^ unknown prefix | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 | LL | #name = #kind #value diff --git a/tests/ui/rust-2024/box-slice-into-iter-ambiguous.stderr b/tests/ui/rust-2024/box-slice-into-iter-ambiguous.stderr index 0735be2665291..6da2cb97082cb 100644 --- a/tests/ui/rust-2024/box-slice-into-iter-ambiguous.stderr +++ b/tests/ui/rust-2024/box-slice-into-iter-ambiguous.stderr @@ -5,7 +5,7 @@ LL | let y = points.into_iter(); | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `MyIntoIter::into_iter(points)` | = warning: this changes meaning in Rust 2024 - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/box-slice-into-iter-ambiguous.rs:5:9 | diff --git a/tests/ui/rust-2024/gen-kw.e2015.stderr b/tests/ui/rust-2024/gen-kw.e2015.stderr index 3fca7b41ad274..ebb80cf221760 100644 --- a/tests/ui/rust-2024/gen-kw.e2015.stderr +++ b/tests/ui/rust-2024/gen-kw.e2015.stderr @@ -5,7 +5,7 @@ LL | fn gen() {} | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/gen-kw.rs:4:9 | @@ -20,7 +20,7 @@ LL | let gen = r#gen; | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:19:27 @@ -29,7 +29,7 @@ LL | () => { mod test { fn gen() {} } } | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:25:9 @@ -38,7 +38,7 @@ LL | fn test<'gen>(_: &'gen i32) {} | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:25:19 @@ -47,7 +47,7 @@ LL | fn test<'gen>(_: &'gen i32) {} | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:33:13 @@ -56,7 +56,7 @@ LL | struct Test<'gen>(Box>, &'gen ()); | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:33:28 @@ -65,7 +65,7 @@ LL | struct Test<'gen>(Box>, &'gen ()); | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:33:37 @@ -74,7 +74,7 @@ LL | struct Test<'gen>(Box>, &'gen ()); | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: aborting due to 8 previous errors diff --git a/tests/ui/rust-2024/gen-kw.e2018.stderr b/tests/ui/rust-2024/gen-kw.e2018.stderr index b7f2c887536c3..e491454d2a6fe 100644 --- a/tests/ui/rust-2024/gen-kw.e2018.stderr +++ b/tests/ui/rust-2024/gen-kw.e2018.stderr @@ -5,7 +5,7 @@ LL | fn gen() {} | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/gen-kw.rs:4:9 | @@ -20,7 +20,7 @@ LL | let gen = r#gen; | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:19:27 @@ -29,7 +29,7 @@ LL | () => { mod test { fn gen() {} } } | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:25:9 @@ -38,7 +38,7 @@ LL | fn test<'gen>(_: &'gen i32) {} | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:25:19 @@ -47,7 +47,7 @@ LL | fn test<'gen>(_: &'gen i32) {} | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:33:13 @@ -56,7 +56,7 @@ LL | struct Test<'gen>(Box>, &'gen ()); | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:33:28 @@ -65,7 +65,7 @@ LL | struct Test<'gen>(Box>, &'gen ()); | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: `gen` is a keyword in the 2024 edition --> $DIR/gen-kw.rs:33:37 @@ -74,7 +74,7 @@ LL | struct Test<'gen>(Box>, &'gen ()); | ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen` | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see error: aborting due to 8 previous errors diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.stderr b/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.stderr index 15a3fa114147e..8e5c3f4eb1dec 100644 --- a/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.stderr +++ b/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.stderr @@ -5,7 +5,7 @@ LL | core::pin::pin!(async {}).poll(&mut context()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::poll(&core::pin::pin!(async {}), &mut context())` | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/future-poll-async-block.rs:7:9 | diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.stderr b/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.stderr index 633731c2a5a52..70769524d2dfc 100644 --- a/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.stderr +++ b/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.stderr @@ -5,7 +5,7 @@ LL | core::pin::pin!(()).poll(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::poll(&core::pin::pin!(()))` | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/future-poll-not-future-pinned.rs:7:9 | diff --git a/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.stderr b/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.stderr index 5865029d65de2..2e88751cd8a87 100644 --- a/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.stderr +++ b/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.stderr @@ -5,7 +5,7 @@ LL | core::pin::pin!(async {}).poll(&mut context()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::poll(&core::pin::pin!(async {}), &mut context())` | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/in_2024_compatibility.rs:3:9 | diff --git a/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.stderr b/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.stderr index e67f07b4e4651..690c58f85b909 100644 --- a/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.stderr +++ b/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.stderr @@ -5,7 +5,7 @@ LL | Cat.into_future(); | ^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::into_future(&Cat)` | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/into-future-adt.rs:7:9 | diff --git a/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.stderr b/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.stderr index 0588f5bf3f558..4423e1272e818 100644 --- a/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.stderr +++ b/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.stderr @@ -5,7 +5,7 @@ LL | Cat.into_future(); | ^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::into_future(&Cat)` | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/into-future-not-into-future.rs:7:9 | diff --git a/tests/ui/rust-2024/reserved-guarded-strings-lexing.stderr b/tests/ui/rust-2024/reserved-guarded-strings-lexing.stderr index bf74f6eff9981..488f66bb01d37 100644 --- a/tests/ui/rust-2024/reserved-guarded-strings-lexing.stderr +++ b/tests/ui/rust-2024/reserved-guarded-strings-lexing.stderr @@ -35,7 +35,7 @@ LL | demo3!(## "foo"); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/reserved-guarded-strings-lexing.rs:4:9 | @@ -53,7 +53,7 @@ LL | demo4!(### "foo"); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!(# ## "foo"); @@ -66,7 +66,7 @@ LL | demo4!(### "foo"); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!(## # "foo"); @@ -79,7 +79,7 @@ LL | demo4!(## "foo"#); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!(# # "foo"#); @@ -92,7 +92,7 @@ LL | demo7!(### "foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo7!(# ## "foo"###); @@ -105,7 +105,7 @@ LL | demo7!(### "foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo7!(## # "foo"###); @@ -118,7 +118,7 @@ LL | demo7!(### "foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo7!(### "foo"# ##); @@ -131,7 +131,7 @@ LL | demo7!(### "foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo7!(### "foo"## #); @@ -144,7 +144,7 @@ LL | demo5!(###"foo"#); | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo5!(# ##"foo"#); @@ -157,7 +157,7 @@ LL | demo5!(###"foo"#); | ^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo5!(## #"foo"#); @@ -170,7 +170,7 @@ LL | demo5!(###"foo"#); | ^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo5!(### "foo"#); @@ -183,7 +183,7 @@ LL | demo5!(#"foo"###); | ^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo5!(# "foo"###); @@ -196,7 +196,7 @@ LL | demo5!(#"foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo5!(#"foo"# ##); @@ -209,7 +209,7 @@ LL | demo5!(#"foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo5!(#"foo"## #); @@ -222,7 +222,7 @@ LL | demo4!("foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!("foo"# ##); @@ -235,7 +235,7 @@ LL | demo4!("foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!("foo"## #); @@ -248,7 +248,7 @@ LL | demo4!(Ñ#""#); | ^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo4!(Ñ# ""#); @@ -261,7 +261,7 @@ LL | demo3!(🙃#""); | ^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo3!(🙃# ""); diff --git a/tests/ui/rust-2024/reserved-guarded-strings-migration.stderr b/tests/ui/rust-2024/reserved-guarded-strings-migration.stderr index 59f920caa957b..9e6c4554281b7 100644 --- a/tests/ui/rust-2024/reserved-guarded-strings-migration.stderr +++ b/tests/ui/rust-2024/reserved-guarded-strings-migration.stderr @@ -5,7 +5,7 @@ LL | demo3!(## "foo"); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/reserved-guarded-strings-migration.rs:5:9 | @@ -23,7 +23,7 @@ LL | demo4!(### "foo"); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!(# ## "foo"); @@ -36,7 +36,7 @@ LL | demo4!(### "foo"); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!(## # "foo"); @@ -49,7 +49,7 @@ LL | demo4!(## "foo"#); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!(# # "foo"#); @@ -62,7 +62,7 @@ LL | demo6!(### "foo"##); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo6!(# ## "foo"##); @@ -75,7 +75,7 @@ LL | demo6!(### "foo"##); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo6!(## # "foo"##); @@ -88,7 +88,7 @@ LL | demo6!(### "foo"##); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo6!(### "foo"# #); @@ -101,7 +101,7 @@ LL | demo4!("foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!("foo"# ##); @@ -114,7 +114,7 @@ LL | demo4!("foo"###); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo4!("foo"## #); @@ -127,7 +127,7 @@ LL | demo2!(#""); | ^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo2!(# ""); @@ -140,7 +140,7 @@ LL | demo3!(#""#); | ^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo3!(# ""#); @@ -153,7 +153,7 @@ LL | demo3!(##""); | ^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo3!(# #""); @@ -166,7 +166,7 @@ LL | demo3!(##""); | ^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo3!(## ""); @@ -179,7 +179,7 @@ LL | demo2!(#"foo"); | ^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo2!(# "foo"); @@ -192,7 +192,7 @@ LL | demo3!(##"foo"); | ^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo3!(# #"foo"); @@ -205,7 +205,7 @@ LL | demo3!(##"foo"); | ^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo3!(## "foo"); @@ -218,7 +218,7 @@ LL | demo3!(#"foo"#); | ^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo3!(# "foo"#); @@ -231,7 +231,7 @@ LL | demo4!(##"foo"#); | ^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo4!(# #"foo"#); @@ -244,7 +244,7 @@ LL | demo4!(##"foo"#); | ^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo4!(## "foo"#); @@ -257,7 +257,7 @@ LL | demo5!(##"foo"##); | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo5!(# #"foo"##); @@ -270,7 +270,7 @@ LL | demo5!(##"foo"##); | ^^^^^^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a guarded string in Rust 2024 | LL | demo5!(## "foo"##); @@ -283,7 +283,7 @@ LL | demo5!(##"foo"##); | ^^ | = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: insert whitespace here to avoid this being parsed as a forbidden token in Rust 2024 | LL | demo5!(##"foo"# #); diff --git a/tests/ui/rust-2024/unsafe-attributes/in_2024_compatibility.stderr b/tests/ui/rust-2024/unsafe-attributes/in_2024_compatibility.stderr index f0a49f5bd7949..2b77f6e8e52dc 100644 --- a/tests/ui/rust-2024/unsafe-attributes/in_2024_compatibility.stderr +++ b/tests/ui/rust-2024/unsafe-attributes/in_2024_compatibility.stderr @@ -5,7 +5,7 @@ LL | #[no_mangle] | ^^^^^^^^^ usage of unsafe attribute | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/in_2024_compatibility.rs:1:9 | diff --git a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.stderr b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.stderr index 15a48fb71594a..b97176f5e0d3c 100644 --- a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.stderr +++ b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.stderr @@ -5,7 +5,7 @@ LL | tt!([no_mangle]); | ^^^^^^^^^ usage of unsafe attribute | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/unsafe-attributes-fix.rs:2:9 | @@ -26,7 +26,7 @@ LL | ident!(no_mangle); | ----------------- in this macro invocation | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see = note: this error originates in the macro `ident` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap the attribute in `unsafe(...)` | @@ -40,7 +40,7 @@ LL | meta!(no_mangle); | ^^^^^^^^^ usage of unsafe attribute | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: wrap the attribute in `unsafe(...)` | LL | meta!(unsafe(no_mangle)); @@ -53,7 +53,7 @@ LL | meta2!(export_name = "baw"); | ^^^^^^^^^^^ usage of unsafe attribute | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: wrap the attribute in `unsafe(...)` | LL | meta2!(unsafe(export_name = "baw")); @@ -69,7 +69,7 @@ LL | ident2!(export_name, "bars"); | ---------------------------- in this macro invocation | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see = note: this error originates in the macro `ident2` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap the attribute in `unsafe(...)` | @@ -86,7 +86,7 @@ LL | with_cfg_attr!(); | ---------------- in this macro invocation | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see = note: this error originates in the macro `with_cfg_attr` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap the attribute in `unsafe(...)` | @@ -100,7 +100,7 @@ LL | #[no_mangle] | ^^^^^^^^^ usage of unsafe attribute | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: wrap the attribute in `unsafe(...)` | LL | #[unsafe(no_mangle)] diff --git a/tests/ui/rust-2024/unsafe-env-suggestion.stderr b/tests/ui/rust-2024/unsafe-env-suggestion.stderr index 6c95d50f39322..3c5ceaaaf425e 100644 --- a/tests/ui/rust-2024/unsafe-env-suggestion.stderr +++ b/tests/ui/rust-2024/unsafe-env-suggestion.stderr @@ -5,7 +5,7 @@ LL | env::set_var("FOO", "BAR"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/unsafe-env-suggestion.rs:3:9 | @@ -24,7 +24,7 @@ LL | env::remove_var("FOO"); | ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see help: you can wrap the call in an `unsafe` block if you can guarantee that the environment access only happens in single-threaded code | LL + // TODO: Audit that the environment access only happens in single-threaded code. diff --git a/tests/ui/rust-2024/unsafe-env.e2021.stderr b/tests/ui/rust-2024/unsafe-env.e2021.stderr index 4a441cf43ffab..a73db9fd60c73 100644 --- a/tests/ui/rust-2024/unsafe-env.e2021.stderr +++ b/tests/ui/rust-2024/unsafe-env.e2021.stderr @@ -4,7 +4,7 @@ error[E0133]: call to unsafe function `unsafe_fn` is unsafe and requires unsafe LL | unsafe_fn(); | ^^^^^^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/unsafe-env.rs:8:1 diff --git a/tests/ui/rust-2024/unsafe-env.e2024.stderr b/tests/ui/rust-2024/unsafe-env.e2024.stderr index 0ee7e042946b5..cb48ae231f274 100644 --- a/tests/ui/rust-2024/unsafe-env.e2024.stderr +++ b/tests/ui/rust-2024/unsafe-env.e2024.stderr @@ -4,7 +4,7 @@ error[E0133]: call to unsafe function `std::env::set_var` is unsafe and requires LL | env::set_var("FOO", "BAR"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/unsafe-env.rs:8:1 @@ -23,7 +23,7 @@ error[E0133]: call to unsafe function `std::env::remove_var` is unsafe and requi LL | env::remove_var("FOO"); | ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `unsafe_fn` is unsafe and requires unsafe block @@ -32,7 +32,7 @@ error[E0133]: call to unsafe function `unsafe_fn` is unsafe and requires unsafe LL | unsafe_fn(); | ^^^^^^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block diff --git a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.stderr b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.stderr index ab12da0c416ee..9a535fbbaf5e4 100644 --- a/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.stderr +++ b/tests/ui/rust-2024/unsafe-extern-blocks/unsafe-extern-suggestion.stderr @@ -14,7 +14,7 @@ LL | | } | |_^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/unsafe-extern-suggestion.rs:3:9 | diff --git a/tests/ui/statics/issue-15261.stderr b/tests/ui/statics/issue-15261.stderr index d2dd762aa66eb..60c5fb93dbaf2 100644 --- a/tests/ui/statics/issue-15261.stderr +++ b/tests/ui/statics/issue-15261.stderr @@ -4,7 +4,7 @@ warning: creating a shared reference to mutable static LL | static n: &'static usize = unsafe { &n_mut }; | ^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives = note: `#[warn(static_mut_refs)]` on by default help: use `&raw const` instead to create a raw pointer diff --git a/tests/ui/statics/static-mut-shared-parens.stderr b/tests/ui/statics/static-mut-shared-parens.stderr index 3825e8efc4277..16daee091a800 100644 --- a/tests/ui/statics/static-mut-shared-parens.stderr +++ b/tests/ui/statics/static-mut-shared-parens.stderr @@ -4,7 +4,7 @@ warning: creating a shared reference to mutable static LL | let _ = unsafe { (&TEST) as *const usize }; | ^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives = note: `#[warn(static_mut_refs)]` on by default help: use `&raw const` instead to create a raw pointer @@ -18,7 +18,7 @@ warning: creating a mutable reference to mutable static LL | let _ = unsafe { (&mut TEST) as *const usize }; | ^^^^^^^^^^^ mutable reference to mutable static | - = note: for more information, see + = note: for more information, see = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives help: use `&raw mut` instead to create a raw pointer | diff --git a/tests/ui/statics/static-mut-xc.stderr b/tests/ui/statics/static-mut-xc.stderr index 2d7a0553e925f..2e5aa1b264531 100644 --- a/tests/ui/statics/static-mut-xc.stderr +++ b/tests/ui/statics/static-mut-xc.stderr @@ -4,7 +4,7 @@ warning: creating a shared reference to mutable static LL | assert_eq!(static_mut_xc::a, 3); | ^^^^^^^^^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives = note: `#[warn(static_mut_refs)]` on by default @@ -14,7 +14,7 @@ warning: creating a shared reference to mutable static LL | assert_eq!(static_mut_xc::a, 4); | ^^^^^^^^^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives warning: creating a shared reference to mutable static @@ -23,7 +23,7 @@ warning: creating a shared reference to mutable static LL | assert_eq!(static_mut_xc::a, 5); | ^^^^^^^^^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives warning: creating a shared reference to mutable static @@ -32,7 +32,7 @@ warning: creating a shared reference to mutable static LL | assert_eq!(static_mut_xc::a, 15); | ^^^^^^^^^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives warning: creating a shared reference to mutable static @@ -41,7 +41,7 @@ warning: creating a shared reference to mutable static LL | assert_eq!(static_mut_xc::a, -3); | ^^^^^^^^^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives warning: creating a shared reference to mutable static @@ -50,7 +50,7 @@ warning: creating a shared reference to mutable static LL | static_bound(&static_mut_xc::a); | ^^^^^^^^^^^^^^^^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives help: use `&raw const` instead to create a raw pointer | @@ -63,7 +63,7 @@ warning: creating a mutable reference to mutable static LL | static_bound_set(&mut static_mut_xc::a); | ^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static | - = note: for more information, see + = note: for more information, see = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives help: use `&raw mut` instead to create a raw pointer | diff --git a/tests/ui/statics/static-recursive.stderr b/tests/ui/statics/static-recursive.stderr index 252807e2e5dea..0c3f961372b71 100644 --- a/tests/ui/statics/static-recursive.stderr +++ b/tests/ui/statics/static-recursive.stderr @@ -4,7 +4,7 @@ warning: creating a shared reference to mutable static LL | static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 }; | ^^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives = note: `#[warn(static_mut_refs)]` on by default help: use `&raw const` instead to create a raw pointer @@ -18,7 +18,7 @@ warning: creating a shared reference to mutable static LL | assert_eq!(S, *(S as *const *const u8)); | ^ shared reference to mutable static | - = note: for more information, see + = note: for more information, see = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives warning: 2 warnings emitted diff --git a/tests/ui/suggestions/issue-116434-2015.stderr b/tests/ui/suggestions/issue-116434-2015.stderr index cad5812da6632..e7173d91438a0 100644 --- a/tests/ui/suggestions/issue-116434-2015.stderr +++ b/tests/ui/suggestions/issue-116434-2015.stderr @@ -5,7 +5,7 @@ LL | fn foo() -> Clone; | ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -19,7 +19,7 @@ LL | fn foo() -> Clone; | ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: if this is a dyn-compatible trait, use `dyn` | @@ -52,7 +52,7 @@ LL | fn handle() -> DbHandle; | ^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | fn handle() -> dyn DbHandle; @@ -65,7 +65,7 @@ LL | fn handle() -> DbHandle; | ^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/suggestions/issue-61963.stderr b/tests/ui/suggestions/issue-61963.stderr index ef11efe5c74d7..ffdeef12bb7f1 100644 --- a/tests/ui/suggestions/issue-61963.stderr +++ b/tests/ui/suggestions/issue-61963.stderr @@ -5,7 +5,7 @@ LL | bar: Box, | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see note: the lint level is defined here --> $DIR/issue-61963.rs:4:9 | @@ -23,7 +23,7 @@ LL | pub struct Foo { | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | dyn pub struct Foo { diff --git a/tests/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr b/tests/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr index 929f893e34f5a..d90dd201bcfb5 100644 --- a/tests/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr +++ b/tests/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr @@ -68,7 +68,7 @@ LL | impl<'a, T> Struct for Trait<'a, T> {} | ^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -82,7 +82,7 @@ LL | impl<'a, T> Enum for Trait<'a, T> {} | ^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | impl<'a, T> Enum for dyn Trait<'a, T> {} @@ -95,7 +95,7 @@ LL | impl<'a, T> Union for Trait<'a, T> {} | ^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | impl<'a, T> Union for dyn Trait<'a, T> {} diff --git a/tests/ui/traits/bound/not-on-bare-trait.stderr b/tests/ui/traits/bound/not-on-bare-trait.stderr index 9028e66fa020c..69413ca96cdae 100644 --- a/tests/ui/traits/bound/not-on-bare-trait.stderr +++ b/tests/ui/traits/bound/not-on-bare-trait.stderr @@ -5,7 +5,7 @@ LL | fn foo(_x: Foo + Send) { | ^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/traits/missing-for-type-in-impl.e2015.stderr b/tests/ui/traits/missing-for-type-in-impl.e2015.stderr index c8a1329e3d0f6..a0bfc524252f5 100644 --- a/tests/ui/traits/missing-for-type-in-impl.e2015.stderr +++ b/tests/ui/traits/missing-for-type-in-impl.e2015.stderr @@ -5,7 +5,7 @@ LL | impl Foo { | ^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -23,7 +23,7 @@ LL | impl Foo { | ^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: if this is a dyn-compatible trait, use `dyn` | diff --git a/tests/ui/traits/unspecified-self-in-trait-ref.stderr b/tests/ui/traits/unspecified-self-in-trait-ref.stderr index 6f5ae786de6bc..2e872453184f1 100644 --- a/tests/ui/traits/unspecified-self-in-trait-ref.stderr +++ b/tests/ui/traits/unspecified-self-in-trait-ref.stderr @@ -5,7 +5,7 @@ LL | let a = Foo::lol(); | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -25,7 +25,7 @@ LL | let b = Foo::<_>::lol(); | ^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | let b = >::lol(); @@ -44,7 +44,7 @@ LL | let c = Bar::lol(); | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | let c = ::lol(); @@ -63,7 +63,7 @@ LL | let d = Bar::::lol(); | ^^^^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | let d = >::lol(); @@ -82,7 +82,7 @@ LL | let e = Bar::::lol(); | ^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | let e = >::lol(); diff --git a/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr b/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr index a02c6041e45fa..8a26b45117cdc 100644 --- a/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr +++ b/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr @@ -4,7 +4,7 @@ warning[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe blo LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/edition-2024-unsafe_op_in_unsafe_fn.rs:8:1 diff --git a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.stderr b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.stderr index 2ad1de5102d95..458a2180a82b9 100644 --- a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.stderr +++ b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.stderr @@ -4,7 +4,7 @@ warning[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe blo LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/edition_2024_default.rs:11:1 diff --git a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/in_2024_compatibility.stderr b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/in_2024_compatibility.stderr index 54447fbc52820..0c4070068d0b2 100644 --- a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/in_2024_compatibility.stderr +++ b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/in_2024_compatibility.stderr @@ -4,7 +4,7 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/in_2024_compatibility.rs:6:1 diff --git a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/rfc-2585-unsafe_op_in_unsafe_fn.stderr b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/rfc-2585-unsafe_op_in_unsafe_fn.stderr index 5465c225b7e9d..3e43840cf6cb3 100644 --- a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/rfc-2585-unsafe_op_in_unsafe_fn.stderr +++ b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/rfc-2585-unsafe_op_in_unsafe_fn.stderr @@ -4,7 +4,7 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:8:1 @@ -23,7 +23,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe block LL | *PTR; | ^^^^ dereference of raw pointer | - = note: for more information, see + = note: for more information, see = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error[E0133]: use of mutable static is unsafe and requires unsafe block @@ -32,7 +32,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe block LL | VOID = (); | ^^^^ use of mutable static | - = note: for more information, see + = note: for more information, see = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior error: unnecessary `unsafe` block @@ -53,7 +53,7 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:23:1 @@ -73,7 +73,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe block LL | *PTR; | ^^^^ dereference of raw pointer | - = note: for more information, see + = note: for more information, see = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error[E0133]: use of mutable static is unsafe and requires unsafe block @@ -82,7 +82,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe block LL | VOID = (); | ^^^^ use of mutable static | - = note: for more information, see + = note: for more information, see = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior error: unnecessary `unsafe` block diff --git a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/wrapping-unsafe-block-sugg.stderr b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/wrapping-unsafe-block-sugg.stderr index b48e607c53b65..f7dbf39e6f261 100644 --- a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/wrapping-unsafe-block-sugg.stderr +++ b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/wrapping-unsafe-block-sugg.stderr @@ -4,7 +4,7 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/wrapping-unsafe-block-sugg.rs:11:1 @@ -23,7 +23,7 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: dereference of raw pointer is unsafe and requires unsafe block @@ -32,7 +32,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe block LL | let y = *x; | ^^ dereference of raw pointer | - = note: for more information, see + = note: for more information, see = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/wrapping-unsafe-block-sugg.rs:23:1 @@ -46,7 +46,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe block LL | y + *x | ^^ dereference of raw pointer | - = note: for more information, see + = note: for more information, see = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error[E0133]: use of mutable static is unsafe and requires unsafe block @@ -55,7 +55,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe block LL | let y = BAZ; | ^^^ use of mutable static | - = note: for more information, see + = note: for more information, see = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/wrapping-unsafe-block-sugg.rs:36:1 @@ -69,7 +69,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe block LL | y + BAZ | ^^^ use of mutable static | - = note: for more information, see + = note: for more information, see = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block @@ -81,7 +81,7 @@ LL | macro_rules! unsafe_macro { () => (unsf()) } LL | unsafe_macro!(); | --------------- in this macro invocation | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/wrapping-unsafe-block-sugg.rs:58:1 @@ -99,7 +99,7 @@ LL | macro_rules! unsafe_macro { () => (unsf()) } LL | unsafe_macro!(); | --------------- in this macro invocation | - = note: for more information, see + = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior = note: this error originates in the macro `unsafe_macro` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr index a99728f4b669f..26872f60fd351 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr @@ -5,7 +5,7 @@ LL | trait Foo> { | ^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default help: if this is a dyn-compatible trait, use `dyn` | @@ -19,7 +19,7 @@ LL | trait Bar> {} | ^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see + = note: for more information, see help: if this is a dyn-compatible trait, use `dyn` | LL | trait Bar> {} From ac87434362f2db51dc6ca29805daef99c606cba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 21 Jul 2025 01:09:58 +0200 Subject: [PATCH 02/28] Implement support for explicit tail calls in the MIR block builders and the LLVM codegen bckend. --- compiler/rustc_codegen_gcc/src/builder.rs | 15 +++++ compiler/rustc_codegen_llvm/src/builder.rs | 26 +++++++- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 11 ++++ compiler/rustc_codegen_ssa/src/mir/block.rs | 60 +++++++++++++++---- .../rustc_codegen_ssa/src/traits/builder.rs | 12 ++++ .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 27 +++++++++ 6 files changed, 139 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/builder.rs b/compiler/rustc_codegen_gcc/src/builder.rs index a4ec4bf8deac4..48e11c755a4f0 100644 --- a/compiler/rustc_codegen_gcc/src/builder.rs +++ b/compiler/rustc_codegen_gcc/src/builder.rs @@ -1742,6 +1742,21 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { call } + fn tail_call( + &mut self, + _llty: Self::Type, + _fn_attrs: Option<&CodegenFnAttrs>, + _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, + _llfn: Self::Value, + _args: &[Self::Value], + _funclet: Option<&Self::Funclet>, + _instance: Option>, + ) { + bug!( + "Guaranteed tail calls with the 'become' keyword are not implemented in the GCC backend" + ); + } + fn zext(&mut self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<'gcc> { // FIXME(antoyo): this does not zero-extend. self.gcc_int_cast(value, dest_typ) diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 514923ad6f37f..c1beba767cf8c 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -14,6 +14,7 @@ use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::*; use rustc_data_structures::small_c_str::SmallCStr; use rustc_hir::def_id::DefId; +use rustc_middle::bug; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::ty::layout::{ FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTypingEnv, LayoutError, LayoutOfHelpers, @@ -23,7 +24,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; use rustc_sanitizers::{cfi, kcfi}; use rustc_session::config::OptLevel; use rustc_span::Span; -use rustc_target::callconv::FnAbi; +use rustc_target::callconv::{FnAbi, PassMode}; use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target}; use smallvec::SmallVec; use tracing::{debug, instrument}; @@ -1362,6 +1363,29 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { call } + fn tail_call( + &mut self, + llty: Self::Type, + fn_attrs: Option<&CodegenFnAttrs>, + fn_abi: &FnAbi<'tcx, Ty<'tcx>>, + llfn: Self::Value, + args: &[Self::Value], + funclet: Option<&Self::Funclet>, + instance: Option>, + ) { + let call = self.call(llty, fn_attrs, Some(fn_abi), llfn, args, funclet, instance); + + match &fn_abi.ret.mode { + PassMode::Ignore | PassMode::Indirect { .. } => self.ret_void(), + PassMode::Direct(_) | PassMode::Pair { .. } => self.ret(call), + mode @ PassMode::Cast { .. } => { + bug!("Encountered `PassMode::{mode:?}` during codegen") + } + } + + llvm::LLVMSetTailCallKind(call, llvm::TailCallKind::MustTail); + } + fn zext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { unsafe { llvm::LLVMBuildZExt(self.llbuilder, val, dest_ty, UNNAMED) } } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 80a0e5c5accc2..f6e4b649b515f 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -97,6 +97,16 @@ pub(crate) enum ModuleFlagMergeBehavior { // Consts for the LLVM CallConv type, pre-cast to usize. +#[derive(Copy, Clone, PartialEq, Debug)] +#[repr(C)] +#[allow(dead_code)] +pub(crate) enum TailCallKind { + None = 0, + Tail = 1, + MustTail = 2, + NoTail = 3, +} + /// LLVM CallingConv::ID. Should we wrap this? /// /// See @@ -1181,6 +1191,7 @@ unsafe extern "C" { pub(crate) safe fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool; pub(crate) safe fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool); pub(crate) safe fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool); + pub(crate) safe fn LLVMSetTailCallKind(CallInst: &Value, Kind: TailCallKind); // Operations on attributes pub(crate) fn LLVMCreateStringAttribute( diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index bde63fd501aa2..e97a4e98a257a 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -160,6 +160,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { mut unwind: mir::UnwindAction, lifetime_ends_after_call: &[(Bx::Value, Size)], instance: Option>, + tail: bool, mergeable_succ: bool, ) -> MergingSucc { let tcx = bx.tcx(); @@ -221,6 +222,15 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { } }; + if tail { + bx.tail_call(fn_ty, fn_attrs, fn_abi, fn_ptr, llargs, self.funclet(fx), instance); + for &(tmp, size) in lifetime_ends_after_call { + bx.lifetime_end(tmp, size); + } + + return MergingSucc::False; + } + if let Some(unwind_block) = unwind_block { let ret_llbb = if let Some((_, target)) = destination { fx.llbb(target) @@ -659,6 +669,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { unwind, &[], Some(drop_instance), + false, !maybe_null && mergeable_succ, ) } @@ -747,8 +758,19 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let (fn_abi, llfn, instance) = common::build_langcall(bx, span, lang_item); // Codegen the actual panic invoke/call. - let merging_succ = - helper.do_call(self, bx, fn_abi, llfn, &args, None, unwind, &[], Some(instance), false); + let merging_succ = helper.do_call( + self, + bx, + fn_abi, + llfn, + &args, + None, + unwind, + &[], + Some(instance), + false, + false, + ); assert_eq!(merging_succ, MergingSucc::False); MergingSucc::False } @@ -778,6 +800,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { &[], Some(instance), false, + false, ); assert_eq!(merging_succ, MergingSucc::False); } @@ -845,6 +868,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { unwind, &[], Some(instance), + false, mergeable_succ, )) } @@ -860,6 +884,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { target: Option, unwind: mir::UnwindAction, fn_span: Span, + tail: bool, mergeable_succ: bool, ) -> MergingSucc { let source_info = mir::SourceInfo { span: fn_span, ..terminator.source_info }; @@ -1003,8 +1028,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // We still need to call `make_return_dest` even if there's no `target`, since // `fn_abi.ret` could be `PassMode::Indirect`, even if it is uninhabited, // and `make_return_dest` adds the return-place indirect pointer to `llargs`. - let return_dest = self.make_return_dest(bx, destination, &fn_abi.ret, &mut llargs); - let destination = target.map(|target| (return_dest, target)); + let destination = if !tail { + let return_dest = self.make_return_dest(bx, destination, &fn_abi.ret, &mut llargs); + target.map(|target| (return_dest, target)) + } else { + None + }; // Split the rust-call tupled arguments off. let (first_args, untuple) = if sig.abi() == ExternAbi::RustCall @@ -1147,6 +1176,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { unwind, &lifetime_ends_after_call, instance, + tail, mergeable_succ, ) } @@ -1388,15 +1418,23 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { target, unwind, fn_span, + false, mergeable_succ(), ), - mir::TerminatorKind::TailCall { .. } => { - // FIXME(explicit_tail_calls): implement tail calls in ssa backend - span_bug!( - terminator.source_info.span, - "`TailCall` terminator is not yet supported by `rustc_codegen_ssa`" - ) - } + mir::TerminatorKind::TailCall { ref func, ref args, fn_span } => self + .codegen_call_terminator( + helper, + bx, + terminator, + func, + args, + mir::Place::from(mir::RETURN_PLACE), + None, + mir::UnwindAction::Unreachable, + fn_span, + true, + mergeable_succ(), + ), mir::TerminatorKind::CoroutineDrop | mir::TerminatorKind::Yield { .. } => { bug!("coroutine ops in codegen") } diff --git a/compiler/rustc_codegen_ssa/src/traits/builder.rs b/compiler/rustc_codegen_ssa/src/traits/builder.rs index 979456a6ba70f..4b18146863bf4 100644 --- a/compiler/rustc_codegen_ssa/src/traits/builder.rs +++ b/compiler/rustc_codegen_ssa/src/traits/builder.rs @@ -595,6 +595,18 @@ pub trait BuilderMethods<'a, 'tcx>: funclet: Option<&Self::Funclet>, instance: Option>, ) -> Self::Value; + + fn tail_call( + &mut self, + llty: Self::Type, + fn_attrs: Option<&CodegenFnAttrs>, + fn_abi: &FnAbi<'tcx, Ty<'tcx>>, + llfn: Self::Value, + args: &[Self::Value], + funclet: Option<&Self::Funclet>, + instance: Option>, + ); + fn zext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; fn apply_attrs_to_cleanup_callsite(&mut self, llret: Self::Value); diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 90aa9188c8300..83d44f76e511d 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -51,6 +51,14 @@ // //===----------------------------------------------------------------------=== +// Define TailCallKind enum values to match LLVM's +enum LLVMRustTailCallKind { + LLVMRustTailCallKindNone = 0, + LLVMRustTailCallKindTail = 1, + LLVMRustTailCallKindMustTail = 2, + LLVMRustTailCallKindNoTail = 3 +}; + using namespace llvm; using namespace llvm::sys; using namespace llvm::object; @@ -1949,3 +1957,22 @@ extern "C" void LLVMRustSetNoSanitizeHWAddress(LLVMValueRef Global) { MD.NoHWAddress = true; GV.setSanitizerMetadata(MD); } + +extern "C" void LLVMSetTailCallKind(LLVMValueRef Call, + LLVMRustTailCallKind Kind) { + CallInst *CI = unwrap(Call); + switch (Kind) { + case LLVMRustTailCallKindNone: + CI->setTailCallKind(CallInst::TCK_None); + break; + case LLVMRustTailCallKindTail: + CI->setTailCallKind(CallInst::TCK_Tail); + break; + case LLVMRustTailCallKindMustTail: + CI->setTailCallKind(CallInst::TCK_MustTail); + break; + case LLVMRustTailCallKindNoTail: + CI->setTailCallKind(CallInst::TCK_NoTail); + break; + } +} From a96bd57ebcc38707d1d6121758c2ab32367060a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 21 Jul 2025 01:17:00 +0200 Subject: [PATCH 03/28] chore: clang-format --- compiler/rustc_codegen_llvm/src/builder.rs | 2 +- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 2 +- .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 17 ++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index c1beba767cf8c..0bb5de1b834fa 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -1383,7 +1383,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } } - llvm::LLVMSetTailCallKind(call, llvm::TailCallKind::MustTail); + llvm::LLVMRustSetTailCallKind(call, llvm::TailCallKind::MustTail); } fn zext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index f6e4b649b515f..ee5575370ed25 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1191,7 +1191,7 @@ unsafe extern "C" { pub(crate) safe fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool; pub(crate) safe fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool); pub(crate) safe fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool); - pub(crate) safe fn LLVMSetTailCallKind(CallInst: &Value, Kind: TailCallKind); + pub(crate) safe fn LLVMRustSetTailCallKind(CallInst: &Value, Kind: TailCallKind); // Operations on attributes pub(crate) fn LLVMCreateStringAttribute( diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 83d44f76e511d..50128500e09fa 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -51,14 +51,6 @@ // //===----------------------------------------------------------------------=== -// Define TailCallKind enum values to match LLVM's -enum LLVMRustTailCallKind { - LLVMRustTailCallKindNone = 0, - LLVMRustTailCallKindTail = 1, - LLVMRustTailCallKindMustTail = 2, - LLVMRustTailCallKindNoTail = 3 -}; - using namespace llvm; using namespace llvm::sys; using namespace llvm::object; @@ -1958,7 +1950,14 @@ extern "C" void LLVMRustSetNoSanitizeHWAddress(LLVMValueRef Global) { GV.setSanitizerMetadata(MD); } -extern "C" void LLVMSetTailCallKind(LLVMValueRef Call, +enum LLVMRustTailCallKind { + LLVMRustTailCallKindNone = 0, + LLVMRustTailCallKindTail = 1, + LLVMRustTailCallKindMustTail = 2, + LLVMRustTailCallKindNoTail = 3 +}; + +extern "C" void LLVMRustSetTailCallKind(LLVMValueRef Call, LLVMRustTailCallKind Kind) { CallInst *CI = unwrap(Call); switch (Kind) { From 205f4ca8b99efa2b17705942b4f70d13c01e60ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 21 Jul 2025 02:12:24 +0200 Subject: [PATCH 04/28] tests: add ui fail/pass tests and llvm ir tail codegen tests --- tests/codegen/become-musttail.rs | 18 ++++++++++++++++++ .../ui/explicit-tail-calls/recursion-no-tce.rs | 16 ++++++++++++++++ tests/ui/explicit-tail-calls/recursion-tce.rs | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 tests/codegen/become-musttail.rs create mode 100644 tests/ui/explicit-tail-calls/recursion-no-tce.rs create mode 100644 tests/ui/explicit-tail-calls/recursion-tce.rs diff --git a/tests/codegen/become-musttail.rs b/tests/codegen/become-musttail.rs new file mode 100644 index 0000000000000..779ee3efc21ce --- /dev/null +++ b/tests/codegen/become-musttail.rs @@ -0,0 +1,18 @@ +//@ compile-flags: -C opt-level=0 -Cpanic=abort -C no-prepopulate-passes +//@ needs-unwind + +#![crate_type = "lib"] +#![feature(explicit_tail_calls)] + +// CHECK-LABEL: define {{.*}}@fibonacci( +#[no_mangle] +#[inline(never)] +pub fn fibonacci(n: u64, a: u64, b: u64) -> u64 { + // CHECK: musttail call {{.*}}@fibonacci( + // CHECK-NEXT: ret u64 + match n { + 0 => a, + 1 => b, + _ => become fibonacci(n - 1, b, a + b), + } +} diff --git a/tests/ui/explicit-tail-calls/recursion-no-tce.rs b/tests/ui/explicit-tail-calls/recursion-no-tce.rs new file mode 100644 index 0000000000000..93e4cb655dc2f --- /dev/null +++ b/tests/ui/explicit-tail-calls/recursion-no-tce.rs @@ -0,0 +1,16 @@ +//@ run-fail + +use std::hint::black_box; + +pub fn count(curr: u64, top: u64) -> u64 { + if black_box(curr) >= top { + curr + } else { + count(curr + 1, top) + } +} + +fn main() { + println!("{}", + count(0, black_box(1000000))); +} diff --git a/tests/ui/explicit-tail-calls/recursion-tce.rs b/tests/ui/explicit-tail-calls/recursion-tce.rs new file mode 100644 index 0000000000000..8c89ceb7869aa --- /dev/null +++ b/tests/ui/explicit-tail-calls/recursion-tce.rs @@ -0,0 +1,17 @@ +//@ run-pass +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +use std::hint::black_box; + +pub fn count(curr: u64, top: u64) -> u64 { + if black_box(curr) >= top { + curr + } else { + become count(curr + 1, top) + } +} + +fn main() { + println!("{}", count(0, black_box(1000000))); +} From 3fac2797c5e07f2c4780c4bedefb5e846df032b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 21 Jul 2025 02:13:43 +0200 Subject: [PATCH 05/28] chore: fix typo --- tests/ui/explicit-tail-calls/recursion-no-tce.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/ui/explicit-tail-calls/recursion-no-tce.rs b/tests/ui/explicit-tail-calls/recursion-no-tce.rs index 93e4cb655dc2f..ada1a69509fa9 100644 --- a/tests/ui/explicit-tail-calls/recursion-no-tce.rs +++ b/tests/ui/explicit-tail-calls/recursion-no-tce.rs @@ -11,6 +11,5 @@ pub fn count(curr: u64, top: u64) -> u64 { } fn main() { - println!("{}", - count(0, black_box(1000000))); + println!("{}", count(0, black_box(1000000))); } From 55b5612b326c724d137ba1b7f138933d87eb57f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 21 Jul 2025 17:51:23 +0200 Subject: [PATCH 06/28] don't end lifetimes after call --- compiler/rustc_codegen_ssa/src/mir/block.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index e97a4e98a257a..42ff6fff90001 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -224,10 +224,6 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { if tail { bx.tail_call(fn_ty, fn_attrs, fn_abi, fn_ptr, llargs, self.funclet(fx), instance); - for &(tmp, size) in lifetime_ends_after_call { - bx.lifetime_end(tmp, size); - } - return MergingSucc::False; } From 2cd84dc29c99795bb25e9daf1587378ef2d7fe23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 21 Jul 2025 17:54:57 +0200 Subject: [PATCH 07/28] recursion-no-tce.rs should be run-crash --- tests/ui/explicit-tail-calls/recursion-no-tce.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/explicit-tail-calls/recursion-no-tce.rs b/tests/ui/explicit-tail-calls/recursion-no-tce.rs index ada1a69509fa9..c1f297804d3ad 100644 --- a/tests/ui/explicit-tail-calls/recursion-no-tce.rs +++ b/tests/ui/explicit-tail-calls/recursion-no-tce.rs @@ -1,4 +1,4 @@ -//@ run-fail +//@ run-crash use std::hint::black_box; From d424207be03627a946dc74ef2fb2c08e2d0dc19b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 21 Jul 2025 18:26:39 +0200 Subject: [PATCH 08/28] fix typo in codegen test --- tests/codegen/become-musttail.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codegen/become-musttail.rs b/tests/codegen/become-musttail.rs index 779ee3efc21ce..07f3357191042 100644 --- a/tests/codegen/become-musttail.rs +++ b/tests/codegen/become-musttail.rs @@ -9,7 +9,7 @@ #[inline(never)] pub fn fibonacci(n: u64, a: u64, b: u64) -> u64 { // CHECK: musttail call {{.*}}@fibonacci( - // CHECK-NEXT: ret u64 + // CHECK-NEXT: ret i64 match n { 0 => a, 1 => b, From dad96b107c0dd35ce2eecfaecc0e6af4988b3bb4 Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Sun, 20 Jul 2025 14:35:43 +0200 Subject: [PATCH 09/28] Use serde for target spec json deserialize The previous manual parsing of `serde_json::Value` was a lot of complicated code and extremely error-prone. It was full of janky behavior like sometimes ignoring type errors, sometimes erroring for type errors, sometimes warning for type errors, and sometimes just ICEing for type errors (the icing on the top). Additionally, many of the error messages about allowed values were out of date because they were in a completely different place than the FromStr impls. Overall, the system caused confusion for users. I also found the old deserialization code annoying to read. Whenever a `key!` invocation was found, one had to first look for the right macro arm, and no go to definition could help. This PR replaces all this manual parsing with a 2-step process involving serde. First, the string is parsed into a `TargetSpecJson` struct. This struct is a 1:1 representation of the spec JSON. It already parses all the enums and is very simple to read and write. Then, the fields from this struct are copied into the actual `Target`. The reason for this two-step process instead of just serializing into a `Target` is because of a few reasons 1. There are a few transformations performed between the two formats 2. The default logic is implemented this way. Otherwise all the default field values would have to be spelled out again, which is suboptimal. With this logic, they fall out naturally, because everything in the json struct is an `Option`. Overall, the mapping is pretty simple, with the vast majority of fields just doing a 1:1 mapping that is captured by two macros. I have deliberately avoided making the macros generic to keep them simple. All the `FromStr` impls now have the error message right inside them, which increases the chance of it being up to date. Some "`from_str`" impls were turned into proper `FromStr` impls to support this. The new code is much less involved, delegating all the JSON parsing logic to serde, without any manual type matching. This change introduces a few breaking changes for consumers. While it is possible to use this format on stable, it is very much subject to change, so breaking changes are expected. The hope is also that because of the way stricter behavior, breaking changes are easier to deal with, as they come with clearer error messages. 1. Invalid types now always error, everywhere. Previously, they would sometimes error, and sometimes just be ignored (which meant the users JSON was still broken, just silently!) 2. This now makes use of `deny_unknown_fields` instead of just warning on unused fields, which was done previously. Serde doesn't make it easy to get such warning behavior, which was the primary reason that this now changed. But I think error behavior is very reasonable too. If someone has random stale fields in their JSON, it is likely because these fields did something at some point but no longer do, and the user likely wants to be informed of this so they can figure out what to do. This is also relevant for the future. If we remove a field but someone has it set, it probably makes sense for them to take a look whether they need this and should look for alternatives, or whether they can just delete it. Overall, the JSON is made more explicit. This is the only expected breakage, but there could also be small breakage from small mistakes. All targets roundtrip though, so it can't be anything too major. --- Cargo.lock | 13 + compiler/rustc_session/src/config.rs | 4 +- compiler/rustc_session/src/options.rs | 2 +- compiler/rustc_target/Cargo.toml | 3 + compiler/rustc_target/src/json.rs | 15 + compiler/rustc_target/src/spec/json.rs | 1025 ++++++----------- compiler/rustc_target/src/spec/mod.rs | 388 ++++--- compiler/rustc_target/src/tests.rs | 50 +- src/librustdoc/doctest.rs | 2 +- src/tools/tidy/src/deps.rs | 1 + .../rustdoc-target-spec-json-path/target.json | 1 - .../target-specs/endianness-mismatch.json | 1 - .../target-specs/my-awesome-platform.json | 4 +- .../target-specs/my-incomplete-platform.json | 4 +- .../my-x86_64-unknown-linux-gnu-platform.json | 4 +- .../target-specs/require-explicit-cpu.json | 1 - tests/run-make/target-specs/rmake.rs | 4 +- tests/ui/check-cfg/my-awesome-platform.json | 1 - tests/ui/codegen/mismatched-data-layout.json | 1 - tests/ui/codegen/mismatched-data-layouts.rs | 1 + .../ui/codegen/mismatched-data-layouts.stderr | 2 +- 21 files changed, 678 insertions(+), 849 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d2fca8bb3f48..1537a60718623 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4499,7 +4499,10 @@ dependencies = [ "rustc_macros", "rustc_serialize", "rustc_span", + "serde", + "serde_derive", "serde_json", + "serde_path_to_error", "tracing", ] @@ -4870,6 +4873,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59fab13f937fa393d08645bf3a84bdfe86e296747b506ada67bb15f10f218b2a" +dependencies = [ + "itoa", + "serde", +] + [[package]] name = "serde_spanned" version = "0.6.9" diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index d6215e1de043a..190cb6c5e0388 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -336,12 +336,12 @@ impl LinkSelfContained { if let Some(component_to_enable) = component.strip_prefix('+') { self.explicitly_set = None; self.enabled_components - .insert(LinkSelfContainedComponents::from_str(component_to_enable)?); + .insert(LinkSelfContainedComponents::from_str(component_to_enable).ok()?); Some(()) } else if let Some(component_to_disable) = component.strip_prefix('-') { self.explicitly_set = None; self.disabled_components - .insert(LinkSelfContainedComponents::from_str(component_to_disable)?); + .insert(LinkSelfContainedComponents::from_str(component_to_disable).ok()?); Some(()) } else { None diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 2bdde2f887a30..313eec6268d3c 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1295,7 +1295,7 @@ pub mod parse { } pub(crate) fn parse_linker_flavor(slot: &mut Option, v: Option<&str>) -> bool { - match v.and_then(LinkerFlavorCli::from_str) { + match v.and_then(|v| LinkerFlavorCli::from_str(v).ok()) { Some(lf) => *slot = Some(lf), _ => return false, } diff --git a/compiler/rustc_target/Cargo.toml b/compiler/rustc_target/Cargo.toml index 0121c752dbdde..56932c24922e5 100644 --- a/compiler/rustc_target/Cargo.toml +++ b/compiler/rustc_target/Cargo.toml @@ -12,7 +12,10 @@ rustc_fs_util = { path = "../rustc_fs_util" } rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } +serde = "1.0.219" +serde_derive = "1.0.219" serde_json = "1.0.59" +serde_path_to_error = "0.1.17" tracing = "0.1" # tidy-alphabetical-end diff --git a/compiler/rustc_target/src/json.rs b/compiler/rustc_target/src/json.rs index 4fcc477921ba2..896609bdbe3a7 100644 --- a/compiler/rustc_target/src/json.rs +++ b/compiler/rustc_target/src/json.rs @@ -114,3 +114,18 @@ impl ToJson for rustc_abi::CanonAbi { self.to_string().to_json() } } + +macro_rules! serde_deserialize_from_str { + ($ty:ty) => { + impl<'de> serde::Deserialize<'de> for $ty { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + FromStr::from_str(&s).map_err(serde::de::Error::custom) + } + } + }; +} +pub(crate) use serde_deserialize_from_str; diff --git a/compiler/rustc_target/src/spec/json.rs b/compiler/rustc_target/src/spec/json.rs index 6c716f8712530..d27c1929aef74 100644 --- a/compiler/rustc_target/src/spec/json.rs +++ b/compiler/rustc_target/src/spec/json.rs @@ -1,60 +1,47 @@ -use std::borrow::Cow; use std::collections::BTreeMap; use std::str::FromStr; -use rustc_abi::{Align, AlignFromBytesError, ExternAbi}; -use serde_json::Value; +use rustc_abi::{Align, AlignFromBytesError}; -use super::{Target, TargetKind, TargetOptions, TargetWarnings}; +use super::crt_objects::CrtObjects; +use super::{ + BinaryFormat, CodeModel, DebuginfoKind, FloatAbi, FramePointer, LinkArgsCli, + LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFlavorCli, LldFlavor, + MergeFunctions, PanicStrategy, RelocModel, RelroLevel, RustcAbi, SanitizerSet, + SmallDataThresholdSupport, SplitDebuginfo, StackProbeType, StaticCow, SymbolVisibility, Target, + TargetKind, TargetOptions, TargetWarnings, TlsModel, +}; use crate::json::{Json, ToJson}; use crate::spec::AbiMap; impl Target { /// Loads a target descriptor from a JSON object. - pub fn from_json(obj: Json) -> Result<(Target, TargetWarnings), String> { - // While ugly, this code must remain this way to retain - // compatibility with existing JSON fields and the internal - // expected naming of the Target and TargetOptions structs. - // To ensure compatibility is retained, the built-in targets - // are round-tripped through this code to catch cases where - // the JSON parser is not updated to match the structs. - - let mut obj = match obj { - Value::Object(obj) => obj, - _ => return Err("Expected JSON object for target")?, - }; + pub fn from_json(json: &str) -> Result<(Target, TargetWarnings), String> { + let json_deserializer = &mut serde_json::Deserializer::from_str(json); - let mut get_req_field = |name: &str| { - obj.remove(name) - .and_then(|j| j.as_str().map(str::to_string)) - .ok_or_else(|| format!("Field {name} in target specification is required")) - }; + let json: TargetSpecJson = + serde_path_to_error::deserialize(json_deserializer).map_err(|err| err.to_string())?; let mut base = Target { - llvm_target: get_req_field("llvm-target")?.into(), + llvm_target: json.llvm_target, metadata: Default::default(), - pointer_width: get_req_field("target-pointer-width")? - .parse::() - .map_err(|_| "target-pointer-width must be an integer".to_string())?, - data_layout: get_req_field("data-layout")?.into(), - arch: get_req_field("arch")?.into(), + pointer_width: json + .target_pointer_width + .parse() + .map_err(|err| format!("invalid target-pointer-width: {err}"))?, + data_layout: json.data_layout, + arch: json.arch, options: Default::default(), }; // FIXME: This doesn't properly validate anything and just ignores the data if it's invalid. // That's okay for now, the only use of this is when generating docs, which we don't do for // custom targets. - if let Some(Json::Object(mut metadata)) = obj.remove("metadata") { - base.metadata.description = metadata - .remove("description") - .and_then(|desc| desc.as_str().map(|desc| desc.to_owned().into())); - base.metadata.tier = metadata - .remove("tier") - .and_then(|tier| tier.as_u64()) - .filter(|tier| (1..=3).contains(tier)); - base.metadata.host_tools = - metadata.remove("host_tools").and_then(|host| host.as_bool()); - base.metadata.std = metadata.remove("std").and_then(|host| host.as_bool()); + if let Some(metadata) = json.metadata { + base.metadata.description = metadata.description; + base.metadata.tier = metadata.tier.filter(|tier| (1..=3).contains(tier)); + base.metadata.host_tools = metadata.host_tools; + base.metadata.std = metadata.std; } let alignment_error = |field_name: &str, error: AlignFromBytesError| -> String { @@ -65,640 +52,188 @@ impl Target { format!("`{}` bits is not a valid value for {field_name}: {msg}", error.align() * 8) }; - let mut incorrect_type = vec![]; - - macro_rules! key { - ($key_name:ident) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(s) = obj.remove(&name).and_then(|s| s.as_str().map(str::to_string).map(Cow::from)) { - base.$key_name = s; - } - } ); - ($key_name:ident = $json_name:expr) => ( { - let name = $json_name; - if let Some(s) = obj.remove(name).and_then(|s| s.as_str().map(str::to_string).map(Cow::from)) { - base.$key_name = s; - } - } ); - ($key_name:ident = $json_name:expr, u64 as $int_ty:ty) => ( { - let name = $json_name; - if let Some(s) = obj.remove(name).and_then(|b| b.as_u64()) { - base.$key_name = s as $int_ty; - } - } ); - ($key_name:ident, bool) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(s) = obj.remove(&name).and_then(|b| b.as_bool()) { - base.$key_name = s; - } - } ); - ($key_name:ident = $json_name:expr, bool) => ( { - let name = $json_name; - if let Some(s) = obj.remove(name).and_then(|b| b.as_bool()) { - base.$key_name = s; - } - } ); - ($key_name:ident, u32) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(s) = obj.remove(&name).and_then(|b| b.as_u64()) { - if s < 1 || s > 5 { - return Err("Not a valid DWARF version number".into()); - } - base.$key_name = s as u32; - } - } ); - ($key_name:ident, Option) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(s) = obj.remove(&name).and_then(|b| b.as_bool()) { - base.$key_name = Some(s); - } - } ); - ($key_name:ident, Option) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(s) = obj.remove(&name).and_then(|b| b.as_u64()) { - base.$key_name = Some(s); - } - } ); - ($key_name:ident, Option>) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(s) = obj.remove(&name).and_then(|b| Some(b.as_str()?.to_string())) { - base.$key_name = Some(s.into()); - } - } ); - ($key_name:ident, Option) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(b) = obj.remove(&name).and_then(|b| b.as_u64()) { - match Align::from_bits(b) { - Ok(align) => base.$key_name = Some(align), - Err(e) => return Err(alignment_error(&name, e)), - } - } - } ); - ($key_name:ident, BinaryFormat) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|f| f.as_str().and_then(|s| { - match s.parse::() { - Ok(binary_format) => base.$key_name = binary_format, - _ => return Some(Err(format!( - "'{s}' is not a valid value for binary_format. \ - Use 'coff', 'elf', 'mach-o', 'wasm' or 'xcoff' " - ))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, MergeFunctions) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(mergefunc) => base.$key_name = mergefunc, - _ => return Some(Err(format!("'{}' is not a valid value for \ - merge-functions. Use 'disabled', \ - 'trampolines', or 'aliases'.", - s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, FloatAbi) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(float_abi) => base.$key_name = Some(float_abi), - _ => return Some(Err(format!("'{}' is not a valid value for \ - llvm-floatabi. Use 'soft' or 'hard'.", - s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, RustcAbi) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(rustc_abi) => base.$key_name = Some(rustc_abi), - _ => return Some(Err(format!( - "'{s}' is not a valid value for rustc-abi. \ - Use 'x86-softfloat' or leave the field unset." - ))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, RelocModel) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(relocation_model) => base.$key_name = relocation_model, - _ => return Some(Err(format!("'{}' is not a valid relocation model. \ - Run `rustc --print relocation-models` to \ - see the list of supported values.", s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, CodeModel) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(code_model) => base.$key_name = Some(code_model), - _ => return Some(Err(format!("'{}' is not a valid code model. \ - Run `rustc --print code-models` to \ - see the list of supported values.", s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, TlsModel) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(tls_model) => base.$key_name = tls_model, - _ => return Some(Err(format!("'{}' is not a valid TLS model. \ - Run `rustc --print tls-models` to \ - see the list of supported values.", s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, SmallDataThresholdSupport) => ( { - obj.remove("small-data-threshold-support").and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(support) => base.small_data_threshold_support = support, - _ => return Some(Err(format!("'{s}' is not a valid value for small-data-threshold-support."))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, PanicStrategy) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s { - "unwind" => base.$key_name = super::PanicStrategy::Unwind, - "abort" => base.$key_name = super::PanicStrategy::Abort, - _ => return Some(Err(format!("'{}' is not a valid value for \ - panic-strategy. Use 'unwind' or 'abort'.", - s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, RelroLevel) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(level) => base.$key_name = level, - _ => return Some(Err(format!("'{}' is not a valid value for \ - relro-level. Use 'full', 'partial, or 'off'.", - s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, Option) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(level) => base.$key_name = Some(level), - _ => return Some(Err(format!("'{}' is not a valid value for \ - symbol-visibility. Use 'hidden', 'protected, or 'interposable'.", - s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, DebuginfoKind) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(level) => base.$key_name = level, - _ => return Some(Err( - format!("'{s}' is not a valid value for debuginfo-kind. Use 'dwarf', \ - 'dwarf-dsym' or 'pdb'.") - )), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, SplitDebuginfo) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(level) => base.$key_name = level, - _ => return Some(Err(format!("'{}' is not a valid value for \ - split-debuginfo. Use 'off' or 'dsymutil'.", - s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, list) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(j) = obj.remove(&name) { - if let Some(v) = j.as_array() { - base.$key_name = v.iter() - .map(|a| a.as_str().unwrap().to_string().into()) - .collect(); - } else { - incorrect_type.push(name) - } - } - } ); - ($key_name:ident, opt_list) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(j) = obj.remove(&name) { - if let Some(v) = j.as_array() { - base.$key_name = Some(v.iter() - .map(|a| a.as_str().unwrap().to_string().into()) - .collect()); - } else { - incorrect_type.push(name) - } + macro_rules! forward { + ($name:ident) => { + if let Some($name) = json.$name { + base.$name = $name; } - } ); - ($key_name:ident, fallible_list) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|j| { - if let Some(v) = j.as_array() { - match v.iter().map(|a| FromStr::from_str(a.as_str().unwrap())).collect() { - Ok(l) => { base.$key_name = l }, - // FIXME: `fallible_list` can't re-use the `key!` macro for list - // elements and the error messages from that macro, so it has a bad - // generic message instead - Err(_) => return Some(Err( - format!("`{:?}` is not a valid value for `{}`", j, name) - )), - } - } else { - incorrect_type.push(name) - } - Some(Ok(())) - }).unwrap_or(Ok(())) - } ); - ($key_name:ident, optional) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(o) = obj.remove(&name) { - base.$key_name = o - .as_str() - .map(|s| s.to_string().into()); - } - } ); - ($key_name:ident = $json_name:expr, LldFlavor) => ( { - let name = $json_name; - obj.remove(name).and_then(|o| o.as_str().and_then(|s| { - if let Some(flavor) = super::LldFlavor::from_str(&s) { - base.$key_name = flavor; - } else { - return Some(Err(format!( - "'{}' is not a valid value for lld-flavor. \ - Use 'darwin', 'gnu', 'link' or 'wasm'.", - s))) - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident = $json_name:expr, LinkerFlavorCli) => ( { - let name = $json_name; - obj.remove(name).and_then(|o| o.as_str().and_then(|s| { - match super::LinkerFlavorCli::from_str(s) { - Some(linker_flavor) => base.$key_name = linker_flavor, - _ => return Some(Err(format!("'{}' is not a valid value for linker-flavor. \ - Use {}", s, super::LinkerFlavorCli::one_of()))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident, StackProbeType) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| match super::StackProbeType::from_json(&o) { - Ok(v) => { - base.$key_name = v; - Some(Ok(())) - }, - Err(s) => Some(Err( - format!("`{:?}` is not a valid value for `{}`: {}", o, name, s) - )), - }).unwrap_or(Ok(())) - } ); - ($key_name:ident, SanitizerSet) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(o) = obj.remove(&name) { - if let Some(a) = o.as_array() { - for s in a { - use super::SanitizerSet; - base.$key_name |= match s.as_str() { - Some("address") => SanitizerSet::ADDRESS, - Some("cfi") => SanitizerSet::CFI, - Some("dataflow") => SanitizerSet::DATAFLOW, - Some("kcfi") => SanitizerSet::KCFI, - Some("kernel-address") => SanitizerSet::KERNELADDRESS, - Some("leak") => SanitizerSet::LEAK, - Some("memory") => SanitizerSet::MEMORY, - Some("memtag") => SanitizerSet::MEMTAG, - Some("safestack") => SanitizerSet::SAFESTACK, - Some("shadow-call-stack") => SanitizerSet::SHADOWCALLSTACK, - Some("thread") => SanitizerSet::THREAD, - Some("hwaddress") => SanitizerSet::HWADDRESS, - Some(s) => return Err(format!("unknown sanitizer {}", s)), - _ => return Err(format!("not a string: {:?}", s)), - }; - } - } else { - incorrect_type.push(name) - } - } - Ok::<(), String>(()) - } ); - ($key_name:ident, link_self_contained_components) => ( { - // Skeleton of what needs to be parsed: - // - // ``` - // $name: { - // "components": [ - // - // ] - // } - // ``` - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(o) = obj.remove(&name) { - if let Some(o) = o.as_object() { - let component_array = o.get("components") - .ok_or_else(|| format!("{name}: expected a \ - JSON object with a `components` field."))?; - let component_array = component_array.as_array() - .ok_or_else(|| format!("{name}.components: expected a JSON array"))?; - let mut components = super::LinkSelfContainedComponents::empty(); - for s in component_array { - components |= match s.as_str() { - Some(s) => { - super::LinkSelfContainedComponents::from_str(s) - .ok_or_else(|| format!("unknown \ - `-Clink-self-contained` component: {s}"))? - }, - _ => return Err(format!("not a string: {:?}", s)), - }; - } - base.$key_name = super::LinkSelfContainedDefault::WithComponents(components); - } else { - incorrect_type.push(name) - } - } - Ok::<(), String>(()) - } ); - ($key_name:ident = $json_name:expr, link_self_contained_backwards_compatible) => ( { - let name = $json_name; - obj.remove(name).and_then(|o| o.as_str().and_then(|s| { - match s.parse::() { - Ok(lsc_default) => base.$key_name = lsc_default, - _ => return Some(Err(format!("'{}' is not a valid `-Clink-self-contained` default. \ - Use 'false', 'true', 'musl' or 'mingw'", s))), - } - Some(Ok(())) - })).unwrap_or(Ok(())) - } ); - ($key_name:ident = $json_name:expr, link_objects) => ( { - let name = $json_name; - if let Some(val) = obj.remove(name) { - let obj = val.as_object().ok_or_else(|| format!("{}: expected a \ - JSON object with fields per CRT object kind.", name))?; - let mut args = super::CrtObjects::new(); - for (k, v) in obj { - let kind = super::LinkOutputKind::from_str(&k).ok_or_else(|| { - format!("{}: '{}' is not a valid value for CRT object kind. \ - Use '(dynamic,static)-(nopic,pic)-exe' or \ - '(dynamic,static)-dylib' or 'wasi-reactor-exe'", name, k) - })?; - - let v = v.as_array().ok_or_else(|| - format!("{}.{}: expected a JSON array", name, k) - )?.iter().enumerate() - .map(|(i,s)| { - let s = s.as_str().ok_or_else(|| - format!("{}.{}[{}]: expected a JSON string", name, k, i))?; - Ok(s.to_string().into()) - }) - .collect::, String>>()?; - - args.insert(kind, v); - } - base.$key_name = args; - } - } ); - ($key_name:ident = $json_name:expr, link_args) => ( { - let name = $json_name; - if let Some(val) = obj.remove(name) { - let obj = val.as_object().ok_or_else(|| format!("{}: expected a \ - JSON object with fields per linker-flavor.", name))?; - let mut args = super::LinkArgsCli::new(); - for (k, v) in obj { - let flavor = super::LinkerFlavorCli::from_str(&k).ok_or_else(|| { - format!("{}: '{}' is not a valid value for linker-flavor. \ - Use 'em', 'gcc', 'ld' or 'msvc'", name, k) - })?; - - let v = v.as_array().ok_or_else(|| - format!("{}.{}: expected a JSON array", name, k) - )?.iter().enumerate() - .map(|(i,s)| { - let s = s.as_str().ok_or_else(|| - format!("{}.{}[{}]: expected a JSON string", name, k, i))?; - Ok(s.to_string().into()) - }) - .collect::, String>>()?; - - args.insert(flavor, v); - } - base.$key_name = args; - } - } ); - ($key_name:ident, env) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - if let Some(o) = obj.remove(&name) { - if let Some(a) = o.as_array() { - for o in a { - if let Some(s) = o.as_str() { - if let [k, v] = *s.split('=').collect::>() { - base.$key_name - .to_mut() - .push((k.to_string().into(), v.to_string().into())) - } - } - } - } else { - incorrect_type.push(name) - } + }; + } + macro_rules! forward_opt { + ($name:ident) => { + if let Some($name) = json.$name { + base.$name = Some($name); } - } ); - ($key_name:ident, target_families) => ( { - if let Some(value) = obj.remove("target-family") { - if let Some(v) = value.as_array() { - base.$key_name = v.iter() - .map(|a| a.as_str().unwrap().to_string().into()) - .collect(); - } else if let Some(v) = value.as_str() { - base.$key_name = vec![v.to_string().into()].into(); - } + }; + } + + if let Some(target_endian) = json.target_endian { + base.endian = target_endian.0; + } + + forward!(frame_pointer); + forward!(c_int_width); + forward_opt!(c_enum_min_bits); // if None, matches c_int_width + forward!(os); + forward!(env); + forward!(abi); + forward!(vendor); + forward_opt!(linker); + forward!(linker_flavor_json); + forward!(lld_flavor_json); + forward!(linker_is_gnu_json); + forward!(pre_link_objects); + forward!(post_link_objects); + forward!(pre_link_objects_self_contained); + forward!(post_link_objects_self_contained); + + // Deserializes the backwards-compatible variants of `-Clink-self-contained` + if let Some(link_self_contained) = json.link_self_contained_backwards_compatible { + base.link_self_contained = link_self_contained; + } + // Deserializes the components variant of `-Clink-self-contained` + if let Some(link_self_contained) = json.link_self_contained { + let components = link_self_contained + .components + .into_iter() + .fold(LinkSelfContainedComponents::empty(), |a, b| a | b); + base.link_self_contained = LinkSelfContainedDefault::WithComponents(components); + } + + forward!(pre_link_args_json); + forward!(late_link_args_json); + forward!(late_link_args_dynamic_json); + forward!(late_link_args_static_json); + forward!(post_link_args_json); + forward_opt!(link_script); + + if let Some(link_env) = json.link_env { + for s in link_env { + if let [k, v] = *s.split('=').collect::>() { + base.link_env.to_mut().push((k.to_string().into(), v.to_string().into())) + } else { + return Err(format!("link-env value '{s}' must be of the pattern 'KEY=VALUE'")); } - } ); + } } - if let Some(j) = obj.remove("target-endian") { - if let Some(s) = j.as_str() { - base.endian = s.parse()?; - } else { - incorrect_type.push("target-endian".into()) + forward!(link_env_remove); + forward!(asm_args); + forward!(cpu); + forward!(need_explicit_cpu); + forward!(features); + forward!(dynamic_linking); + forward_opt!(direct_access_external_data); + forward!(dll_tls_export); + forward!(only_cdylib); + forward!(executables); + forward!(relocation_model); + forward_opt!(code_model); + forward!(tls_model); + forward!(disable_redzone); + forward!(function_sections); + forward!(dll_prefix); + forward!(dll_suffix); + forward!(exe_suffix); + forward!(staticlib_prefix); + forward!(staticlib_suffix); + + if let Some(target_family) = json.target_family { + match target_family { + TargetFamiliesJson::Array(families) => base.families = families, + TargetFamiliesJson::String(family) => base.families = vec![family].into(), } } - if let Some(fp) = obj.remove("frame-pointer") { - if let Some(s) = fp.as_str() { - base.frame_pointer = s - .parse() - .map_err(|()| format!("'{s}' is not a valid value for frame-pointer"))?; - } else { - incorrect_type.push("frame-pointer".into()) + forward!(abi_return_struct_as_int); + forward!(is_like_aix); + forward!(is_like_darwin); + forward!(is_like_solaris); + forward!(is_like_windows); + forward!(is_like_msvc); + forward!(is_like_wasm); + forward!(is_like_android); + forward!(binary_format); + forward!(default_dwarf_version); + forward!(allows_weak_linkage); + forward!(has_rpath); + forward!(no_default_libraries); + forward!(position_independent_executables); + forward!(static_position_independent_executables); + forward!(plt_by_default); + forward!(relro_level); + forward!(archive_format); + forward!(allow_asm); + forward!(main_needs_argc_argv); + forward!(has_thread_local); + forward!(obj_is_bitcode); + forward!(bitcode_llvm_cmdline); + forward_opt!(max_atomic_width); + forward_opt!(min_atomic_width); + forward!(atomic_cas); + forward!(panic_strategy); + forward!(crt_static_allows_dylibs); + forward!(crt_static_default); + forward!(crt_static_respected); + forward!(stack_probes); + + if let Some(min_global_align) = json.min_global_align { + match Align::from_bits(min_global_align) { + Ok(align) => base.min_global_align = Some(align), + Err(e) => return Err(alignment_error("min-global-align", e)), } } - key!(c_int_width = "target-c-int-width", u64 as u16); - key!(c_enum_min_bits, Option); // if None, matches c_int_width - key!(os); - key!(env); - key!(abi); - key!(vendor); - key!(linker, optional); - key!(linker_flavor_json = "linker-flavor", LinkerFlavorCli)?; - key!(lld_flavor_json = "lld-flavor", LldFlavor)?; - key!(linker_is_gnu_json = "linker-is-gnu", bool); - key!(pre_link_objects = "pre-link-objects", link_objects); - key!(post_link_objects = "post-link-objects", link_objects); - key!(pre_link_objects_self_contained = "pre-link-objects-fallback", link_objects); - key!(post_link_objects_self_contained = "post-link-objects-fallback", link_objects); - // Deserializes the backwards-compatible variants of `-Clink-self-contained` - key!( - link_self_contained = "crt-objects-fallback", - link_self_contained_backwards_compatible - )?; - // Deserializes the components variant of `-Clink-self-contained` - key!(link_self_contained, link_self_contained_components)?; - key!(pre_link_args_json = "pre-link-args", link_args); - key!(late_link_args_json = "late-link-args", link_args); - key!(late_link_args_dynamic_json = "late-link-args-dynamic", link_args); - key!(late_link_args_static_json = "late-link-args-static", link_args); - key!(post_link_args_json = "post-link-args", link_args); - key!(link_script, optional); - key!(link_env, env); - key!(link_env_remove, list); - key!(asm_args, list); - key!(cpu); - key!(need_explicit_cpu, bool); - key!(features); - key!(dynamic_linking, bool); - key!(direct_access_external_data, Option); - key!(dll_tls_export, bool); - key!(only_cdylib, bool); - key!(executables, bool); - key!(relocation_model, RelocModel)?; - key!(code_model, CodeModel)?; - key!(tls_model, TlsModel)?; - key!(disable_redzone, bool); - key!(function_sections, bool); - key!(dll_prefix); - key!(dll_suffix); - key!(exe_suffix); - key!(staticlib_prefix); - key!(staticlib_suffix); - key!(families, target_families); - key!(abi_return_struct_as_int, bool); - key!(is_like_aix, bool); - key!(is_like_darwin, bool); - key!(is_like_solaris, bool); - key!(is_like_windows, bool); - key!(is_like_msvc, bool); - key!(is_like_wasm, bool); - key!(is_like_android, bool); - key!(binary_format, BinaryFormat)?; - key!(default_dwarf_version, u32); - key!(allows_weak_linkage, bool); - key!(has_rpath, bool); - key!(no_default_libraries, bool); - key!(position_independent_executables, bool); - key!(static_position_independent_executables, bool); - key!(plt_by_default, bool); - key!(relro_level, RelroLevel)?; - key!(archive_format); - key!(allow_asm, bool); - key!(main_needs_argc_argv, bool); - key!(has_thread_local, bool); - key!(obj_is_bitcode, bool); - key!(bitcode_llvm_cmdline); - key!(max_atomic_width, Option); - key!(min_atomic_width, Option); - key!(atomic_cas, bool); - key!(panic_strategy, PanicStrategy)?; - key!(crt_static_allows_dylibs, bool); - key!(crt_static_default, bool); - key!(crt_static_respected, bool); - key!(stack_probes, StackProbeType)?; - key!(min_global_align, Option); - key!(default_codegen_units, Option); - key!(default_codegen_backend, Option>); - key!(trap_unreachable, bool); - key!(requires_lto, bool); - key!(singlethread, bool); - key!(no_builtins, bool); - key!(default_visibility, Option)?; - key!(emit_debug_gdb_scripts, bool); - key!(requires_uwtable, bool); - key!(default_uwtable, bool); - key!(simd_types_indirect, bool); - key!(limit_rdylib_exports, bool); - key!(override_export_symbols, opt_list); - key!(merge_functions, MergeFunctions)?; - key!(mcount = "target-mcount"); - key!(llvm_mcount_intrinsic, optional); - key!(llvm_abiname); - key!(llvm_floatabi, FloatAbi)?; - key!(rustc_abi, RustcAbi)?; - key!(relax_elf_relocations, bool); - key!(llvm_args, list); - key!(use_ctors_section, bool); - key!(eh_frame_header, bool); - key!(has_thumb_interworking, bool); - key!(debuginfo_kind, DebuginfoKind)?; - key!(split_debuginfo, SplitDebuginfo)?; - key!(supported_split_debuginfo, fallible_list)?; - key!(supported_sanitizers, SanitizerSet)?; - key!(generate_arange_section, bool); - key!(supports_stack_protector, bool); - key!(small_data_threshold_support, SmallDataThresholdSupport)?; - key!(entry_name); - key!(supports_xray, bool); + forward_opt!(default_codegen_units); + forward_opt!(default_codegen_backend); + forward!(trap_unreachable); + forward!(requires_lto); + forward!(singlethread); + forward!(no_builtins); + forward_opt!(default_visibility); + forward!(emit_debug_gdb_scripts); + forward!(requires_uwtable); + forward!(default_uwtable); + forward!(simd_types_indirect); + forward!(limit_rdylib_exports); + forward_opt!(override_export_symbols); + forward!(merge_functions); + forward!(mcount); + forward_opt!(llvm_mcount_intrinsic); + forward!(llvm_abiname); + forward_opt!(llvm_floatabi); + forward_opt!(rustc_abi); + forward!(relax_elf_relocations); + forward!(llvm_args); + forward!(use_ctors_section); + forward!(eh_frame_header); + forward!(has_thumb_interworking); + forward!(debuginfo_kind); + forward!(split_debuginfo); + forward!(supported_split_debuginfo); + + if let Some(supported_sanitizers) = json.supported_sanitizers { + base.supported_sanitizers = + supported_sanitizers.into_iter().fold(SanitizerSet::empty(), |a, b| a | b); + } + + forward!(generate_arange_section); + forward!(supports_stack_protector); + forward!(small_data_threshold_support); + forward!(entry_name); + forward!(supports_xray); // we're going to run `update_from_cli`, but that won't change the target's AbiMap // FIXME: better factor the Target definition so we enforce this on a type level let abi_map = AbiMap::from_target(&base); - - if let Some(abi_str) = obj.remove("entry-abi") { - if let Json::String(abi_str) = abi_str { - match abi_str.parse::() { - Ok(abi) => base.options.entry_abi = abi_map.canonize_abi(abi, false).unwrap(), - Err(_) => return Err(format!("{abi_str} is not a valid ExternAbi")), - } - } else { - incorrect_type.push("entry-abi".to_owned()) - } + if let Some(entry_abi) = json.entry_abi { + base.options.entry_abi = abi_map.canonize_abi(entry_abi.0, false).unwrap(); } base.update_from_cli(); base.check_consistency(TargetKind::Json)?; - // Each field should have been read using `Json::remove` so any keys remaining are unused. - let remaining_keys = obj.keys(); - Ok(( - base, - TargetWarnings { unused_fields: remaining_keys.cloned().collect(), incorrect_type }, - )) + Ok((base, TargetWarnings { unused_fields: vec![] })) } } @@ -877,3 +412,189 @@ impl ToJson for Target { Json::Object(d) } } + +#[derive(serde_derive::Deserialize)] +struct LinkSelfContainedComponentsWrapper { + components: Vec, +} + +#[derive(serde_derive::Deserialize)] +#[serde(untagged)] +enum TargetFamiliesJson { + Array(StaticCow<[StaticCow]>), + String(StaticCow), +} + +/// `Endian` is in `rustc_abi`, which doesn't have access to the macro and serde. +struct EndianWrapper(rustc_abi::Endian); +impl FromStr for EndianWrapper { + type Err = String; + fn from_str(s: &str) -> Result { + rustc_abi::Endian::from_str(s).map(Self) + } +} +crate::json::serde_deserialize_from_str!(EndianWrapper); + +/// `ExternAbi` is in `rustc_abi`, which doesn't have access to the macro and serde. +struct ExternAbiWrapper(rustc_abi::ExternAbi); +impl FromStr for ExternAbiWrapper { + type Err = String; + fn from_str(s: &str) -> Result { + rustc_abi::ExternAbi::from_str(s) + .map(Self) + .map_err(|_| format!("{s} is not a valid extern ABI")) + } +} +crate::json::serde_deserialize_from_str!(ExternAbiWrapper); + +#[derive(serde_derive::Deserialize)] +struct TargetSpecJsonMetadata { + description: Option>, + tier: Option, + host_tools: Option, + std: Option, +} + +#[derive(serde_derive::Deserialize)] +#[serde(rename_all = "kebab-case")] +// Ensure that all unexpected fields get turned into errors. +// This helps users stay up to date when the schema changes instead of silently +// ignoring their old values. +#[serde(deny_unknown_fields)] +struct TargetSpecJson { + llvm_target: StaticCow, + target_pointer_width: String, + data_layout: StaticCow, + arch: StaticCow, + + metadata: Option, + + // options: + target_endian: Option, + frame_pointer: Option, + #[serde(rename = "target-c-int-width")] + c_int_width: Option, + c_enum_min_bits: Option, + os: Option>, + env: Option>, + abi: Option>, + vendor: Option>, + linker: Option>, + #[serde(rename = "linker-flavor")] + linker_flavor_json: Option, + #[serde(rename = "lld-flavor")] + lld_flavor_json: Option, + #[serde(rename = "linker-is-gnu")] + linker_is_gnu_json: Option, + #[serde(rename = "pre-link-objects")] + pre_link_objects: Option, + #[serde(rename = "post-link-objects")] + post_link_objects: Option, + #[serde(rename = "pre-link-objects-fallback")] + pre_link_objects_self_contained: Option, + #[serde(rename = "post-link-objects-fallback")] + post_link_objects_self_contained: Option, + #[serde(rename = "crt-objects-fallback")] + link_self_contained_backwards_compatible: Option, + link_self_contained: Option, + #[serde(rename = "pre-link-args")] + pre_link_args_json: Option, + #[serde(rename = "late-link-args")] + late_link_args_json: Option, + #[serde(rename = "late-link-args-dynamic")] + late_link_args_dynamic_json: Option, + #[serde(rename = "late-link-args-static")] + late_link_args_static_json: Option, + #[serde(rename = "post-link-args")] + post_link_args_json: Option, + link_script: Option>, + link_env: Option>>, + link_env_remove: Option]>>, + asm_args: Option]>>, + cpu: Option>, + need_explicit_cpu: Option, + features: Option>, + dynamic_linking: Option, + direct_access_external_data: Option, + dll_tls_export: Option, + only_cdylib: Option, + executables: Option, + relocation_model: Option, + code_model: Option, + tls_model: Option, + disable_redzone: Option, + function_sections: Option, + dll_prefix: Option>, + dll_suffix: Option>, + exe_suffix: Option>, + staticlib_prefix: Option>, + staticlib_suffix: Option>, + target_family: Option, + abi_return_struct_as_int: Option, + is_like_aix: Option, + is_like_darwin: Option, + is_like_solaris: Option, + is_like_windows: Option, + is_like_msvc: Option, + is_like_wasm: Option, + is_like_android: Option, + binary_format: Option, + default_dwarf_version: Option, + allows_weak_linkage: Option, + has_rpath: Option, + no_default_libraries: Option, + position_independent_executables: Option, + static_position_independent_executables: Option, + plt_by_default: Option, + relro_level: Option, + archive_format: Option>, + allow_asm: Option, + main_needs_argc_argv: Option, + has_thread_local: Option, + obj_is_bitcode: Option, + bitcode_llvm_cmdline: Option>, + max_atomic_width: Option, + min_atomic_width: Option, + atomic_cas: Option, + panic_strategy: Option, + crt_static_allows_dylibs: Option, + crt_static_default: Option, + crt_static_respected: Option, + stack_probes: Option, + min_global_align: Option, + default_codegen_units: Option, + default_codegen_backend: Option>, + trap_unreachable: Option, + requires_lto: Option, + singlethread: Option, + no_builtins: Option, + default_visibility: Option, + emit_debug_gdb_scripts: Option, + requires_uwtable: Option, + default_uwtable: Option, + simd_types_indirect: Option, + limit_rdylib_exports: Option, + override_export_symbols: Option]>>, + merge_functions: Option, + #[serde(rename = "target-mcount")] + mcount: Option>, + llvm_mcount_intrinsic: Option>, + llvm_abiname: Option>, + llvm_floatabi: Option, + rustc_abi: Option, + relax_elf_relocations: Option, + llvm_args: Option]>>, + use_ctors_section: Option, + eh_frame_header: Option, + has_thumb_interworking: Option, + debuginfo_kind: Option, + split_debuginfo: Option, + supported_split_debuginfo: Option>, + supported_sanitizers: Option>, + generate_arange_section: Option, + supports_stack_protector: Option, + small_data_threshold_support: Option, + entry_name: Option>, + supports_xray: Option, + entry_abi: Option, +} diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 4bc0d88a910cb..c64cd9a51b7d2 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -37,6 +37,7 @@ //! //! [JSON]: https://json.org +use core::result::Result; use std::borrow::Cow; use std::collections::BTreeMap; use std::hash::{Hash, Hasher}; @@ -198,18 +199,29 @@ impl LldFlavor { LldFlavor::Link => "link", } } +} - fn from_str(s: &str) -> Option { - Some(match s { +impl FromStr for LldFlavor { + type Err = String; + + fn from_str(s: &str) -> Result { + Ok(match s { "darwin" => LldFlavor::Ld64, "gnu" => LldFlavor::Ld, "link" => LldFlavor::Link, "wasm" => LldFlavor::Wasm, - _ => return None, + _ => { + return Err( + "invalid value for lld flavor: '{s}', expected one of 'darwin', 'gnu', 'link', 'wasm'" + .into(), + ); + } }) } } +crate::json::serde_deserialize_from_str!(LldFlavor); + impl ToJson for LldFlavor { fn to_json(&self) -> Json { self.as_str().to_json() @@ -494,19 +506,23 @@ macro_rules! linker_flavor_cli_impls { concat!("one of: ", $($string, " ",)*) } - pub fn from_str(s: &str) -> Option { - Some(match s { - $($string => $($flavor)*,)* - _ => return None, - }) - } - pub fn desc(self) -> &'static str { match self { $($($flavor)* => $string,)* } } } + + impl FromStr for LinkerFlavorCli { + type Err = String; + + fn from_str(s: &str) -> Result { + Ok(match s { + $($string => $($flavor)*,)* + _ => return Err(format!("invalid linker flavor, allowed values: {}", Self::one_of())), + }) + } + } ) } @@ -540,6 +556,8 @@ linker_flavor_cli_impls! { (LinkerFlavorCli::Em) "em" } +crate::json::serde_deserialize_from_str!(LinkerFlavorCli); + impl ToJson for LinkerFlavorCli { fn to_json(&self) -> Json { self.desc().to_json() @@ -573,19 +591,26 @@ pub enum LinkSelfContainedDefault { /// Parses a backwards-compatible `-Clink-self-contained` option string, without components. impl FromStr for LinkSelfContainedDefault { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { Ok(match s { "false" => LinkSelfContainedDefault::False, "true" | "wasm" => LinkSelfContainedDefault::True, "musl" => LinkSelfContainedDefault::InferredForMusl, "mingw" => LinkSelfContainedDefault::InferredForMingw, - _ => return Err(()), + _ => { + return Err(format!( + "'{s}' is not a valid `-Clink-self-contained` default. \ + Use 'false', 'true', 'wasm', 'musl' or 'mingw'", + )); + } }) } } +crate::json::serde_deserialize_from_str!(LinkSelfContainedDefault); + impl ToJson for LinkSelfContainedDefault { fn to_json(&self) -> Json { match *self { @@ -652,19 +677,6 @@ bitflags::bitflags! { rustc_data_structures::external_bitflags_debug! { LinkSelfContainedComponents } impl LinkSelfContainedComponents { - /// Parses a single `-Clink-self-contained` well-known component, not a set of flags. - pub fn from_str(s: &str) -> Option { - Some(match s { - "crto" => LinkSelfContainedComponents::CRT_OBJECTS, - "libc" => LinkSelfContainedComponents::LIBC, - "unwind" => LinkSelfContainedComponents::UNWIND, - "linker" => LinkSelfContainedComponents::LINKER, - "sanitizers" => LinkSelfContainedComponents::SANITIZERS, - "mingw" => LinkSelfContainedComponents::MINGW, - _ => return None, - }) - } - /// Return the component's name. /// /// Returns `None` if the bitflags aren't a singular component (but a mix of multiple flags). @@ -708,6 +720,29 @@ impl LinkSelfContainedComponents { } } +impl FromStr for LinkSelfContainedComponents { + type Err = String; + + /// Parses a single `-Clink-self-contained` well-known component, not a set of flags. + fn from_str(s: &str) -> Result { + Ok(match s { + "crto" => LinkSelfContainedComponents::CRT_OBJECTS, + "libc" => LinkSelfContainedComponents::LIBC, + "unwind" => LinkSelfContainedComponents::UNWIND, + "linker" => LinkSelfContainedComponents::LINKER, + "sanitizers" => LinkSelfContainedComponents::SANITIZERS, + "mingw" => LinkSelfContainedComponents::MINGW, + _ => { + return Err(format!( + "'{s}' is not a valid link-self-contained component, expected 'crto', 'libc', 'unwind', 'linker', 'sanitizers', 'mingw'" + )); + } + }) + } +} + +crate::json::serde_deserialize_from_str!(LinkSelfContainedComponents); + impl ToJson for LinkSelfContainedComponents { fn to_json(&self) -> Json { let components: Vec<_> = Self::all_components() @@ -821,6 +856,25 @@ impl PanicStrategy { } } +impl FromStr for PanicStrategy { + type Err = String; + fn from_str(s: &str) -> Result { + Ok(match s { + "unwind" => PanicStrategy::Unwind, + "abort" => PanicStrategy::Abort, + _ => { + return Err(format!( + "'{}' is not a valid value for \ + panic-strategy. Use 'unwind' or 'abort'.", + s + )); + } + }) + } +} + +crate::json::serde_deserialize_from_str!(PanicStrategy); + impl ToJson for PanicStrategy { fn to_json(&self) -> Json { match *self { @@ -867,18 +921,24 @@ impl SymbolVisibility { } impl FromStr for SymbolVisibility { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { match s { "hidden" => Ok(SymbolVisibility::Hidden), "protected" => Ok(SymbolVisibility::Protected), "interposable" => Ok(SymbolVisibility::Interposable), - _ => Err(()), + _ => Err(format!( + "'{}' is not a valid value for \ + symbol-visibility. Use 'hidden', 'protected, or 'interposable'.", + s + )), } } } +crate::json::serde_deserialize_from_str!(SymbolVisibility); + impl ToJson for SymbolVisibility { fn to_json(&self) -> Json { match *self { @@ -890,19 +950,25 @@ impl ToJson for SymbolVisibility { } impl FromStr for RelroLevel { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { match s { "full" => Ok(RelroLevel::Full), "partial" => Ok(RelroLevel::Partial), "off" => Ok(RelroLevel::Off), "none" => Ok(RelroLevel::None), - _ => Err(()), + _ => Err(format!( + "'{}' is not a valid value for \ + relro-level. Use 'full', 'partial, 'off', or 'none'.", + s + )), } } } +crate::json::serde_deserialize_from_str!(RelroLevel); + impl ToJson for RelroLevel { fn to_json(&self) -> Json { match *self { @@ -923,7 +989,7 @@ pub enum SmallDataThresholdSupport { } impl FromStr for SmallDataThresholdSupport { - type Err = (); + type Err = String; fn from_str(s: &str) -> Result { if s == "none" { @@ -935,11 +1001,13 @@ impl FromStr for SmallDataThresholdSupport { } else if let Some(arg) = s.strip_prefix("llvm-arg=") { Ok(Self::LlvmArg(arg.to_string().into())) } else { - Err(()) + Err(format!("'{s}' is not a valid value for small-data-threshold-support.")) } } } +crate::json::serde_deserialize_from_str!(SmallDataThresholdSupport); + impl ToJson for SmallDataThresholdSupport { fn to_json(&self) -> Value { match self { @@ -969,18 +1037,25 @@ impl MergeFunctions { } impl FromStr for MergeFunctions { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { match s { "disabled" => Ok(MergeFunctions::Disabled), "trampolines" => Ok(MergeFunctions::Trampolines), "aliases" => Ok(MergeFunctions::Aliases), - _ => Err(()), + _ => Err(format!( + "'{}' is not a valid value for \ + merge-functions. Use 'disabled', \ + 'trampolines', or 'aliases'.", + s + )), } } } +crate::json::serde_deserialize_from_str!(MergeFunctions); + impl ToJson for MergeFunctions { fn to_json(&self) -> Json { match *self { @@ -1040,9 +1115,9 @@ impl RelocModel { } impl FromStr for RelocModel { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { Ok(match s { "static" => RelocModel::Static, "pic" => RelocModel::Pic, @@ -1051,11 +1126,19 @@ impl FromStr for RelocModel { "ropi" => RelocModel::Ropi, "rwpi" => RelocModel::Rwpi, "ropi-rwpi" => RelocModel::RopiRwpi, - _ => return Err(()), + _ => { + return Err(format!( + "invalid relocation model '{s}'. + Run `rustc --print relocation-models` to \ + see the list of supported values.'" + )); + } }) } } +crate::json::serde_deserialize_from_str!(RelocModel); + impl ToJson for RelocModel { fn to_json(&self) -> Json { self.desc().to_json() @@ -1072,20 +1155,28 @@ pub enum CodeModel { } impl FromStr for CodeModel { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { Ok(match s { "tiny" => CodeModel::Tiny, "small" => CodeModel::Small, "kernel" => CodeModel::Kernel, "medium" => CodeModel::Medium, "large" => CodeModel::Large, - _ => return Err(()), + _ => { + return Err(format!( + "'{s}' is not a valid code model. \ + Run `rustc --print code-models` to \ + see the list of supported values." + )); + } }) } } +crate::json::serde_deserialize_from_str!(CodeModel); + impl ToJson for CodeModel { fn to_json(&self) -> Json { match *self { @@ -1107,17 +1198,25 @@ pub enum FloatAbi { } impl FromStr for FloatAbi { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { Ok(match s { "soft" => FloatAbi::Soft, "hard" => FloatAbi::Hard, - _ => return Err(()), + _ => { + return Err(format!( + "'{}' is not a valid value for \ + llvm-floatabi. Use 'soft' or 'hard'.", + s + )); + } }) } } +crate::json::serde_deserialize_from_str!(FloatAbi); + impl ToJson for FloatAbi { fn to_json(&self) -> Json { match *self { @@ -1138,17 +1237,24 @@ pub enum RustcAbi { } impl FromStr for RustcAbi { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { Ok(match s { "x86-sse2" => RustcAbi::X86Sse2, "x86-softfloat" => RustcAbi::X86Softfloat, - _ => return Err(()), + _ => { + return Err(format!( + "'{s}' is not a valid value for rustc-abi. \ + Use 'x86-softfloat' or leave the field unset." + )); + } }) } } +crate::json::serde_deserialize_from_str!(RustcAbi); + impl ToJson for RustcAbi { fn to_json(&self) -> Json { match *self { @@ -1169,9 +1275,9 @@ pub enum TlsModel { } impl FromStr for TlsModel { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { Ok(match s { // Note the difference "general" vs "global" difference. The model name is "general", // but the user-facing option name is "global" for consistency with other compilers. @@ -1180,11 +1286,19 @@ impl FromStr for TlsModel { "initial-exec" => TlsModel::InitialExec, "local-exec" => TlsModel::LocalExec, "emulated" => TlsModel::Emulated, - _ => return Err(()), + _ => { + return Err(format!( + "'{s}' is not a valid TLS model. \ + Run `rustc --print tls-models` to \ + see the list of supported values." + )); + } }) } } +crate::json::serde_deserialize_from_str!(TlsModel); + impl ToJson for TlsModel { fn to_json(&self) -> Json { match *self { @@ -1230,19 +1344,6 @@ impl LinkOutputKind { } } - pub(super) fn from_str(s: &str) -> Option { - Some(match s { - "dynamic-nopic-exe" => LinkOutputKind::DynamicNoPicExe, - "dynamic-pic-exe" => LinkOutputKind::DynamicPicExe, - "static-nopic-exe" => LinkOutputKind::StaticNoPicExe, - "static-pic-exe" => LinkOutputKind::StaticPicExe, - "dynamic-dylib" => LinkOutputKind::DynamicDylib, - "static-dylib" => LinkOutputKind::StaticDylib, - "wasi-reactor-exe" => LinkOutputKind::WasiReactorExe, - _ => return None, - }) - } - pub fn can_link_dylib(self) -> bool { match self { LinkOutputKind::StaticNoPicExe | LinkOutputKind::StaticPicExe => false, @@ -1255,6 +1356,31 @@ impl LinkOutputKind { } } +impl FromStr for LinkOutputKind { + type Err = String; + + fn from_str(s: &str) -> Result { + Ok(match s { + "dynamic-nopic-exe" => LinkOutputKind::DynamicNoPicExe, + "dynamic-pic-exe" => LinkOutputKind::DynamicPicExe, + "static-nopic-exe" => LinkOutputKind::StaticNoPicExe, + "static-pic-exe" => LinkOutputKind::StaticPicExe, + "dynamic-dylib" => LinkOutputKind::DynamicDylib, + "static-dylib" => LinkOutputKind::StaticDylib, + "wasi-reactor-exe" => LinkOutputKind::WasiReactorExe, + _ => { + return Err(format!( + "invalid value for CRT object kind. \ + Use '(dynamic,static)-(nopic,pic)-exe' or \ + '(dynamic,static)-dylib' or 'wasi-reactor-exe'" + )); + } + }) + } +} + +crate::json::serde_deserialize_from_str!(LinkOutputKind); + impl fmt::Display for LinkOutputKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.as_str()) @@ -1290,18 +1416,25 @@ impl DebuginfoKind { } impl FromStr for DebuginfoKind { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { Ok(match s { "dwarf" => DebuginfoKind::Dwarf, "dwarf-dsym" => DebuginfoKind::DwarfDsym, "pdb" => DebuginfoKind::Pdb, - _ => return Err(()), + _ => { + return Err(format!( + "'{s}' is not a valid value for debuginfo-kind. Use 'dwarf', \ + 'dwarf-dsym' or 'pdb'." + )); + } }) } } +crate::json::serde_deserialize_from_str!(DebuginfoKind); + impl ToJson for DebuginfoKind { fn to_json(&self) -> Json { self.as_str().to_json() @@ -1354,18 +1487,25 @@ impl SplitDebuginfo { } impl FromStr for SplitDebuginfo { - type Err = (); + type Err = String; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { Ok(match s { "off" => SplitDebuginfo::Off, "unpacked" => SplitDebuginfo::Unpacked, "packed" => SplitDebuginfo::Packed, - _ => return Err(()), + _ => { + return Err(format!( + "'{s}' is not a valid value for \ + split-debuginfo. Use 'off', 'unpacked', or 'packed'.", + )); + } }) } } +crate::json::serde_deserialize_from_str!(SplitDebuginfo); + impl ToJson for SplitDebuginfo { fn to_json(&self) -> Json { self.as_str().to_json() @@ -1378,7 +1518,9 @@ impl fmt::Display for SplitDebuginfo { } } -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, serde_derive::Deserialize)] +#[serde(tag = "kind")] +#[serde(rename_all = "kebab-case")] pub enum StackProbeType { /// Don't emit any stack probes. None, @@ -1390,44 +1532,10 @@ pub enum StackProbeType { Call, /// Use inline option for LLVM versions later than specified in `min_llvm_version_for_inline` /// and call `__rust_probestack` otherwise. - InlineOrCall { min_llvm_version_for_inline: (u32, u32, u32) }, -} - -impl StackProbeType { - fn from_json(json: &Json) -> Result { - let object = json.as_object().ok_or_else(|| "expected a JSON object")?; - let kind = object - .get("kind") - .and_then(|o| o.as_str()) - .ok_or_else(|| "expected `kind` to be a string")?; - match kind { - "none" => Ok(StackProbeType::None), - "inline" => Ok(StackProbeType::Inline), - "call" => Ok(StackProbeType::Call), - "inline-or-call" => { - let min_version = object - .get("min-llvm-version-for-inline") - .and_then(|o| o.as_array()) - .ok_or_else(|| "expected `min-llvm-version-for-inline` to be an array")?; - let mut iter = min_version.into_iter().map(|v| { - let int = v.as_u64().ok_or_else( - || "expected `min-llvm-version-for-inline` values to be integers", - )?; - u32::try_from(int) - .map_err(|_| "`min-llvm-version-for-inline` values don't convert to u32") - }); - let min_llvm_version_for_inline = ( - iter.next().unwrap_or(Ok(11))?, - iter.next().unwrap_or(Ok(0))?, - iter.next().unwrap_or(Ok(0))?, - ); - Ok(StackProbeType::InlineOrCall { min_llvm_version_for_inline }) - } - _ => Err(String::from( - "`kind` expected to be one of `none`, `inline`, `call` or `inline-or-call`", - )), - } - } + InlineOrCall { + #[serde(rename = "min-llvm-version-for-inline")] + min_llvm_version_for_inline: (u32, u32, u32), + }, } impl ToJson for StackProbeType { @@ -1549,6 +1657,29 @@ impl fmt::Display for SanitizerSet { } } +impl FromStr for SanitizerSet { + type Err = String; + fn from_str(s: &str) -> Result { + Ok(match s { + "address" => SanitizerSet::ADDRESS, + "cfi" => SanitizerSet::CFI, + "dataflow" => SanitizerSet::DATAFLOW, + "kcfi" => SanitizerSet::KCFI, + "kernel-address" => SanitizerSet::KERNELADDRESS, + "leak" => SanitizerSet::LEAK, + "memory" => SanitizerSet::MEMORY, + "memtag" => SanitizerSet::MEMTAG, + "safestack" => SanitizerSet::SAFESTACK, + "shadow-call-stack" => SanitizerSet::SHADOWCALLSTACK, + "thread" => SanitizerSet::THREAD, + "hwaddress" => SanitizerSet::HWADDRESS, + s => return Err(format!("unknown sanitizer {s}")), + }) + } +} + +crate::json::serde_deserialize_from_str!(SanitizerSet); + impl ToJson for SanitizerSet { fn to_json(&self) -> Json { self.into_iter() @@ -1587,17 +1718,19 @@ impl FramePointer { } impl FromStr for FramePointer { - type Err = (); - fn from_str(s: &str) -> Result { + type Err = String; + fn from_str(s: &str) -> Result { Ok(match s { "always" => Self::Always, "non-leaf" => Self::NonLeaf, "may-omit" => Self::MayOmit, - _ => return Err(()), + _ => return Err(format!("'{s}' is not a valid value for frame-pointer")), }) } } +crate::json::serde_deserialize_from_str!(FramePointer); + impl ToJson for FramePointer { fn to_json(&self) -> Json { match *self { @@ -1685,7 +1818,7 @@ impl BinaryFormat { } impl FromStr for BinaryFormat { - type Err = (); + type Err = String; fn from_str(s: &str) -> Result { match s { "coff" => Ok(Self::Coff), @@ -1693,11 +1826,16 @@ impl FromStr for BinaryFormat { "mach-o" => Ok(Self::MachO), "wasm" => Ok(Self::Wasm), "xcoff" => Ok(Self::Xcoff), - _ => Err(()), + _ => Err(format!( + "'{s}' is not a valid value for binary_format. \ + Use 'coff', 'elf', 'mach-o', 'wasm' or 'xcoff' " + )), } } } +crate::json::serde_deserialize_from_str!(BinaryFormat); + impl ToJson for BinaryFormat { fn to_json(&self) -> Json { match self { @@ -2130,12 +2268,11 @@ pub(crate) use cvs; #[derive(Debug, PartialEq)] pub struct TargetWarnings { unused_fields: Vec, - incorrect_type: Vec, } impl TargetWarnings { pub fn empty() -> Self { - Self { unused_fields: Vec::new(), incorrect_type: Vec::new() } + Self { unused_fields: Vec::new() } } pub fn warning_messages(&self) -> Vec { @@ -2146,12 +2283,6 @@ impl TargetWarnings { self.unused_fields.join(", ") )); } - if !self.incorrect_type.is_empty() { - warnings.push(format!( - "target json file contains fields whose value doesn't have the correct json type: {}", - self.incorrect_type.join(", ") - )); - } warnings } } @@ -3325,7 +3456,8 @@ impl Target { /// Test target self-consistency and JSON encoding/decoding roundtrip. #[cfg(test)] fn test_target(mut self) { - let recycled_target = Target::from_json(self.to_json()).map(|(j, _)| j); + let recycled_target = + Target::from_json(&serde_json::to_string(&self.to_json()).unwrap()).map(|(j, _)| j); self.update_to_cli(); self.check_consistency(TargetKind::Builtin).unwrap(); assert_eq!(recycled_target, Ok(self)); @@ -3373,8 +3505,7 @@ impl Target { fn load_file(path: &Path) -> Result<(Target, TargetWarnings), String> { let contents = fs::read_to_string(path).map_err(|e| e.to_string())?; - let obj = serde_json::from_str(&contents).map_err(|e| e.to_string())?; - Target::from_json(obj) + Target::from_json(&contents) } match *target_tuple { @@ -3422,10 +3553,7 @@ impl Target { Err(format!("could not find specification for target {target_tuple:?}")) } } - TargetTuple::TargetJson { ref contents, .. } => { - let obj = serde_json::from_str(contents).map_err(|e| e.to_string())?; - Target::from_json(obj) - } + TargetTuple::TargetJson { ref contents, .. } => Target::from_json(contents), } } diff --git a/compiler/rustc_target/src/tests.rs b/compiler/rustc_target/src/tests.rs index 76375170db63d..ee847a84007f0 100644 --- a/compiler/rustc_target/src/tests.rs +++ b/compiler/rustc_target/src/tests.rs @@ -2,8 +2,7 @@ use crate::spec::Target; #[test] fn report_unused_fields() { - let json = serde_json::from_str( - r#" + let json = r#" { "arch": "powerpc64", "data-layout": "e-m:e-i64:64-n32:64", @@ -11,47 +10,8 @@ fn report_unused_fields() { "target-pointer-width": "64", "code-mode": "foo" } - "#, - ) - .unwrap(); - let warnings = Target::from_json(json).unwrap().1; - assert_eq!(warnings.warning_messages().len(), 1); - assert!(warnings.warning_messages().join("\n").contains("code-mode")); -} - -#[test] -fn report_incorrect_json_type() { - let json = serde_json::from_str( - r#" - { - "arch": "powerpc64", - "data-layout": "e-m:e-i64:64-n32:64", - "llvm-target": "powerpc64le-elf", - "target-pointer-width": "64", - "link-env-remove": "foo" - } - "#, - ) - .unwrap(); - let warnings = Target::from_json(json).unwrap().1; - assert_eq!(warnings.warning_messages().len(), 1); - assert!(warnings.warning_messages().join("\n").contains("link-env-remove")); -} - -#[test] -fn no_warnings_for_valid_target() { - let json = serde_json::from_str( - r#" - { - "arch": "powerpc64", - "data-layout": "e-m:e-i64:64-n32:64", - "llvm-target": "powerpc64le-elf", - "target-pointer-width": "64", - "link-env-remove": ["foo"] - } - "#, - ) - .unwrap(); - let warnings = Target::from_json(json).unwrap().1; - assert_eq!(warnings.warning_messages().len(), 0); + "#; + let result = Target::from_json(json); + eprintln!("{result:#?}"); + assert!(result.is_err()); } diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 38ba6b4503dc1..a32c2f7fb18c5 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -444,7 +444,7 @@ fn add_exe_suffix(input: String, target: &TargetTuple) -> String { let exe_suffix = match target { TargetTuple::TargetTuple(_) => Target::expect_builtin(target).options.exe_suffix, TargetTuple::TargetJson { contents, .. } => { - Target::from_json(contents.parse().unwrap()).unwrap().0.options.exe_suffix + Target::from_json(contents).unwrap().0.options.exe_suffix } }; input + &exe_suffix diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index f43f5eae9a560..d17ae162ab235 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -378,6 +378,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "serde", "serde_derive", "serde_json", + "serde_path_to_error", "sha1", "sha2", "sharded-slab", diff --git a/tests/run-make/rustdoc-target-spec-json-path/target.json b/tests/run-make/rustdoc-target-spec-json-path/target.json index c478f1196fae0..d7e4cac57ae75 100644 --- a/tests/run-make/rustdoc-target-spec-json-path/target.json +++ b/tests/run-make/rustdoc-target-spec-json-path/target.json @@ -6,7 +6,6 @@ "dynamic-linking": true, "env": "gnu", "executables": true, - "has-elf-tls": true, "has-rpath": true, "linker-is-gnu": true, "llvm-target": "x86_64-unknown-linux-gnu", diff --git a/tests/run-make/target-specs/endianness-mismatch.json b/tests/run-make/target-specs/endianness-mismatch.json index 431053ea99b60..cc03becc59af6 100644 --- a/tests/run-make/target-specs/endianness-mismatch.json +++ b/tests/run-make/target-specs/endianness-mismatch.json @@ -5,7 +5,6 @@ "llvm-target": "x86_64-unknown-linux-gnu", "target-endian": "big", "target-pointer-width": "64", - "target-c-int-width": "32", "arch": "x86_64", "os": "linux" } diff --git a/tests/run-make/target-specs/my-awesome-platform.json b/tests/run-make/target-specs/my-awesome-platform.json index 1673ef7bd54d1..d41038b84a865 100644 --- a/tests/run-make/target-specs/my-awesome-platform.json +++ b/tests/run-make/target-specs/my-awesome-platform.json @@ -4,8 +4,6 @@ "llvm-target": "i686-unknown-linux-gnu", "target-endian": "little", "target-pointer-width": "32", - "target-c-int-width": "32", "arch": "x86", - "os": "linux", - "morestack": false + "os": "linux" } diff --git a/tests/run-make/target-specs/my-incomplete-platform.json b/tests/run-make/target-specs/my-incomplete-platform.json index ceaa25cdf2fef..8bdc4108f494a 100644 --- a/tests/run-make/target-specs/my-incomplete-platform.json +++ b/tests/run-make/target-specs/my-incomplete-platform.json @@ -3,8 +3,6 @@ "linker-flavor": "gcc", "target-endian": "little", "target-pointer-width": "32", - "target-c-int-width": "32", "arch": "x86", - "os": "foo", - "morestack": false + "os": "foo" } diff --git a/tests/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json b/tests/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json index 0cafce15a9fef..27833f1abdd9e 100644 --- a/tests/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json +++ b/tests/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json @@ -5,8 +5,6 @@ "llvm-target": "x86_64-unknown-linux-gnu", "target-endian": "little", "target-pointer-width": "64", - "target-c-int-width": "32", "arch": "x86_64", - "os": "linux", - "morestack": false + "os": "linux" } diff --git a/tests/run-make/target-specs/require-explicit-cpu.json b/tests/run-make/target-specs/require-explicit-cpu.json index 5cbb9573b3f12..9744bca168e2d 100644 --- a/tests/run-make/target-specs/require-explicit-cpu.json +++ b/tests/run-make/target-specs/require-explicit-cpu.json @@ -4,7 +4,6 @@ "llvm-target": "i686-unknown-linux-gnu", "target-endian": "little", "target-pointer-width": "32", - "target-c-int-width": "32", "arch": "x86", "os": "linux", "need-explicit-cpu": true diff --git a/tests/run-make/target-specs/rmake.rs b/tests/run-make/target-specs/rmake.rs index 9184e5f772f78..7e565588ed6bc 100644 --- a/tests/run-make/target-specs/rmake.rs +++ b/tests/run-make/target-specs/rmake.rs @@ -8,8 +8,6 @@ use run_make_support::{diff, rfs, rustc}; fn main() { - rustc().input("foo.rs").target("my-awesome-platform.json").crate_type("lib").emit("asm").run(); - assert!(!rfs::read_to_string("foo.s").contains("morestack")); rustc() .input("foo.rs") .target("my-invalid-platform.json") @@ -19,7 +17,7 @@ fn main() { .input("foo.rs") .target("my-incomplete-platform.json") .run_fail() - .assert_stderr_contains("Field llvm-target"); + .assert_stderr_contains("missing field `llvm-target`"); rustc() .env("RUST_TARGET_PATH", ".") .input("foo.rs") diff --git a/tests/ui/check-cfg/my-awesome-platform.json b/tests/ui/check-cfg/my-awesome-platform.json index 03b08b727bd3a..4c16d06c7b7d6 100644 --- a/tests/ui/check-cfg/my-awesome-platform.json +++ b/tests/ui/check-cfg/my-awesome-platform.json @@ -4,7 +4,6 @@ "arch": "x86_64", "target-endian": "little", "target-pointer-width": "64", - "target-c-int-width": "32", "os": "ericos", "linker-flavor": "ld.lld", "linker": "rust-lld", diff --git a/tests/ui/codegen/mismatched-data-layout.json b/tests/ui/codegen/mismatched-data-layout.json index 7adc883252474..f8c510c186362 100644 --- a/tests/ui/codegen/mismatched-data-layout.json +++ b/tests/ui/codegen/mismatched-data-layout.json @@ -4,7 +4,6 @@ "arch": "x86_64", "target-endian": "little", "target-pointer-width": "64", - "target-c-int-width": "32", "os": "none", "linker-flavor": "ld.lld", "linker": "rust-lld", diff --git a/tests/ui/codegen/mismatched-data-layouts.rs b/tests/ui/codegen/mismatched-data-layouts.rs index 6428b8c5247b7..ea1457148a52c 100644 --- a/tests/ui/codegen/mismatched-data-layouts.rs +++ b/tests/ui/codegen/mismatched-data-layouts.rs @@ -5,6 +5,7 @@ //@ compile-flags: --crate-type=lib --target={{src-base}}/codegen/mismatched-data-layout.json -Z unstable-options //@ normalize-stderr: "`, `[A-Za-z0-9-:]*`" -> "`, `normalized data layout`" //@ normalize-stderr: "layout, `[A-Za-z0-9-:]*`" -> "layout, `normalized data layout`" +//@ normalize-stderr: "`mismatched-data-layout-\d+`" -> "`mismatched-data-layout-`" #![feature(lang_items, no_core, auto_traits)] #![no_core] diff --git a/tests/ui/codegen/mismatched-data-layouts.stderr b/tests/ui/codegen/mismatched-data-layouts.stderr index b7d5d82bee08c..d1117564d5b73 100644 --- a/tests/ui/codegen/mismatched-data-layouts.stderr +++ b/tests/ui/codegen/mismatched-data-layouts.stderr @@ -1,4 +1,4 @@ -error: data-layout for target `mismatched-data-layout-7193370089426056427`, `normalized data layout`, differs from LLVM target's `x86_64-unknown-none-gnu` default layout, `normalized data layout` +error: data-layout for target `mismatched-data-layout-`, `normalized data layout`, differs from LLVM target's `x86_64-unknown-none-gnu` default layout, `normalized data layout` error: aborting due to 1 previous error From e5a506251d912d0cfddf2e2e6597234c6929dd10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 21 Jul 2025 20:28:00 +0200 Subject: [PATCH 10/28] add an error message if you attempt to pass indirect args via guaranteed tail calls. --- compiler/rustc_codegen_ssa/src/mir/block.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 42ff6fff90001..3aa6bb0bd59c6 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -1045,6 +1045,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // to generate `lifetime_end` when the call returns. let mut lifetime_ends_after_call: Vec<(Bx::Value, Size)> = Vec::new(); 'make_args: for (i, arg) in first_args.iter().enumerate() { + if tail && matches!(fn_abi.args[i].mode, PassMode::Indirect { .. }) { + bug!( + r"Arguments using PassMode::Indirect are currently not supported for tail calls. + See https://github.com/rust-lang/rust/pull/144232#discussion_r2218543841 for more information." + ); + } + let mut op = self.codegen_operand(bx, &arg.node); if let (0, Some(ty::InstanceKind::Virtual(_, idx))) = (i, instance.map(|i| i.def)) { From ecf34e1d648dc0f70b92e99e869ec02631139f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 21 Jul 2025 20:30:27 +0200 Subject: [PATCH 11/28] use span_bug instead of bug --- compiler/rustc_codegen_ssa/src/mir/block.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 3aa6bb0bd59c6..91b3d2a1a26fa 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -1046,9 +1046,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let mut lifetime_ends_after_call: Vec<(Bx::Value, Size)> = Vec::new(); 'make_args: for (i, arg) in first_args.iter().enumerate() { if tail && matches!(fn_abi.args[i].mode, PassMode::Indirect { .. }) { - bug!( - r"Arguments using PassMode::Indirect are currently not supported for tail calls. - See https://github.com/rust-lang/rust/pull/144232#discussion_r2218543841 for more information." + span_bug!( + fn_span, + "arguments using PassMode::Indirect are currently not supported for tail calls" ); } From c4eb07761643d2fa26d6f609eb23c8d22e14d8eb Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Thu, 17 Jul 2025 18:41:52 -0400 Subject: [PATCH 12/28] Ensure we codegen and don't internalize the entrypoint --- compiler/rustc_middle/src/mir/mono.rs | 6 ++---- compiler/rustc_middle/src/ty/context.rs | 14 ++++++++++++++ compiler/rustc_monomorphize/src/collector.rs | 9 +++++++++ compiler/rustc_monomorphize/src/partitioning.rs | 15 +++++---------- tests/ui/entry-point/auxiliary/main_functions.rs | 3 +++ .../ui/entry-point/imported_main_local_codegen.rs | 11 +++++++++++ 6 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 tests/ui/entry-point/imported_main_local_codegen.rs diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index 47ba850d50dd4..c2927361d05c4 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -143,10 +143,8 @@ impl<'tcx> MonoItem<'tcx> { }; // Similarly, the executable entrypoint must be instantiated exactly once. - if let Some((entry_def_id, _)) = tcx.entry_fn(()) { - if instance.def_id() == entry_def_id { - return InstantiationMode::GloballyShared { may_conflict: false }; - } + if tcx.is_entrypoint(instance.def_id()) { + return InstantiationMode::GloballyShared { may_conflict: false }; } // If the function is #[naked] or contains any other attribute that requires exactly-once diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 915b062417f2f..26da2abe126cd 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -3402,6 +3402,20 @@ impl<'tcx> TyCtxt<'tcx> { pub fn do_not_recommend_impl(self, def_id: DefId) -> bool { self.get_diagnostic_attr(def_id, sym::do_not_recommend).is_some() } + + /// Whether this def is one of the special bin crate entrypoint functions that must have a + /// monomorphization and also not be internalized in the bin crate. + pub fn is_entrypoint(self, def_id: DefId) -> bool { + if self.is_lang_item(def_id, LangItem::Start) { + return true; + } + if let Some((entry_def_id, _)) = self.entry_fn(()) + && entry_def_id == def_id + { + return true; + } + false + } } /// Parameter attributes that can only be determined by examining the body of a function instead diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 91c8e64ce9afe..5071f9f892216 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1582,6 +1582,15 @@ impl<'v> RootCollector<'_, 'v> { return; }; + let main_instance = Instance::mono(self.tcx, main_def_id); + if self.tcx.should_codegen_locally(main_instance) { + self.output.push(create_fn_mono_item( + self.tcx, + main_instance, + self.tcx.def_span(main_def_id), + )); + } + let Some(start_def_id) = self.tcx.lang_items().start_fn() else { self.tcx.dcx().emit_fatal(errors::StartNotFound); }; diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 69851511fb1f4..ca8228de57e89 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -223,11 +223,7 @@ where // So even if its mode is LocalCopy, we need to treat it like a root. match mono_item.instantiation_mode(cx.tcx) { InstantiationMode::GloballyShared { .. } => {} - InstantiationMode::LocalCopy => { - if !cx.tcx.is_lang_item(mono_item.def_id(), LangItem::Start) { - continue; - } - } + InstantiationMode::LocalCopy => continue, } let characteristic_def_id = characteristic_def_id_of_mono_item(cx.tcx, mono_item); @@ -821,10 +817,9 @@ fn mono_item_visibility<'tcx>( | InstanceKind::FnPtrAddrShim(..) => return Visibility::Hidden, }; - // The `start_fn` lang item is actually a monomorphized instance of a - // function in the standard library, used for the `main` function. We don't - // want to export it so we tag it with `Hidden` visibility but this symbol - // is only referenced from the actual `main` symbol which we unfortunately + // Both the `start_fn` lang item and `main` itself should not be exported, + // so we give them with `Hidden` visibility but these symbols are + // only referenced from the actual `main` symbol which we unfortunately // don't know anything about during partitioning/collection. As a result we // forcibly keep this symbol out of the `internalization_candidates` set. // @@ -834,7 +829,7 @@ fn mono_item_visibility<'tcx>( // from the `main` symbol we'll generate later. // // This may be fixable with a new `InstanceKind` perhaps? Unsure! - if tcx.is_lang_item(def_id, LangItem::Start) { + if tcx.is_entrypoint(def_id) { *can_be_internalized = false; return Visibility::Hidden; } diff --git a/tests/ui/entry-point/auxiliary/main_functions.rs b/tests/ui/entry-point/auxiliary/main_functions.rs index cc7992a42c187..ab4a09b633100 100644 --- a/tests/ui/entry-point/auxiliary/main_functions.rs +++ b/tests/ui/entry-point/auxiliary/main_functions.rs @@ -1 +1,4 @@ pub fn boilerplate() {} + +#[inline] +pub fn local_codegen() {} diff --git a/tests/ui/entry-point/imported_main_local_codegen.rs b/tests/ui/entry-point/imported_main_local_codegen.rs new file mode 100644 index 0000000000000..1e46c10937302 --- /dev/null +++ b/tests/ui/entry-point/imported_main_local_codegen.rs @@ -0,0 +1,11 @@ +//@ run-pass +//@ aux-build:main_functions.rs +//@ compile-flags: -Ccodegen-units=1024 + +// This is a regression test for https://github.com/rust-lang/rust/issues/144052. +// Entrypoint functions call each other in ways that CGU partitioning doesn't know about. So there +// is a special check to not internalize any of them. But internalizing them can be okay if there +// are few enough CGUs, so we use a lot of CGUs in this test to hit the bad case. + +extern crate main_functions; +pub use main_functions::local_codegen as main; From 6e8762f769c90f7a6ab0428db8ba55066eafd859 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 1 Oct 2023 15:09:35 +0000 Subject: [PATCH 13/28] Use less HIR in check_private_in_public. --- compiler/rustc_privacy/src/lib.rs | 122 +++++++----------- .../associated-item-privacy-trait.stderr | 22 ++-- .../ui/privacy/private-in-public-warn.stderr | 72 +++++------ 3 files changed, 92 insertions(+), 124 deletions(-) diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 80c13e44d7d8e..5021002e4cbc1 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -26,7 +26,7 @@ use rustc_errors::{MultiSpan, listify}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId, LocalModDefId}; use rustc_hir::intravisit::{self, InferKind, Visitor}; -use rustc_hir::{AmbigArg, ForeignItemKind, ItemId, ItemKind, PatKind}; +use rustc_hir::{AmbigArg, ForeignItemId, ItemId, PatKind}; use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility, Level}; use rustc_middle::query::Providers; use rustc_middle::ty::print::PrintTraitRefExt as _; @@ -599,18 +599,13 @@ impl<'tcx> EmbargoVisitor<'tcx> { DefKind::Struct | DefKind::Union => { // While structs and unions have type privacy, their fields do not. - let item = self.tcx.hir_expect_item(def_id); - if let hir::ItemKind::Struct(_, _, ref struct_def) - | hir::ItemKind::Union(_, _, ref struct_def) = item.kind - { - for field in struct_def.fields() { - let field_vis = self.tcx.local_visibility(field.def_id); - if field_vis.is_accessible_from(module, self.tcx) { - self.reach(field.def_id, macro_ev).ty(); - } + let struct_def = self.tcx.adt_def(def_id); + for field in struct_def.non_enum_variant().fields.iter() { + let def_id = field.did.expect_local(); + let field_vis = self.tcx.local_visibility(def_id); + if field_vis.is_accessible_from(module, self.tcx) { + self.reach(def_id, macro_ev).ty(); } - } else { - bug!("item {:?} with DefKind {:?}", item, def_kind); } } @@ -1640,66 +1635,29 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { self.check(def_id, item_visibility, effective_vis).generics().predicates(); } DefKind::Enum => { - let item = tcx.hir_item(id); - if let hir::ItemKind::Enum(_, _, ref def) = item.kind { - self.check_unnameable(item.owner_id.def_id, effective_vis); - - self.check(item.owner_id.def_id, item_visibility, effective_vis) - .generics() - .predicates(); - - for variant in def.variants { - for field in variant.data.fields() { - self.check(field.def_id, item_visibility, effective_vis).ty(); - } - } - } - } - // Subitems of foreign modules have their own publicity. - DefKind::ForeignMod => { - let item = tcx.hir_item(id); - if let hir::ItemKind::ForeignMod { items, .. } = item.kind { - for &foreign_item in items { - let foreign_item = tcx.hir_foreign_item(foreign_item); - - let ev = self.get(foreign_item.owner_id.def_id); - let vis = tcx.local_visibility(foreign_item.owner_id.def_id); - - if let ForeignItemKind::Type = foreign_item.kind { - self.check_unnameable(foreign_item.owner_id.def_id, ev); - } + self.check_unnameable(def_id, effective_vis); + self.check(def_id, item_visibility, effective_vis).generics().predicates(); - self.check(foreign_item.owner_id.def_id, vis, ev) - .generics() - .predicates() - .ty(); - } + let adt = tcx.adt_def(id.owner_id); + for field in adt.all_fields() { + self.check(field.did.expect_local(), item_visibility, effective_vis).ty(); } } // Subitems of structs and unions have their own publicity. DefKind::Struct | DefKind::Union => { - let item = tcx.hir_item(id); - if let hir::ItemKind::Struct(_, _, ref struct_def) - | hir::ItemKind::Union(_, _, ref struct_def) = item.kind - { - self.check_unnameable(item.owner_id.def_id, effective_vis); - self.check(item.owner_id.def_id, item_visibility, effective_vis) - .generics() - .predicates(); + self.check_unnameable(def_id, effective_vis); + self.check(def_id, item_visibility, effective_vis).generics().predicates(); - for field in struct_def.fields() { - let field_visibility = tcx.local_visibility(field.def_id); - let field_ev = self.get(field.def_id); + let adt = tcx.adt_def(id.owner_id); + for field in adt.all_fields() { + let visibility = min(item_visibility, field.vis.expect_local(), tcx); + let field_ev = self.get(field.did.expect_local()); - self.check( - field.def_id, - min(item_visibility, field_visibility, tcx), - field_ev, - ) - .ty(); - } + self.check(field.did.expect_local(), visibility, field_ev).ty(); } } + // Subitems of foreign modules have their own publicity. + DefKind::ForeignMod => {} // An inherent impl is public when its type is public // Subitems of inherent impls have their own publicity. // A trait impl is public when both its type and its trait are public @@ -1755,6 +1713,19 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { _ => {} } } + + fn check_foreign_item(&mut self, id: ForeignItemId) { + let tcx = self.tcx; + let def_id = id.owner_id.def_id; + let item_visibility = tcx.local_visibility(def_id); + let effective_vis = self.get(def_id); + + if let DefKind::ForeignTy = self.tcx.def_kind(def_id) { + self.check_unnameable(def_id, effective_vis); + } + + self.check(def_id, item_visibility, effective_vis).generics().predicates().ty(); + } } pub fn provide(providers: &mut Providers) { @@ -1783,20 +1754,13 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) { if let Some(body_id) = tcx.hir_maybe_body_owned_by(def_id) { visitor.visit_nested_body(body_id.id()); } - } - for id in module.free_items() { - if let ItemKind::Impl(i) = tcx.hir_item(id).kind { - if let Some(item) = i.of_trait { - let trait_ref = tcx.impl_trait_ref(id.owner_id.def_id).unwrap(); - let trait_ref = trait_ref.instantiate_identity(); - visitor.span = item.path.span; - let _ = visitor.visit_def_id( - trait_ref.def_id, - "trait", - &trait_ref.print_only_trait_path(), - ); - } + if let DefKind::Impl { of_trait: true } = tcx.def_kind(def_id) { + let trait_ref = tcx.impl_trait_ref(def_id).unwrap(); + let trait_ref = trait_ref.instantiate_identity(); + visitor.span = tcx.hir_expect_item(def_id).expect_impl().of_trait.unwrap().path.span; + let _ = + visitor.visit_def_id(trait_ref.def_id, "trait", &trait_ref.print_only_trait_path()); } } } @@ -1887,7 +1851,11 @@ fn check_private_in_public(tcx: TyCtxt<'_>, (): ()) { // Check for private types in public interfaces. let mut checker = PrivateItemsInPublicInterfacesChecker { tcx, effective_visibilities }; - for id in tcx.hir_free_items() { + let crate_items = tcx.hir_crate_items(()); + for id in crate_items.free_items() { checker.check_item(id); } + for id in crate_items.foreign_items() { + checker.check_foreign_item(id); + } } diff --git a/tests/ui/privacy/associated-item-privacy-trait.stderr b/tests/ui/privacy/associated-item-privacy-trait.stderr index f79c4cff72fa2..4e9dfa4a83519 100644 --- a/tests/ui/privacy/associated-item-privacy-trait.stderr +++ b/tests/ui/privacy/associated-item-privacy-trait.stderr @@ -75,6 +75,17 @@ LL | priv_trait::mac!(); | = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) +error: trait `PrivTr` is private + --> $DIR/associated-item-privacy-trait.rs:29:14 + | +LL | impl PrivTr for u8 {} + | ^^^^^^ private trait +... +LL | priv_trait::mac!(); + | ------------------ in this macro invocation + | + = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) + error: type `priv_signature::Priv` is private --> $DIR/associated-item-privacy-trait.rs:46:21 | @@ -317,16 +328,5 @@ LL | priv_parent_substs::mac!(); | = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: trait `PrivTr` is private - --> $DIR/associated-item-privacy-trait.rs:29:14 - | -LL | impl PrivTr for u8 {} - | ^^^^^^ private trait -... -LL | priv_trait::mac!(); - | ------------------ in this macro invocation - | - = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) - error: aborting due to 30 previous errors diff --git a/tests/ui/privacy/private-in-public-warn.stderr b/tests/ui/privacy/private-in-public-warn.stderr index 3743879ffa616..0343002ea3181 100644 --- a/tests/ui/privacy/private-in-public-warn.stderr +++ b/tests/ui/privacy/private-in-public-warn.stderr @@ -84,42 +84,6 @@ note: but type `types::Priv` is only usable at visibility `pub(self)` LL | struct Priv; | ^^^^^^^^^^^ -error: type `types::Priv` is more private than the item `types::ES` - --> $DIR/private-in-public-warn.rs:27:9 - | -LL | pub static ES: Priv; - | ^^^^^^^^^^^^^^^^^^^ static `types::ES` is reachable at visibility `pub(crate)` - | -note: but type `types::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:9:5 - | -LL | struct Priv; - | ^^^^^^^^^^^ - -error: type `types::Priv` is more private than the item `types::ef1` - --> $DIR/private-in-public-warn.rs:28:9 - | -LL | pub fn ef1(arg: Priv); - | ^^^^^^^^^^^^^^^^^^^^^^ function `types::ef1` is reachable at visibility `pub(crate)` - | -note: but type `types::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:9:5 - | -LL | struct Priv; - | ^^^^^^^^^^^ - -error: type `types::Priv` is more private than the item `types::ef2` - --> $DIR/private-in-public-warn.rs:29:9 - | -LL | pub fn ef2() -> Priv; - | ^^^^^^^^^^^^^^^^^^^^^ function `types::ef2` is reachable at visibility `pub(crate)` - | -note: but type `types::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:9:5 - | -LL | struct Priv; - | ^^^^^^^^^^^ - error[E0446]: private type `types::Priv` in public interface --> $DIR/private-in-public-warn.rs:32:9 | @@ -395,6 +359,42 @@ note: but type `Priv2` is only usable at visibility `pub(self)` LL | struct Priv2; | ^^^^^^^^^^^^ +error: type `types::Priv` is more private than the item `types::ES` + --> $DIR/private-in-public-warn.rs:27:9 + | +LL | pub static ES: Priv; + | ^^^^^^^^^^^^^^^^^^^ static `types::ES` is reachable at visibility `pub(crate)` + | +note: but type `types::Priv` is only usable at visibility `pub(self)` + --> $DIR/private-in-public-warn.rs:9:5 + | +LL | struct Priv; + | ^^^^^^^^^^^ + +error: type `types::Priv` is more private than the item `types::ef1` + --> $DIR/private-in-public-warn.rs:28:9 + | +LL | pub fn ef1(arg: Priv); + | ^^^^^^^^^^^^^^^^^^^^^^ function `types::ef1` is reachable at visibility `pub(crate)` + | +note: but type `types::Priv` is only usable at visibility `pub(self)` + --> $DIR/private-in-public-warn.rs:9:5 + | +LL | struct Priv; + | ^^^^^^^^^^^ + +error: type `types::Priv` is more private than the item `types::ef2` + --> $DIR/private-in-public-warn.rs:29:9 + | +LL | pub fn ef2() -> Priv; + | ^^^^^^^^^^^^^^^^^^^^^ function `types::ef2` is reachable at visibility `pub(crate)` + | +note: but type `types::Priv` is only usable at visibility `pub(self)` + --> $DIR/private-in-public-warn.rs:9:5 + | +LL | struct Priv; + | ^^^^^^^^^^^ + warning: bounds on generic parameters in type aliases are not enforced --> $DIR/private-in-public-warn.rs:41:23 | From 0aa617001aa5a0d6945079dd084c0bd4a13f3189 Mon Sep 17 00:00:00 2001 From: yuk1ty Date: Mon, 21 Jul 2025 14:51:55 +0900 Subject: [PATCH 14/28] Add a test case for ui test false-sealed-traits-note.rs --- .../sealed-traits/false-sealed-traits-note.rs | 12 ++++++++- .../false-sealed-traits-note.stderr | 25 ++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/tests/ui/privacy/sealed-traits/false-sealed-traits-note.rs b/tests/ui/privacy/sealed-traits/false-sealed-traits-note.rs index 13f3065e442e5..d5065a6b55b2f 100644 --- a/tests/ui/privacy/sealed-traits/false-sealed-traits-note.rs +++ b/tests/ui/privacy/sealed-traits/false-sealed-traits-note.rs @@ -1,5 +1,6 @@ -// We should not emit sealed traits note, see issue #143392 +// We should not emit sealed traits note, see issue #143392 and #143121 +/// Reported in #143392 mod inner { pub trait TraitA {} @@ -10,4 +11,13 @@ struct Struct; impl inner::TraitB for Struct {} //~ ERROR the trait bound `Struct: TraitA` is not satisfied [E0277] +/// Reported in #143121 +mod x { + pub trait A {} + pub trait B: A {} + + pub struct C; + impl B for C {} //~ ERROR the trait bound `C: A` is not satisfied [E0277] +} + fn main(){} diff --git a/tests/ui/privacy/sealed-traits/false-sealed-traits-note.stderr b/tests/ui/privacy/sealed-traits/false-sealed-traits-note.stderr index f80d985ad6e63..df8016565da47 100644 --- a/tests/ui/privacy/sealed-traits/false-sealed-traits-note.stderr +++ b/tests/ui/privacy/sealed-traits/false-sealed-traits-note.stderr @@ -1,20 +1,37 @@ error[E0277]: the trait bound `Struct: TraitA` is not satisfied - --> $DIR/false-sealed-traits-note.rs:11:24 + --> $DIR/false-sealed-traits-note.rs:12:24 | LL | impl inner::TraitB for Struct {} | ^^^^^^ the trait `TraitA` is not implemented for `Struct` | help: this trait has no implementations, consider adding one - --> $DIR/false-sealed-traits-note.rs:4:5 + --> $DIR/false-sealed-traits-note.rs:5:5 | LL | pub trait TraitA {} | ^^^^^^^^^^^^^^^^ note: required by a bound in `TraitB` - --> $DIR/false-sealed-traits-note.rs:6:23 + --> $DIR/false-sealed-traits-note.rs:7:23 | LL | pub trait TraitB: TraitA {} | ^^^^^^ required by this bound in `TraitB` -error: aborting due to 1 previous error +error[E0277]: the trait bound `C: A` is not satisfied + --> $DIR/false-sealed-traits-note.rs:20:16 + | +LL | impl B for C {} + | ^ the trait `A` is not implemented for `C` + | +help: this trait has no implementations, consider adding one + --> $DIR/false-sealed-traits-note.rs:16:5 + | +LL | pub trait A {} + | ^^^^^^^^^^^ +note: required by a bound in `B` + --> $DIR/false-sealed-traits-note.rs:17:18 + | +LL | pub trait B: A {} + | ^ required by this bound in `B` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. From 9e75032a9dc06d8286aebcb4ed00ad5d81bbf0e9 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 22 Jul 2025 13:38:08 -0500 Subject: [PATCH 15/28] rustdoc: avoid allocating a temp String for aliases in search index --- src/librustdoc/html/render/search_index.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 3c9be29ccc359..e2f86b8a8549e 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -100,9 +100,22 @@ pub(crate) fn build_index( let crate_doc = short_markdown_summary(&krate.module.doc_value(), &krate.module.link_names(cache)); + #[derive(Eq, Ord, PartialEq, PartialOrd)] + struct SerSymbolAsStr(Symbol); + + impl Serialize for SerSymbolAsStr { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + self.0.as_str().serialize(serializer) + } + } + + type AliasMap = BTreeMap>; // Aliases added through `#[doc(alias = "...")]`. Since a few items can have the same alias, // we need the alias element to have an array of items. - let mut aliases: BTreeMap> = BTreeMap::new(); + let mut aliases: AliasMap = BTreeMap::new(); // Sort search index items. This improves the compressibility of the search index. cache.search_index.sort_unstable_by(|k1, k2| { @@ -116,7 +129,7 @@ pub(crate) fn build_index( // Set up alias indexes. for (i, item) in cache.search_index.iter().enumerate() { for alias in &item.aliases[..] { - aliases.entry(alias.to_string()).or_default().push(i); + aliases.entry(SerSymbolAsStr(*alias)).or_default().push(i); } } @@ -474,7 +487,7 @@ pub(crate) fn build_index( // The String is alias name and the vec is the list of the elements with this alias. // // To be noted: the `usize` elements are indexes to `items`. - aliases: &'a BTreeMap>, + aliases: &'a AliasMap, // Used when a type has more than one impl with an associated item with the same name. associated_item_disambiguators: &'a Vec<(usize, String)>, // A list of shard lengths encoded as vlqhex. See the comment in write_vlqhex_to_string From 3440bc92f90366a9f65ec2b86e3e1b5fe3922aa6 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 3 Jul 2025 13:30:59 +0000 Subject: [PATCH 16/28] Unquerify extern_mod_stmt_cnum. --- compiler/rustc_middle/src/query/mod.rs | 3 --- compiler/rustc_middle/src/ty/context.rs | 7 +++++-- compiler/rustc_passes/src/check_attr.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index ad7f4973e235b..a80b323f4aeab 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -2152,9 +2152,6 @@ rustc_queries! { desc { |tcx| "collecting child items of module `{}`", tcx.def_path_str(def_id) } separate_provide_extern } - query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option { - desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id) } - } /// Gets the number of definitions in a foreign crate. /// diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 51db92ecd78f2..aa1e753538c36 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -3373,6 +3373,11 @@ impl<'tcx> TyCtxt<'tcx> { self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..]) } + /// Return the crate imported by given use item. + pub fn extern_mod_stmt_cnum(self, def_id: LocalDefId) -> Option { + self.resolutions(()).extern_crate_map.get(&def_id).copied() + } + pub fn resolver_for_lowering(self) -> &'tcx Steal<(ty::ResolverAstLowering, Arc)> { self.resolver_for_lowering_raw(()).0 } @@ -3428,8 +3433,6 @@ pub struct DeducedParamAttrs { } pub fn provide(providers: &mut Providers) { - providers.extern_mod_stmt_cnum = - |tcx, id| tcx.resolutions(()).extern_crate_map.get(&id).cloned(); providers.is_panic_runtime = |tcx, LocalCrate| contains_name(tcx.hir_krate_attrs(), sym::panic_runtime); providers.is_compiler_builtins = diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 96c895e71dfe7..22092521fd8d0 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1255,7 +1255,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { return; } - if self.tcx.extern_mod_stmt_cnum(hir_id.owner).is_none() { + if self.tcx.extern_mod_stmt_cnum(hir_id.owner.def_id).is_none() { self.tcx.emit_node_span_lint( INVALID_DOC_ATTRIBUTES, hir_id, From 95de0aaed3a01d6c3f09931ba9d2a5b1ac492a19 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 22 Jul 2025 18:36:09 -0500 Subject: [PATCH 17/28] rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion This function can cause false negatives if used incorrectly (usually "do any of the doc fragments come from a macro" is the wrong question to ask), and thus it is unused. --- compiler/rustc_resolve/src/rustdoc.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs index 24e15ded94fef..6450f63472ca9 100644 --- a/compiler/rustc_resolve/src/rustdoc.rs +++ b/compiler/rustc_resolve/src/rustdoc.rs @@ -509,9 +509,8 @@ fn collect_link_data<'input, F: BrokenLinkCallback<'input>>( display_text.map(String::into_boxed_str) } -/// Returns a tuple containing a span encompassing all the document fragments and a boolean that is -/// `true` if any of the fragments are from a macro expansion. -pub fn span_of_fragments_with_expansion(fragments: &[DocFragment]) -> Option<(Span, bool)> { +/// Returns a span encompassing all the document fragments. +pub fn span_of_fragments(fragments: &[DocFragment]) -> Option { let (first_fragment, last_fragment) = match fragments { [] => return None, [first, .., last] => (first, last), @@ -520,15 +519,7 @@ pub fn span_of_fragments_with_expansion(fragments: &[DocFragment]) -> Option<(Sp if first_fragment.span == DUMMY_SP { return None; } - Some(( - first_fragment.span.to(last_fragment.span), - fragments.iter().any(|frag| frag.from_expansion), - )) -} - -/// Returns a span encompassing all the document fragments. -pub fn span_of_fragments(fragments: &[DocFragment]) -> Option { - span_of_fragments_with_expansion(fragments).map(|(sp, _)| sp) + Some(first_fragment.span.to(last_fragment.span)) } /// Attempts to match a range of bytes from parsed markdown to a `Span` in the source code. @@ -686,7 +677,7 @@ pub fn source_span_for_markdown_range_inner( } } - let (span, _) = span_of_fragments_with_expansion(fragments)?; + let span = span_of_fragments(fragments)?; let src_span = span.from_inner(InnerSpan::new( md_range.start + start_bytes, md_range.end + start_bytes + end_bytes, From ab8e521316874caff183eeb4ab0abf0e1f52906b Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 7 Nov 2024 15:33:45 -0600 Subject: [PATCH 18/28] get rid of some false negatives in rustdoc::broken_intra_doc_links rustdoc will not try to do intra-doc linking if the "path" of a link looks too much like a "real url". however, only inline links ([text](url)) can actually contain a url, other types of links (reference links, shortcut links) contain a *reference* which is later resolved to an actual url. the "path" in this case cannot be a url, and therefore it should not be skipped due to looking like a url. Co-authored-by: Michael Howell --- .../passes/collect_intra_doc_links.rs | 13 ++++++-- tests/rustdoc-ui/bad-intra-doc.rs | 13 ++++++++ tests/rustdoc-ui/bad-intra-doc.stderr | 31 +++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 tests/rustdoc-ui/bad-intra-doc.rs create mode 100644 tests/rustdoc-ui/bad-intra-doc.stderr diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 5a9aa2a94c8b4..97f8a2be10b27 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -941,13 +941,20 @@ fn preprocess_link( ori_link: &MarkdownLink, dox: &str, ) -> Option> { + // certain link kinds cannot have their path be urls, + // so they should not be ignored, no matter how much they look like urls. + // e.g. [https://example.com/] is not a link to example.com. + let can_be_url = ori_link.kind != LinkType::ShortcutUnknown + && ori_link.kind != LinkType::CollapsedUnknown + && ori_link.kind != LinkType::ReferenceUnknown; + // [] is mostly likely not supposed to be a link if ori_link.link.is_empty() { return None; } // Bail early for real links. - if ori_link.link.contains('/') { + if can_be_url && ori_link.link.contains('/') { return None; } @@ -972,7 +979,7 @@ fn preprocess_link( Ok(None) => (None, link, link), Err((err_msg, relative_range)) => { // Only report error if we would not have ignored this link. See issue #83859. - if !should_ignore_link_with_disambiguators(link) { + if !(can_be_url && should_ignore_link_with_disambiguators(link)) { let disambiguator_range = match range_between_backticks(&ori_link.range, dox) { MarkdownLinkRange::Destination(no_backticks_range) => { MarkdownLinkRange::Destination( @@ -989,7 +996,7 @@ fn preprocess_link( } }; - if should_ignore_link(path_str) { + if can_be_url && should_ignore_link(path_str) { return None; } diff --git a/tests/rustdoc-ui/bad-intra-doc.rs b/tests/rustdoc-ui/bad-intra-doc.rs new file mode 100644 index 0000000000000..7bc55756e670b --- /dev/null +++ b/tests/rustdoc-ui/bad-intra-doc.rs @@ -0,0 +1,13 @@ +#![no_std] +#![deny(rustdoc::broken_intra_doc_links)] + +// regression test for https://github.com/rust-lang/rust/issues/54191 + +/// this is not a link to [`example.com`] //~ERROR unresolved link +/// +/// this link [`has spaces in it`]. +/// +/// attempted link to method: [`Foo.bar()`] //~ERROR unresolved link +/// +/// classic broken intra-doc link: [`Bar`] //~ERROR unresolved link +pub struct Foo; diff --git a/tests/rustdoc-ui/bad-intra-doc.stderr b/tests/rustdoc-ui/bad-intra-doc.stderr new file mode 100644 index 0000000000000..9533792b35b60 --- /dev/null +++ b/tests/rustdoc-ui/bad-intra-doc.stderr @@ -0,0 +1,31 @@ +error: unresolved link to `example.com` + --> $DIR/bad-intra-doc.rs:6:29 + | +LL | /// this is not a link to [`example.com`] + | ^^^^^^^^^^^ no item named `example.com` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` +note: the lint level is defined here + --> $DIR/bad-intra-doc.rs:2:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unresolved link to `Foo.bar` + --> $DIR/bad-intra-doc.rs:10:33 + | +LL | /// attempted link to method: [`Foo.bar()`] + | ^^^^^^^^^ no item named `Foo.bar` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `Bar` + --> $DIR/bad-intra-doc.rs:12:38 + | +LL | /// classic broken intra-doc link: [`Bar`] + | ^^^ no item named `Bar` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: aborting due to 3 previous errors + From 91b9b33ce3f141d20eac39d7d924286a17055486 Mon Sep 17 00:00:00 2001 From: binarycat Date: Fri, 8 Nov 2024 13:59:56 -0600 Subject: [PATCH 19/28] adjust more unit tests to reflect more aggressive intra-doc linting --- .../disambiguator-endswith-named-suffix.rs | 30 ++--- ...disambiguator-endswith-named-suffix.stderr | 122 +++++++++++++++++- tests/rustdoc-ui/intra-doc/weird-syntax.rs | 2 +- .../rustdoc-ui/intra-doc/weird-syntax.stderr | 24 ++++ .../lints/redundant_explicit_links-utf8.rs | 14 +- .../redundant_explicit_links-utf8.stderr | 59 +++++++++ 6 files changed, 230 insertions(+), 21 deletions(-) create mode 100644 tests/rustdoc-ui/lints/redundant_explicit_links-utf8.stderr diff --git a/tests/rustdoc-ui/disambiguator-endswith-named-suffix.rs b/tests/rustdoc-ui/disambiguator-endswith-named-suffix.rs index 1174e16dd53fd..cb277d529ce77 100644 --- a/tests/rustdoc-ui/disambiguator-endswith-named-suffix.rs +++ b/tests/rustdoc-ui/disambiguator-endswith-named-suffix.rs @@ -2,67 +2,67 @@ //@ normalize-stderr: "nightly|beta|1\.[0-9][0-9]\.[0-9]" -> "$$CHANNEL" //! [struct@m!()] //~ WARN: unmatched disambiguator `struct` and suffix `!()` -//! [struct@m!{}] +//! [struct@m!{}] //~ WARN: unmatched disambiguator `struct` and suffix `!{}` //! [struct@m![]] //! [struct@f()] //~ WARN: unmatched disambiguator `struct` and suffix `()` //! [struct@m!] //~ WARN: unmatched disambiguator `struct` and suffix `!` //! //! [enum@m!()] //~ WARN: unmatched disambiguator `enum` and suffix `!()` -//! [enum@m!{}] +//! [enum@m!{}] //~ WARN: unmatched disambiguator `enum` and suffix `!{}` //! [enum@m![]] //! [enum@f()] //~ WARN: unmatched disambiguator `enum` and suffix `()` //! [enum@m!] //~ WARN: unmatched disambiguator `enum` and suffix `!` //! //! [trait@m!()] //~ WARN: unmatched disambiguator `trait` and suffix `!()` -//! [trait@m!{}] +//! [trait@m!{}] //~ WARN: unmatched disambiguator `trait` and suffix `!{}` //! [trait@m![]] //! [trait@f()] //~ WARN: unmatched disambiguator `trait` and suffix `()` //! [trait@m!] //~ WARN: unmatched disambiguator `trait` and suffix `!` //! //! [module@m!()] //~ WARN: unmatched disambiguator `module` and suffix `!()` -//! [module@m!{}] +//! [module@m!{}] //~ WARN: unmatched disambiguator `module` and suffix `!{}` //! [module@m![]] //! [module@f()] //~ WARN: unmatched disambiguator `module` and suffix `()` //! [module@m!] //~ WARN: unmatched disambiguator `module` and suffix `!` //! //! [mod@m!()] //~ WARN: unmatched disambiguator `mod` and suffix `!()` -//! [mod@m!{}] +//! [mod@m!{}] //~ WARN: unmatched disambiguator `mod` and suffix `!{}` //! [mod@m![]] //! [mod@f()] //~ WARN: unmatched disambiguator `mod` and suffix `()` //! [mod@m!] //~ WARN: unmatched disambiguator `mod` and suffix `!` //! //! [const@m!()] //~ WARN: unmatched disambiguator `const` and suffix `!()` -//! [const@m!{}] +//! [const@m!{}] //~ WARN: unmatched disambiguator `const` and suffix `!{}` //! [const@m![]] //! [const@f()] //~ WARN: incompatible link kind for `f` //! [const@m!] //~ WARN: unmatched disambiguator `const` and suffix `!` //! //! [constant@m!()] //~ WARN: unmatched disambiguator `constant` and suffix `!()` -//! [constant@m!{}] +//! [constant@m!{}] //~ WARN: unmatched disambiguator `constant` and suffix `!{}` //! [constant@m![]] //! [constant@f()] //~ WARN: incompatible link kind for `f` //! [constant@m!] //~ WARN: unmatched disambiguator `constant` and suffix `!` //! //! [static@m!()] //~ WARN: unmatched disambiguator `static` and suffix `!()` -//! [static@m!{}] +//! [static@m!{}] //~ WARN: unmatched disambiguator `static` and suffix `!{}` //! [static@m![]] //! [static@f()] //~ WARN: incompatible link kind for `f` //! [static@m!] //~ WARN: unmatched disambiguator `static` and suffix `!` //! //! [function@m!()] //~ WARN: unmatched disambiguator `function` and suffix `!()` -//! [function@m!{}] +//! [function@m!{}] //~ WARN: unmatched disambiguator `function` and suffix `!{}` //! [function@m![]] //! [function@f()] //! [function@m!] //~ WARN: unmatched disambiguator `function` and suffix `!` //! //! [fn@m!()] //~ WARN: unmatched disambiguator `fn` and suffix `!()` -//! [fn@m!{}] +//! [fn@m!{}] //~ WARN: unmatched disambiguator `fn` and suffix `!{}` //! [fn@m![]] //! [fn@f()] //! [fn@m!] //~ WARN: unmatched disambiguator `fn` and suffix `!` //! //! [method@m!()] //~ WARN: unmatched disambiguator `method` and suffix `!()` -//! [method@m!{}] +//! [method@m!{}] //~ WARN: unmatched disambiguator `method` and suffix `!{}` //! [method@m![]] //! [method@f()] //! [method@m!] //~ WARN: unmatched disambiguator `method` and suffix `!` @@ -74,13 +74,13 @@ //! [derive@m!] //~ WARN: incompatible link kind for `m` //! //! [type@m!()] //~ WARN: unmatched disambiguator `type` and suffix `!()` -//! [type@m!{}] +//! [type@m!{}] //~ WARN: unmatched disambiguator `type` and suffix `!{}` //! [type@m![]] //! [type@f()] //~ WARN: unmatched disambiguator `type` and suffix `()` //! [type@m!] //~ WARN: unmatched disambiguator `type` and suffix `!` //! //! [value@m!()] //~ WARN: unmatched disambiguator `value` and suffix `!()` -//! [value@m!{}] +//! [value@m!{}] //~ WARN: unmatched disambiguator `value` and suffix `!{}` //! [value@m![]] //! [value@f()] //! [value@m!] //~ WARN: unmatched disambiguator `value` and suffix `!` @@ -92,13 +92,13 @@ //! [macro@m!] //! //! [prim@m!()] //~ WARN: unmatched disambiguator `prim` and suffix `!()` -//! [prim@m!{}] +//! [prim@m!{}] //~ WARN: unmatched disambiguator `prim` and suffix `!{}` //! [prim@m![]] //! [prim@f()] //~ WARN: unmatched disambiguator `prim` and suffix `()` //! [prim@m!] //~ WARN: unmatched disambiguator `prim` and suffix `!` //! //! [primitive@m!()] //~ WARN: unmatched disambiguator `primitive` and suffix `!()` -//! [primitive@m!{}] +//! [primitive@m!{}] //~ WARN: unmatched disambiguator `primitive` and suffix `!{}` //! [primitive@m![]] //! [primitive@f()] //~ WARN: unmatched disambiguator `primitive` and suffix `()` //! [primitive@m!] //~ WARN: unmatched disambiguator `primitive` and suffix `!` diff --git a/tests/rustdoc-ui/disambiguator-endswith-named-suffix.stderr b/tests/rustdoc-ui/disambiguator-endswith-named-suffix.stderr index f4e40a4887383..1840338596880 100644 --- a/tests/rustdoc-ui/disambiguator-endswith-named-suffix.stderr +++ b/tests/rustdoc-ui/disambiguator-endswith-named-suffix.stderr @@ -7,6 +7,14 @@ LL | //! [struct@m!()] = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default +warning: unmatched disambiguator `struct` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:5:6 + | +LL | //! [struct@m!{}] + | ^^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `struct` and suffix `()` --> $DIR/disambiguator-endswith-named-suffix.rs:7:6 | @@ -31,6 +39,14 @@ LL | //! [enum@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `enum` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:11:6 + | +LL | //! [enum@m!{}] + | ^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `enum` and suffix `()` --> $DIR/disambiguator-endswith-named-suffix.rs:13:6 | @@ -55,6 +71,14 @@ LL | //! [trait@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `trait` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:17:6 + | +LL | //! [trait@m!{}] + | ^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `trait` and suffix `()` --> $DIR/disambiguator-endswith-named-suffix.rs:19:6 | @@ -79,6 +103,14 @@ LL | //! [module@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `module` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:23:6 + | +LL | //! [module@m!{}] + | ^^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `module` and suffix `()` --> $DIR/disambiguator-endswith-named-suffix.rs:25:6 | @@ -103,6 +135,14 @@ LL | //! [mod@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `mod` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:29:6 + | +LL | //! [mod@m!{}] + | ^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `mod` and suffix `()` --> $DIR/disambiguator-endswith-named-suffix.rs:31:6 | @@ -127,6 +167,14 @@ LL | //! [const@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `const` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:35:6 + | +LL | //! [const@m!{}] + | ^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: incompatible link kind for `f` --> $DIR/disambiguator-endswith-named-suffix.rs:37:6 | @@ -155,6 +203,14 @@ LL | //! [constant@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `constant` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:41:6 + | +LL | //! [constant@m!{}] + | ^^^^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: incompatible link kind for `f` --> $DIR/disambiguator-endswith-named-suffix.rs:43:6 | @@ -183,6 +239,14 @@ LL | //! [static@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `static` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:47:6 + | +LL | //! [static@m!{}] + | ^^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: incompatible link kind for `f` --> $DIR/disambiguator-endswith-named-suffix.rs:49:6 | @@ -211,6 +275,14 @@ LL | //! [function@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `function` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:53:6 + | +LL | //! [function@m!{}] + | ^^^^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `function` and suffix `!` --> $DIR/disambiguator-endswith-named-suffix.rs:56:6 | @@ -227,6 +299,14 @@ LL | //! [fn@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `fn` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:59:6 + | +LL | //! [fn@m!{}] + | ^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `fn` and suffix `!` --> $DIR/disambiguator-endswith-named-suffix.rs:62:6 | @@ -243,6 +323,14 @@ LL | //! [method@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `method` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:65:6 + | +LL | //! [method@m!{}] + | ^^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `method` and suffix `!` --> $DIR/disambiguator-endswith-named-suffix.rs:68:6 | @@ -303,6 +391,14 @@ LL | //! [type@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `type` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:77:6 + | +LL | //! [type@m!{}] + | ^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `type` and suffix `()` --> $DIR/disambiguator-endswith-named-suffix.rs:79:6 | @@ -327,6 +423,14 @@ LL | //! [value@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `value` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:83:6 + | +LL | //! [value@m!{}] + | ^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `value` and suffix `!` --> $DIR/disambiguator-endswith-named-suffix.rs:86:6 | @@ -351,6 +455,14 @@ LL | //! [prim@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `prim` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:95:6 + | +LL | //! [prim@m!{}] + | ^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `prim` and suffix `()` --> $DIR/disambiguator-endswith-named-suffix.rs:97:6 | @@ -375,6 +487,14 @@ LL | //! [primitive@m!()] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators +warning: unmatched disambiguator `primitive` and suffix `!{}` + --> $DIR/disambiguator-endswith-named-suffix.rs:101:6 + | +LL | //! [primitive@m!{}] + | ^^^^^^^^^ + | + = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators + warning: unmatched disambiguator `primitive` and suffix `()` --> $DIR/disambiguator-endswith-named-suffix.rs:103:6 | @@ -391,5 +511,5 @@ LL | //! [primitive@m!] | = note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators -warning: 46 warnings emitted +warning: 61 warnings emitted diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.rs b/tests/rustdoc-ui/intra-doc/weird-syntax.rs index d2a922b2b6247..1c5977b1bc33d 100644 --- a/tests/rustdoc-ui/intra-doc/weird-syntax.rs +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.rs @@ -65,7 +65,7 @@ pub struct XLinkToCloneWithStartSpace; /// [x][struct@Clone ] //~ERROR link pub struct XLinkToCloneWithEndSpace; -/// [x][Clone\(\)] not URL-shaped enough +/// [x][Clone\(\)] //~ERROR link pub struct XLinkToCloneWithEscapedParens; /// [x][`Clone`] not URL-shaped enough diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.stderr b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr index ad813f0f9b623..3a567e409eff7 100644 --- a/tests/rustdoc-ui/intra-doc/weird-syntax.stderr +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr @@ -123,6 +123,14 @@ LL - /// [x][struct@Clone ] LL + /// [x][trait@Clone ] | +error: unresolved link to `Clone\(\)` + --> $DIR/weird-syntax.rs:68:9 + | +LL | /// [x][Clone\(\)] + | ^^^^^^^^^ no item named `Clone\(\)` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + error: unresolved link to `Clone` --> $DIR/weird-syntax.rs:74:9 | @@ -299,5 +307,21 @@ LL | /// - [`SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`]: the | = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:132:9 + | +LL | /// The [cln][] link here will produce a plain text suggestion + | ^^^^^ this link resolves to the trait `Clone`, which is not a function + | + = help: to link to the trait, prefix with `trait@`: trait@Clone + +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:137:9 + | +LL | /// The [cln][] link here will produce a plain text suggestion + | ^^^^^ this link resolved to a trait, which is not a struct + | + = help: to link to the trait, prefix with `trait@`: trait@Clone + error: aborting due to 27 previous errors diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs b/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs index 4f4590d45fc88..81cd6c73d1c17 100644 --- a/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs +++ b/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs @@ -1,18 +1,24 @@ //@ check-pass -/// [`…foo`] [`…bar`] [`Err`] +/// [`…foo`] //~ WARN: unresolved link +/// [`…bar`] //~ WARN: unresolved link +/// [`Err`] pub struct Broken {} -/// [`…`] [`…`] [`Err`] +/// [`…`] //~ WARN: unresolved link +/// [`…`] //~ WARN: unresolved link +/// [`Err`] pub struct Broken2 {} -/// [`…`][…] [`…`][…] [`Err`] +/// [`…`][…] //~ WARN: unresolved link +/// [`…`][…] //~ WARN: unresolved link +/// [`Err`] pub struct Broken3 {} /// […………………………][Broken3] pub struct Broken4 {} -/// [Broken3][…………………………] +/// [Broken3][…………………………] //~ WARN: unresolved link pub struct Broken5 {} pub struct Err; diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.stderr b/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.stderr new file mode 100644 index 0000000000000..0a5ff68b90814 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.stderr @@ -0,0 +1,59 @@ +warning: unresolved link to `…foo` + --> $DIR/redundant_explicit_links-utf8.rs:3:7 + | +LL | /// [`…foo`] + | ^^^^ no item named `…foo` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default + +warning: unresolved link to `…bar` + --> $DIR/redundant_explicit_links-utf8.rs:4:7 + | +LL | /// [`…bar`] + | ^^^^ no item named `…bar` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `…` + --> $DIR/redundant_explicit_links-utf8.rs:8:7 + | +LL | /// [`…`] + | ^ no item named `…` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `…` + --> $DIR/redundant_explicit_links-utf8.rs:9:7 + | +LL | /// [`…`] + | ^ no item named `…` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `…` + --> $DIR/redundant_explicit_links-utf8.rs:13:11 + | +LL | /// [`…`][…] + | ^ no item named `…` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `…` + --> $DIR/redundant_explicit_links-utf8.rs:14:11 + | +LL | /// [`…`][…] + | ^ no item named `…` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `…………………………` + --> $DIR/redundant_explicit_links-utf8.rs:21:15 + | +LL | /// [Broken3][…………………………] + | ^^^^^^^^^^ no item named `…………………………` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: 7 warnings emitted + From de68c59c233b11e78bbd09873b289ea37fbd7a86 Mon Sep 17 00:00:00 2001 From: binarycat Date: Fri, 18 Apr 2025 15:32:56 -0500 Subject: [PATCH 20/28] rustdoc::broken_intra_doc_links: no backticks = use old behavior this is in an effort to reduce the amount of code churn caused by this lint triggering on text that was never meant to be a link. a more principled hierustic for ignoring lints is not possible without extensive changes, due to the lint emitting code being so far away from the link collecting code, and the fact that only the link collecting code has access to details about how the link appears in the unnormalized markdown. --- src/librustdoc/passes/collect_intra_doc_links.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 97f8a2be10b27..08f0d4015fcaf 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -996,7 +996,9 @@ fn preprocess_link( } }; - if can_be_url && should_ignore_link(path_str) { + // If there's no backticks, be lenient revert to old behavior. + // This is to prevent churn by linting on stuff that isn't meant to be a link. + if (can_be_url || !ori_link.link.contains('`')) && should_ignore_link(path_str) { return None; } From c5b39cfa9475f7eccf1ae3be9889b10209f570cd Mon Sep 17 00:00:00 2001 From: binarycat Date: Fri, 18 Apr 2025 17:15:11 -0500 Subject: [PATCH 21/28] rustdoc: update tests to match new lint behavior --- tests/rustdoc-ui/bad-intra-doc.rs | 2 ++ tests/rustdoc-ui/intra-doc/weird-syntax.rs | 2 +- .../rustdoc-ui/intra-doc/weird-syntax.stderr | 24 ------------------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/tests/rustdoc-ui/bad-intra-doc.rs b/tests/rustdoc-ui/bad-intra-doc.rs index 7bc55756e670b..c24a848d8985c 100644 --- a/tests/rustdoc-ui/bad-intra-doc.rs +++ b/tests/rustdoc-ui/bad-intra-doc.rs @@ -10,4 +10,6 @@ /// attempted link to method: [`Foo.bar()`] //~ERROR unresolved link /// /// classic broken intra-doc link: [`Bar`] //~ERROR unresolved link +/// +/// no backticks, so we let this one slide: [Foo.bar()] pub struct Foo; diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.rs b/tests/rustdoc-ui/intra-doc/weird-syntax.rs index 1c5977b1bc33d..9f18f67fc44ab 100644 --- a/tests/rustdoc-ui/intra-doc/weird-syntax.rs +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.rs @@ -65,7 +65,7 @@ pub struct XLinkToCloneWithStartSpace; /// [x][struct@Clone ] //~ERROR link pub struct XLinkToCloneWithEndSpace; -/// [x][Clone\(\)] //~ERROR link +/// [x][Clone\(\)] pub struct XLinkToCloneWithEscapedParens; /// [x][`Clone`] not URL-shaped enough diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.stderr b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr index 3a567e409eff7..ad813f0f9b623 100644 --- a/tests/rustdoc-ui/intra-doc/weird-syntax.stderr +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr @@ -123,14 +123,6 @@ LL - /// [x][struct@Clone ] LL + /// [x][trait@Clone ] | -error: unresolved link to `Clone\(\)` - --> $DIR/weird-syntax.rs:68:9 - | -LL | /// [x][Clone\(\)] - | ^^^^^^^^^ no item named `Clone\(\)` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - error: unresolved link to `Clone` --> $DIR/weird-syntax.rs:74:9 | @@ -307,21 +299,5 @@ LL | /// - [`SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`]: the | = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` -error: unresolved link to `Clone` - --> $DIR/weird-syntax.rs:132:9 - | -LL | /// The [cln][] link here will produce a plain text suggestion - | ^^^^^ this link resolves to the trait `Clone`, which is not a function - | - = help: to link to the trait, prefix with `trait@`: trait@Clone - -error: incompatible link kind for `Clone` - --> $DIR/weird-syntax.rs:137:9 - | -LL | /// The [cln][] link here will produce a plain text suggestion - | ^^^^^ this link resolved to a trait, which is not a struct - | - = help: to link to the trait, prefix with `trait@`: trait@Clone - error: aborting due to 27 previous errors From 82df8924b5d5e7f8f70fec1e31e2e5ef54fbb5f0 Mon Sep 17 00:00:00 2001 From: binarycat Date: Fri, 18 Apr 2025 20:23:05 -0500 Subject: [PATCH 22/28] rustdoc::broken_intra_doc_links: only be lenient with shortcut links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit collapsed links and reference links have a pretty particular syntax, it seems unlikely they would show up on accident. Co-authored-by: León Orell Valerian Liehr --- .../passes/collect_intra_doc_links.rs | 27 +++++++++++++++---- tests/rustdoc-ui/intra-doc/weird-syntax.rs | 2 +- .../rustdoc-ui/intra-doc/weird-syntax.stderr | 10 ++++++- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 08f0d4015fcaf..c9fa3a4837f29 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -944,9 +944,10 @@ fn preprocess_link( // certain link kinds cannot have their path be urls, // so they should not be ignored, no matter how much they look like urls. // e.g. [https://example.com/] is not a link to example.com. - let can_be_url = ori_link.kind != LinkType::ShortcutUnknown - && ori_link.kind != LinkType::CollapsedUnknown - && ori_link.kind != LinkType::ReferenceUnknown; + let can_be_url = !matches!( + ori_link.kind, + LinkType::ShortcutUnknown | LinkType::CollapsedUnknown | LinkType::ReferenceUnknown + ); // [] is mostly likely not supposed to be a link if ori_link.link.is_empty() { @@ -996,9 +997,25 @@ fn preprocess_link( } }; - // If there's no backticks, be lenient revert to old behavior. + // If there's no backticks, be lenient and revert to the old behavior. // This is to prevent churn by linting on stuff that isn't meant to be a link. - if (can_be_url || !ori_link.link.contains('`')) && should_ignore_link(path_str) { + // only shortcut links have simple enough syntax that they + // are likely to be written accidentally, collapsed and reference links + // need 4 metachars, and reference links will not usually use + // backticks in the reference name. + // therefore, only shortcut syntax gets the lenient behavior. + // + // here's a truth table for how link kinds that cannot be urls are handled: + // + // |-------------------------------------------------------| + // | | is shortcut link | not shortcut link | + // |--------------|--------------------|-------------------| + // | has backtick | never ignore | never ignore | + // | no backtick | ignore if url-like | never ignore | + // |-------------------------------------------------------| + let ignore_urllike = + can_be_url || (ori_link.kind == LinkType::ShortcutUnknown && !ori_link.link.contains('`')); + if ignore_urllike && should_ignore_link(path_str) { return None; } diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.rs b/tests/rustdoc-ui/intra-doc/weird-syntax.rs index 9f18f67fc44ab..1c5977b1bc33d 100644 --- a/tests/rustdoc-ui/intra-doc/weird-syntax.rs +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.rs @@ -65,7 +65,7 @@ pub struct XLinkToCloneWithStartSpace; /// [x][struct@Clone ] //~ERROR link pub struct XLinkToCloneWithEndSpace; -/// [x][Clone\(\)] +/// [x][Clone\(\)] //~ERROR link pub struct XLinkToCloneWithEscapedParens; /// [x][`Clone`] not URL-shaped enough diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.stderr b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr index ad813f0f9b623..7f2fc1fe62562 100644 --- a/tests/rustdoc-ui/intra-doc/weird-syntax.stderr +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr @@ -123,6 +123,14 @@ LL - /// [x][struct@Clone ] LL + /// [x][trait@Clone ] | +error: unresolved link to `Clone\(\)` + --> $DIR/weird-syntax.rs:68:9 + | +LL | /// [x][Clone\(\)] + | ^^^^^^^^^ no item named `Clone\(\)` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + error: unresolved link to `Clone` --> $DIR/weird-syntax.rs:74:9 | @@ -299,5 +307,5 @@ LL | /// - [`SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`]: the | = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` -error: aborting due to 27 previous errors +error: aborting due to 28 previous errors From 2d389969c42f3a52ef63b8654740408c89feeb83 Mon Sep 17 00:00:00 2001 From: binarycat Date: Sat, 19 Apr 2025 10:51:40 -0500 Subject: [PATCH 23/28] move bad-intra-doc test into intra-doc dir --- tests/rustdoc-ui/{ => intra-doc}/bad-intra-doc.rs | 0 tests/rustdoc-ui/{ => intra-doc}/bad-intra-doc.stderr | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/rustdoc-ui/{ => intra-doc}/bad-intra-doc.rs (100%) rename tests/rustdoc-ui/{ => intra-doc}/bad-intra-doc.stderr (100%) diff --git a/tests/rustdoc-ui/bad-intra-doc.rs b/tests/rustdoc-ui/intra-doc/bad-intra-doc.rs similarity index 100% rename from tests/rustdoc-ui/bad-intra-doc.rs rename to tests/rustdoc-ui/intra-doc/bad-intra-doc.rs diff --git a/tests/rustdoc-ui/bad-intra-doc.stderr b/tests/rustdoc-ui/intra-doc/bad-intra-doc.stderr similarity index 100% rename from tests/rustdoc-ui/bad-intra-doc.stderr rename to tests/rustdoc-ui/intra-doc/bad-intra-doc.stderr From 9bb9c39fa5c5f5ea38c5173aa7c23c290a9cac88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 23 Jul 2025 01:48:54 +0200 Subject: [PATCH 24/28] Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding --- .../src/hir_ty_lowering/lint.rs | 19 ++++++++++++++++--- .../suggest-assoc-ty-bound-on-eq-bound.rs | 9 ++++++++- .../suggest-assoc-ty-bound-on-eq-bound.stderr | 13 ++++++++++++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs index 9abae33ffdbb9..646ff3ca08d24 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs @@ -447,17 +447,30 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { fn maybe_suggest_assoc_ty_bound(&self, self_ty: &hir::Ty<'_>, diag: &mut Diag<'_>) { let mut parents = self.tcx().hir_parent_iter(self_ty.hir_id); - if let Some((_, hir::Node::AssocItemConstraint(constraint))) = parents.next() + if let Some((c_hir_id, hir::Node::AssocItemConstraint(constraint))) = parents.next() && let Some(obj_ty) = constraint.ty() + && let Some((_, hir::Node::TraitRef(trait_ref))) = parents.next() { - if let Some((_, hir::Node::TraitRef(..))) = parents.next() - && let Some((_, hir::Node::Ty(ty))) = parents.next() + if let Some((_, hir::Node::Ty(ty))) = parents.next() && let hir::TyKind::TraitObject(..) = ty.kind { // Assoc ty bounds aren't permitted inside trait object types. return; } + if trait_ref + .path + .segments + .iter() + .find_map(|seg| { + seg.args.filter(|args| args.constraints.iter().any(|c| c.hir_id == c_hir_id)) + }) + .is_none_or(|args| args.parenthesized != hir::GenericArgsParentheses::No) + { + // Only consider angle-bracketed args (where we have a `=` to replace with `:`). + return; + } + let lo = if constraint.gen_args.span_ext.is_dummy() { constraint.ident.span } else { diff --git a/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.rs b/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.rs index c8bb0ebd5744b..49e46f44cb2f8 100644 --- a/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.rs +++ b/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.rs @@ -1,4 +1,4 @@ -// Regression test for issue #105056. +// issue: //@ edition: 2021 fn f(_: impl Trait) {} @@ -23,4 +23,11 @@ type Obj = dyn Trait; trait Trait { type T; } +// Don't suggest assoc ty bounds when we have parenthesized args (the underlying assoc type +// binding `Output` isn't introduced by `=` but by `->`, suggesting `:` wouldn't be valid). +// issue: +fn i(_: impl Fn() -> std::fmt::Debug) {} +//~^ ERROR expected a type, found a trait +//~| HELP you can add the `dyn` keyword if you want a trait object + fn main() {} diff --git a/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.stderr b/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.stderr index 6eb8fabb1852c..ea9f25f07194b 100644 --- a/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.stderr +++ b/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.stderr @@ -57,6 +57,17 @@ help: you can add the `dyn` keyword if you want a trait object LL | type Obj = dyn Trait; | +++ -error: aborting due to 4 previous errors +error[E0782]: expected a type, found a trait + --> $DIR/suggest-assoc-ty-bound-on-eq-bound.rs:29:22 + | +LL | fn i(_: impl Fn() -> std::fmt::Debug) {} + | ^^^^^^^^^^^^^^^ + | +help: you can add the `dyn` keyword if you want a trait object + | +LL | fn i(_: impl Fn() -> dyn std::fmt::Debug) {} + | +++ + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0782`. From eb9c65476c9dbcf90d67e938218731f58e6c699a Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Sat, 12 Jul 2025 18:47:19 +0530 Subject: [PATCH 25/28] std: net: uefi: Add support to query connection data - Use EFI_TCP4_GET_MODE_DATA to be able to query for ttl, nodelay, peer_addr and socket_addr. - peer_addr is needed for implementation of `accept`. Signed-off-by: Ayush Singh --- .../std/src/sys/net/connection/uefi/mod.rs | 32 +++++++------- .../std/src/sys/net/connection/uefi/tcp.rs | 42 +++++++++++++++++++ .../std/src/sys/net/connection/uefi/tcp4.rs | 18 ++++++++ library/std/src/sys/pal/uefi/helpers.rs | 4 ++ 4 files changed, 81 insertions(+), 15 deletions(-) diff --git a/library/std/src/sys/net/connection/uefi/mod.rs b/library/std/src/sys/net/connection/uefi/mod.rs index 884cbd4ac1dc7..16e3487a1747f 100644 --- a/library/std/src/sys/net/connection/uefi/mod.rs +++ b/library/std/src/sys/net/connection/uefi/mod.rs @@ -86,11 +86,11 @@ impl TcpStream { } pub fn peer_addr(&self) -> io::Result { - unsupported() + self.inner.peer_addr() } pub fn socket_addr(&self) -> io::Result { - unsupported() + self.inner.socket_addr() } pub fn shutdown(&self, _: Shutdown) -> io::Result<()> { @@ -114,7 +114,7 @@ impl TcpStream { } pub fn nodelay(&self) -> io::Result { - unsupported() + self.inner.nodelay() } pub fn set_ttl(&self, _: u32) -> io::Result<()> { @@ -122,7 +122,7 @@ impl TcpStream { } pub fn ttl(&self) -> io::Result { - unsupported() + self.inner.ttl() } pub fn take_error(&self) -> io::Result> { @@ -140,7 +140,9 @@ impl fmt::Debug for TcpStream { } } -pub struct TcpListener(!); +pub struct TcpListener { + inner: tcp::Tcp, +} impl TcpListener { pub fn bind(_: io::Result<&SocketAddr>) -> io::Result { @@ -148,45 +150,45 @@ impl TcpListener { } pub fn socket_addr(&self) -> io::Result { - self.0 + unsupported() } pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { - self.0 + unsupported() } pub fn duplicate(&self) -> io::Result { - self.0 + unsupported() } pub fn set_ttl(&self, _: u32) -> io::Result<()> { - self.0 + unsupported() } pub fn ttl(&self) -> io::Result { - self.0 + self.inner.ttl() } pub fn set_only_v6(&self, _: bool) -> io::Result<()> { - self.0 + unsupported() } pub fn only_v6(&self) -> io::Result { - self.0 + unsupported() } pub fn take_error(&self) -> io::Result> { - self.0 + unsupported() } pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - self.0 + unsupported() } } impl fmt::Debug for TcpListener { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.0 + todo!() } } diff --git a/library/std/src/sys/net/connection/uefi/tcp.rs b/library/std/src/sys/net/connection/uefi/tcp.rs index 1152f69446e42..aac97007bbfe5 100644 --- a/library/std/src/sys/net/connection/uefi/tcp.rs +++ b/library/std/src/sys/net/connection/uefi/tcp.rs @@ -1,6 +1,8 @@ use super::tcp4; use crate::io; use crate::net::SocketAddr; +use crate::ptr::NonNull; +use crate::sys::{helpers, unsupported}; use crate::time::Duration; pub(crate) enum Tcp { @@ -31,4 +33,44 @@ impl Tcp { Self::V4(client) => client.read(buf, timeout), } } + + pub(crate) fn ttl(&self) -> io::Result { + match self { + Self::V4(client) => client.get_mode_data().map(|x| x.time_to_live.into()), + } + } + + pub(crate) fn nodelay(&self) -> io::Result { + match self { + Self::V4(client) => { + let temp = client.get_mode_data()?; + match NonNull::new(temp.control_option) { + Some(x) => unsafe { Ok(x.as_ref().enable_nagle.into()) }, + None => unsupported(), + } + } + } + } + + pub fn peer_addr(&self) -> io::Result { + match self { + Self::V4(client) => client.get_mode_data().map(|x| { + SocketAddr::new( + helpers::ipv4_from_r_efi(x.access_point.remote_address).into(), + x.access_point.remote_port, + ) + }), + } + } + + pub fn socket_addr(&self) -> io::Result { + match self { + Self::V4(client) => client.get_mode_data().map(|x| { + SocketAddr::new( + helpers::ipv4_from_r_efi(x.access_point.station_address).into(), + x.access_point.station_port, + ) + }), + } + } } diff --git a/library/std/src/sys/net/connection/uefi/tcp4.rs b/library/std/src/sys/net/connection/uefi/tcp4.rs index 6342718929a7d..75862ff247b4f 100644 --- a/library/std/src/sys/net/connection/uefi/tcp4.rs +++ b/library/std/src/sys/net/connection/uefi/tcp4.rs @@ -67,6 +67,24 @@ impl Tcp4 { if r.is_error() { Err(crate::io::Error::from_raw_os_error(r.as_usize())) } else { Ok(()) } } + pub(crate) fn get_mode_data(&self) -> io::Result { + let mut config_data = tcp4::ConfigData::default(); + let protocol = self.protocol.as_ptr(); + + let r = unsafe { + ((*protocol).get_mode_data)( + protocol, + crate::ptr::null_mut(), + &mut config_data, + crate::ptr::null_mut(), + crate::ptr::null_mut(), + crate::ptr::null_mut(), + ) + }; + + if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(config_data) } + } + pub(crate) fn connect(&self, timeout: Option) -> io::Result<()> { let evt = unsafe { self.create_evt() }?; let completion_token = diff --git a/library/std/src/sys/pal/uefi/helpers.rs b/library/std/src/sys/pal/uefi/helpers.rs index 420481648a7d5..271dc4d11de75 100644 --- a/library/std/src/sys/pal/uefi/helpers.rs +++ b/library/std/src/sys/pal/uefi/helpers.rs @@ -761,3 +761,7 @@ impl Drop for OwnedEvent { pub(crate) const fn ipv4_to_r_efi(addr: crate::net::Ipv4Addr) -> efi::Ipv4Address { efi::Ipv4Address { addr: addr.octets() } } + +pub(crate) const fn ipv4_from_r_efi(ip: efi::Ipv4Address) -> crate::net::Ipv4Addr { + crate::net::Ipv4Addr::new(ip.addr[0], ip.addr[1], ip.addr[2], ip.addr[3]) +} From af06bb925f2a3cd24ab2c623d75b5ea2847dc171 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Wed, 23 Jul 2025 14:31:50 +0200 Subject: [PATCH 26/28] Stop using the old `validate_attr` logic for stability attributes --- .../src/attributes/stability.rs | 26 ++++++++++++--- compiler/rustc_parse/src/validate_attr.rs | 3 ++ .../stability-attribute-sanity-4.stderr | 32 +++++++++++++------ 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/stability.rs b/compiler/rustc_attr_parsing/src/attributes/stability.rs index 59337749c8775..c54fc6b41f8e4 100644 --- a/compiler/rustc_attr_parsing/src/attributes/stability.rs +++ b/compiler/rustc_attr_parsing/src/attributes/stability.rs @@ -74,8 +74,15 @@ impl AttributeParser for StabilityParser { template!(NameValueStr: "deprecation message"), |this, cx, args| { reject_outside_std!(cx); - this.allowed_through_unstable_modules = - args.name_value().and_then(|i| i.value_as_str()) + let Some(nv) = args.name_value() else { + cx.expected_name_value(cx.attr_span, None); + return; + }; + let Some(value_str) = nv.value_as_str() else { + cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit())); + return; + }; + this.allowed_through_unstable_modules = Some(value_str); }, ), ]; @@ -247,7 +254,12 @@ pub(crate) fn parse_stability( let mut feature = None; let mut since = None; - for param in args.list()?.mixed() { + let ArgParser::List(list) = args else { + cx.expected_list(cx.attr_span); + return None; + }; + + for param in list.mixed() { let param_span = param.span(); let Some(param) = param.meta_item() else { cx.emit_err(session_diagnostics::UnsupportedLiteral { @@ -322,7 +334,13 @@ pub(crate) fn parse_unstability( let mut is_soft = false; let mut implied_by = None; let mut old_name = None; - for param in args.list()?.mixed() { + + let ArgParser::List(list) = args else { + cx.expected_list(cx.attr_span); + return None; + }; + + for param in list.mixed() { let Some(param) = param.meta_item() else { cx.emit_err(session_diagnostics::UnsupportedLiteral { span: param.span(), diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index cca621103b5d5..f040fed7162ff 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -285,6 +285,9 @@ pub fn check_builtin_meta_item( | sym::rustc_do_not_implement_via_object | sym::rustc_coinductive | sym::const_trait + | sym::stable + | sym::unstable + | sym::rustc_allowed_through_unstable_modules | sym::rustc_specialization_trait | sym::rustc_unsafe_specialization_marker | sym::rustc_allow_incoherent_impl diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr b/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr index 8ead943ffe3a1..f656aeaa16c7f 100644 --- a/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr +++ b/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr @@ -1,26 +1,38 @@ -error: malformed `unstable` attribute input +error[E0539]: malformed `unstable` attribute input --> $DIR/stability-attribute-sanity-4.rs:8:5 | LL | #[unstable] - | ^^^^^^^^^^^ help: must be of the form: `#[unstable(feature = "name", reason = "...", issue = "N")]` + | ^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[unstable(feature = "name", reason = "...", issue = "N")]` -error: malformed `unstable` attribute input +error[E0539]: malformed `unstable` attribute input --> $DIR/stability-attribute-sanity-4.rs:11:5 | LL | #[unstable = "b"] - | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[unstable(feature = "name", reason = "...", issue = "N")]` + | ^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[unstable(feature = "name", reason = "...", issue = "N")]` -error: malformed `stable` attribute input +error[E0539]: malformed `stable` attribute input --> $DIR/stability-attribute-sanity-4.rs:14:5 | LL | #[stable] - | ^^^^^^^^^ help: must be of the form: `#[stable(feature = "name", since = "version")]` + | ^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[stable(feature = "name", since = "version")]` -error: malformed `stable` attribute input +error[E0539]: malformed `stable` attribute input --> $DIR/stability-attribute-sanity-4.rs:17:5 | LL | #[stable = "a"] - | ^^^^^^^^^^^^^^^ help: must be of the form: `#[stable(feature = "name", since = "version")]` + | ^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[stable(feature = "name", since = "version")]` error[E0542]: missing 'since' --> $DIR/stability-attribute-sanity-4.rs:21:5 @@ -42,5 +54,5 @@ LL | #[deprecated = "a"] error: aborting due to 7 previous errors -Some errors have detailed explanations: E0542, E0543. -For more information about an error, try `rustc --explain E0542`. +Some errors have detailed explanations: E0539, E0542, E0543. +For more information about an error, try `rustc --explain E0539`. From 37480bc9e6fef8b2a455b07742a1ee4f364f972c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 21 Jul 2025 11:20:38 +0200 Subject: [PATCH 27/28] coretests/num: use ldexp instead of hard-coding a power of 2 --- library/coretests/tests/num/dec2flt/float.rs | 11 +++--- .../coretests/tests/num/flt2dec/estimator.rs | 4 ++- library/coretests/tests/num/flt2dec/mod.rs | 34 +++++-------------- library/coretests/tests/num/mod.rs | 21 ++++++++++++ 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/library/coretests/tests/num/dec2flt/float.rs b/library/coretests/tests/num/dec2flt/float.rs index 193d5887749ab..8bf4094ced72f 100644 --- a/library/coretests/tests/num/dec2flt/float.rs +++ b/library/coretests/tests/num/dec2flt/float.rs @@ -1,13 +1,14 @@ use core::num::dec2flt::float::RawFloat; +use crate::num::{ldexp_f32, ldexp_f64}; + // FIXME(f16_f128): enable on all targets once possible. #[test] #[cfg(target_has_reliable_f16)] fn test_f16_integer_decode() { assert_eq!(3.14159265359f16.integer_decode(), (1608, -9, 1)); assert_eq!((-8573.5918555f16).integer_decode(), (1072, 3, -1)); - #[cfg(not(miri))] // miri doesn't have powf16 - assert_eq!(2f16.powf(14.0).integer_decode(), (1 << 10, 4, 1)); + assert_eq!(crate::num::ldexp_f16(1.0, 14).integer_decode(), (1 << 10, 4, 1)); assert_eq!(0f16.integer_decode(), (0, -25, 1)); assert_eq!((-0f16).integer_decode(), (0, -25, -1)); assert_eq!(f16::INFINITY.integer_decode(), (1 << 10, 6, 1)); @@ -23,8 +24,7 @@ fn test_f16_integer_decode() { fn test_f32_integer_decode() { assert_eq!(3.14159265359f32.integer_decode(), (13176795, -22, 1)); assert_eq!((-8573.5918555f32).integer_decode(), (8779358, -10, -1)); - // Set 2^100 directly instead of using powf, because it doesn't guarantee precision - assert_eq!(1.2676506e30_f32.integer_decode(), (8388608, 77, 1)); + assert_eq!(ldexp_f32(1.0, 100).integer_decode(), (8388608, 77, 1)); assert_eq!(0f32.integer_decode(), (0, -150, 1)); assert_eq!((-0f32).integer_decode(), (0, -150, -1)); assert_eq!(f32::INFINITY.integer_decode(), (8388608, 105, 1)); @@ -40,8 +40,7 @@ fn test_f32_integer_decode() { fn test_f64_integer_decode() { assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906, -51, 1)); assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931, -39, -1)); - // Set 2^100 directly instead of using powf, because it doesn't guarantee precision - assert_eq!(1.2676506002282294e30_f64.integer_decode(), (4503599627370496, 48, 1)); + assert_eq!(ldexp_f64(1.0, 100).integer_decode(), (4503599627370496, 48, 1)); assert_eq!(0f64.integer_decode(), (0, -1075, 1)); assert_eq!((-0f64).integer_decode(), (0, -1075, -1)); assert_eq!(f64::INFINITY.integer_decode(), (4503599627370496, 972, 1)); diff --git a/library/coretests/tests/num/flt2dec/estimator.rs b/library/coretests/tests/num/flt2dec/estimator.rs index da203b5f3620e..f53282611f686 100644 --- a/library/coretests/tests/num/flt2dec/estimator.rs +++ b/library/coretests/tests/num/flt2dec/estimator.rs @@ -1,5 +1,7 @@ use core::num::flt2dec::estimator::*; +use crate::num::ldexp_f64; + #[test] fn test_estimate_scaling_factor() { macro_rules! assert_almost_eq { @@ -56,7 +58,7 @@ fn test_estimate_scaling_factor() { let step = if cfg!(miri) { 37 } else { 1 }; for i in (-1074..972).step_by(step) { - let expected = super::ldexp_f64(1.0, i).log10().ceil(); + let expected = ldexp_f64(1.0, i).log10().ceil(); assert_almost_eq!(estimate_scaling_factor(1, i as i16), expected as i16); } } diff --git a/library/coretests/tests/num/flt2dec/mod.rs b/library/coretests/tests/num/flt2dec/mod.rs index ce36db33d05f3..4e73bd1f12ee9 100644 --- a/library/coretests/tests/num/flt2dec/mod.rs +++ b/library/coretests/tests/num/flt2dec/mod.rs @@ -6,6 +6,8 @@ use core::num::fmt::{Formatted, Part}; use std::mem::MaybeUninit; use std::{fmt, str}; +use crate::num::{ldexp_f32, ldexp_f64}; + mod estimator; mod strategy { mod dragon; @@ -75,24 +77,6 @@ macro_rules! try_fixed { }) } -#[cfg(target_has_reliable_f16)] -fn ldexp_f16(a: f16, b: i32) -> f16 { - ldexp_f64(a as f64, b) as f16 -} - -fn ldexp_f32(a: f32, b: i32) -> f32 { - ldexp_f64(a as f64, b) as f32 -} - -fn ldexp_f64(a: f64, b: i32) -> f64 { - unsafe extern "C" { - fn ldexp(x: f64, n: i32) -> f64; - } - // SAFETY: assuming a correct `ldexp` has been supplied, the given arguments cannot possibly - // cause undefined behavior - unsafe { ldexp(a, b) } -} - fn check_exact(mut f: F, v: T, vstr: &str, expected: &[u8], expectedk: i16) where T: DecodableFloat, @@ -268,7 +252,7 @@ where // 10^2 * 0.31984375 // 10^2 * 0.32 // 10^2 * 0.3203125 - check_shortest!(f(ldexp_f16(1.0, 5)) => b"32", 2); + check_shortest!(f(crate::num::ldexp_f16(1.0, 5)) => b"32", 2); // 10^5 * 0.65472 // 10^5 * 0.65504 @@ -283,7 +267,7 @@ where // 10^-9 * 0 // 10^-9 * 0.59604644775390625 // 10^-8 * 0.11920928955078125 - let minf16 = ldexp_f16(1.0, -24); + let minf16 = crate::num::ldexp_f16(1.0, -24); check_shortest!(f(minf16) => b"6", -7); } @@ -292,7 +276,7 @@ pub fn f16_exact_sanity_test(mut f: F) where F: for<'a> FnMut(&Decoded, &'a mut [MaybeUninit], i16) -> (&'a [u8], i16), { - let minf16 = ldexp_f16(1.0, -24); + let minf16 = crate::num::ldexp_f16(1.0, -24); check_exact!(f(0.1f16) => b"999755859375 ", -1); check_exact!(f(0.5f16) => b"5 ", 0); @@ -642,7 +626,7 @@ where assert_eq!(to_string(f, f16::MAX, Minus, 1), "65500.0"); assert_eq!(to_string(f, f16::MAX, Minus, 8), "65500.00000000"); - let minf16 = ldexp_f16(1.0, -24); + let minf16 = crate::num::ldexp_f16(1.0, -24); assert_eq!(to_string(f, minf16, Minus, 0), "0.00000006"); assert_eq!(to_string(f, minf16, Minus, 8), "0.00000006"); assert_eq!(to_string(f, minf16, Minus, 9), "0.000000060"); @@ -766,7 +750,7 @@ where assert_eq!(to_string(f, f16::MAX, Minus, (-4, 4), false), "6.55e4"); assert_eq!(to_string(f, f16::MAX, Minus, (-5, 5), false), "65500"); - let minf16 = ldexp_f16(1.0, -24); + let minf16 = crate::num::ldexp_f16(1.0, -24); assert_eq!(to_string(f, minf16, Minus, (-2, 2), false), "6e-8"); assert_eq!(to_string(f, minf16, Minus, (-7, 7), false), "6e-8"); assert_eq!(to_string(f, minf16, Minus, (-8, 8), false), "0.00000006"); @@ -922,7 +906,7 @@ where assert_eq!(to_string(f, f16::MAX, Minus, 6, false), "6.55040e4"); assert_eq!(to_string(f, f16::MAX, Minus, 16, false), "6.550400000000000e4"); - let minf16 = ldexp_f16(1.0, -24); + let minf16 = crate::num::ldexp_f16(1.0, -24); assert_eq!(to_string(f, minf16, Minus, 1, false), "6e-8"); assert_eq!(to_string(f, minf16, Minus, 2, false), "6.0e-8"); assert_eq!(to_string(f, minf16, Minus, 4, false), "5.960e-8"); @@ -1229,7 +1213,7 @@ where #[cfg(target_has_reliable_f16)] { - let minf16 = ldexp_f16(1.0, -24); + let minf16 = crate::num::ldexp_f16(1.0, -24); assert_eq!(to_string(f, minf16, Minus, 0), "0"); assert_eq!(to_string(f, minf16, Minus, 1), "0.0"); assert_eq!(to_string(f, minf16, Minus, 2), "0.00"); diff --git a/library/coretests/tests/num/mod.rs b/library/coretests/tests/num/mod.rs index f340926292c88..54e54f734f647 100644 --- a/library/coretests/tests/num/mod.rs +++ b/library/coretests/tests/num/mod.rs @@ -54,6 +54,27 @@ macro_rules! assume_usize_width { } } +/// Return `a * 2^b`. +#[cfg(target_has_reliable_f16)] +fn ldexp_f16(a: f16, b: i32) -> f16 { + ldexp_f64(a as f64, b) as f16 +} + +/// Return `a * 2^b`. +fn ldexp_f32(a: f32, b: i32) -> f32 { + ldexp_f64(a as f64, b) as f32 +} + +/// Return `a * 2^b`. +fn ldexp_f64(a: f64, b: i32) -> f64 { + unsafe extern "C" { + fn ldexp(x: f64, n: i32) -> f64; + } + // SAFETY: assuming a correct `ldexp` has been supplied, the given arguments cannot possibly + // cause undefined behavior + unsafe { ldexp(a, b) } +} + /// Helper function for testing numeric operations pub fn test_num(ten: T, two: T) where From 371b01057bd31c6a42be2f691ccc22f46e8b291c Mon Sep 17 00:00:00 2001 From: usamoi Date: Sun, 20 Jul 2025 21:40:36 +0800 Subject: [PATCH 28/28] generate elf symbol version in raw-dylib --- .../src/back/link/raw_dylib.rs | 134 ++++++++++++++---- compiler/rustc_metadata/messages.ftl | 3 + compiler/rustc_metadata/src/errors.rs | 7 + compiler/rustc_metadata/src/native_libs.rs | 15 +- tests/ui/linkage-attr/raw-dylib/elf/empty.rs | 11 ++ .../raw-dylib/elf/glibc-x86_64.rs | 74 ++++++++++ .../raw-dylib/elf/malformed-link-name.rs | 20 +++ .../raw-dylib/elf/malformed-link-name.stderr | 26 ++++ 8 files changed, 261 insertions(+), 29 deletions(-) create mode 100644 tests/ui/linkage-attr/raw-dylib/elf/empty.rs create mode 100644 tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs create mode 100644 tests/ui/linkage-attr/raw-dylib/elf/malformed-link-name.rs create mode 100644 tests/ui/linkage-attr/raw-dylib/elf/malformed-link-name.stderr diff --git a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs index 74f39022afb7b..b9e0c95736331 100644 --- a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs +++ b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use rustc_abi::Endian; use rustc_data_structures::base_n::{CASE_INSENSITIVE, ToBaseN}; -use rustc_data_structures::fx::FxIndexMap; +use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_data_structures::stable_hasher::StableHasher; use rustc_hashes::Hash128; use rustc_session::Session; @@ -214,7 +214,7 @@ pub(super) fn create_raw_dylib_elf_stub_shared_objects<'a>( /// It exports all the provided symbols, but is otherwise empty. fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]) -> Vec { use object::write::elf as write; - use object::{Architecture, elf}; + use object::{AddressSize, Architecture, elf}; let mut stub_buf = Vec::new(); @@ -226,54 +226,94 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport] // It is important that the order of reservation matches the order of writing. // The object crate contains many debug asserts that fire if you get this wrong. + let Some((arch, sub_arch)) = sess.target.object_architecture(&sess.unstable_target_features) + else { + sess.dcx().fatal(format!( + "raw-dylib is not supported for the architecture `{}`", + sess.target.arch + )); + }; + let endianness = match sess.target.options.endian { Endian::Little => object::Endianness::Little, Endian::Big => object::Endianness::Big, }; - let mut stub = write::Writer::new(endianness, true, &mut stub_buf); + + let is_64 = match arch.address_size() { + Some(AddressSize::U8 | AddressSize::U16 | AddressSize::U32) => false, + Some(AddressSize::U64) => true, + _ => sess.dcx().fatal(format!( + "raw-dylib is not supported for the architecture `{}`", + sess.target.arch + )), + }; + + let mut stub = write::Writer::new(endianness, is_64, &mut stub_buf); + + let mut vers = Vec::new(); + let mut vers_map = FxHashMap::default(); + let mut syms = Vec::new(); + + for symbol in symbols { + let symbol_name = symbol.name.as_str(); + if let Some((name, version_name)) = symbol_name.split_once('@') { + assert!(!version_name.contains('@')); + let dynstr = stub.add_dynamic_string(name.as_bytes()); + let ver = if let Some(&ver_id) = vers_map.get(version_name) { + ver_id + } else { + let id = vers.len(); + vers_map.insert(version_name, id); + let dynstr = stub.add_dynamic_string(version_name.as_bytes()); + vers.push((version_name, dynstr)); + id + }; + syms.push((name, dynstr, Some(ver))); + } else { + let dynstr = stub.add_dynamic_string(symbol_name.as_bytes()); + syms.push((symbol_name, dynstr, None)); + } + } + + let soname = stub.add_dynamic_string(soname.as_bytes()); // These initial reservations don't reserve any bytes in the binary yet, // they just allocate in the internal data structures. - // First, we crate the dynamic symbol table. It starts with a null symbol + // First, we create the dynamic symbol table. It starts with a null symbol // and then all the symbols and their dynamic strings. stub.reserve_null_dynamic_symbol_index(); - let dynstrs = symbols - .iter() - .map(|sym| { - stub.reserve_dynamic_symbol_index(); - (sym, stub.add_dynamic_string(sym.name.as_str().as_bytes())) - }) - .collect::>(); - - let soname = stub.add_dynamic_string(soname.as_bytes()); + for _ in syms.iter() { + stub.reserve_dynamic_symbol_index(); + } // Reserve the sections. // We have the minimal sections for a dynamic SO and .text where we point our dummy symbols to. stub.reserve_shstrtab_section_index(); let text_section_name = stub.add_section_name(".text".as_bytes()); let text_section = stub.reserve_section_index(); - stub.reserve_dynstr_section_index(); stub.reserve_dynsym_section_index(); + stub.reserve_dynstr_section_index(); + if !vers.is_empty() { + stub.reserve_gnu_versym_section_index(); + stub.reserve_gnu_verdef_section_index(); + } stub.reserve_dynamic_section_index(); // These reservations now determine the actual layout order of the object file. stub.reserve_file_header(); stub.reserve_shstrtab(); stub.reserve_section_headers(); - stub.reserve_dynstr(); stub.reserve_dynsym(); + stub.reserve_dynstr(); + if !vers.is_empty() { + stub.reserve_gnu_versym(); + stub.reserve_gnu_verdef(1 + vers.len(), 1 + vers.len()); + } stub.reserve_dynamic(2); // DT_SONAME, DT_NULL // First write the ELF header with the arch information. - let Some((arch, sub_arch)) = sess.target.object_architecture(&sess.unstable_target_features) - else { - sess.dcx().fatal(format!( - "raw-dylib is not supported for the architecture `{}`", - sess.target.arch - )); - }; let e_machine = match (arch, sub_arch) { (Architecture::Aarch64, None) => elf::EM_AARCH64, (Architecture::Aarch64_Ilp32, None) => elf::EM_AARCH64, @@ -342,18 +382,19 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport] sh_addralign: 1, sh_entsize: 0, }); - stub.write_dynstr_section_header(0); stub.write_dynsym_section_header(0, 1); + stub.write_dynstr_section_header(0); + if !vers.is_empty() { + stub.write_gnu_versym_section_header(0); + stub.write_gnu_verdef_section_header(0); + } stub.write_dynamic_section_header(0); - // .dynstr - stub.write_dynstr(); - // .dynsym stub.write_null_dynamic_symbol(); - for (_, name) in dynstrs { + for (_name, dynstr, _ver) in syms.iter().copied() { stub.write_dynamic_symbol(&write::Sym { - name: Some(name), + name: Some(dynstr), st_info: (elf::STB_GLOBAL << 4) | elf::STT_NOTYPE, st_other: elf::STV_DEFAULT, section: Some(text_section), @@ -363,10 +404,47 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport] }); } + // .dynstr + stub.write_dynstr(); + + // ld.bfd is unhappy if these sections exist without any symbols, so we only generate them when necessary. + if !vers.is_empty() { + // .gnu_version + stub.write_null_gnu_versym(); + for (_name, _dynstr, ver) in syms.iter().copied() { + stub.write_gnu_versym(if let Some(ver) = ver { + assert!((2 + ver as u16) < elf::VERSYM_HIDDEN); + elf::VERSYM_HIDDEN | (2 + ver as u16) + } else { + 1 + }); + } + + // .gnu_version_d + stub.write_align_gnu_verdef(); + stub.write_gnu_verdef(&write::Verdef { + version: elf::VER_DEF_CURRENT, + flags: elf::VER_FLG_BASE, + index: 1, + aux_count: 1, + name: soname, + }); + for (ver, (_name, dynstr)) in vers.into_iter().enumerate() { + stub.write_gnu_verdef(&write::Verdef { + version: elf::VER_DEF_CURRENT, + flags: 0, + index: 2 + ver as u16, + aux_count: 1, + name: dynstr, + }); + } + } + // .dynamic // the DT_SONAME will be used by the linker to populate DT_NEEDED // which the loader uses to find the library. // DT_NULL terminates the .dynamic table. + stub.write_align_dynamic(); stub.write_dynamic_string(elf::DT_SONAME, soname); stub.write_dynamic(elf::DT_NULL, 0); diff --git a/compiler/rustc_metadata/messages.ftl b/compiler/rustc_metadata/messages.ftl index 3bef5ca114b89..4d3e879a098f6 100644 --- a/compiler/rustc_metadata/messages.ftl +++ b/compiler/rustc_metadata/messages.ftl @@ -330,3 +330,6 @@ metadata_wasm_import_form = metadata_whole_archive_needs_static = linking modifier `whole-archive` is only compatible with `static` linking kind + +metadata_raw_dylib_malformed = + link name must be well-formed if link kind is `raw-dylib` diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 4a3b43167cfa4..0332dba1077cd 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -815,3 +815,10 @@ pub struct AsyncDropTypesInDependency { pub extern_crate: Symbol, pub local_crate: Symbol, } + +#[derive(Diagnostic)] +#[diag(metadata_raw_dylib_malformed)] +pub struct RawDylibMalformed { + #[primary_span] + pub span: Span, +} diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 4d276f814ef25..ed0f084ea83c9 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -700,8 +700,21 @@ impl<'tcx> Collector<'tcx> { .link_ordinal .map_or(import_name_type, |ord| Some(PeImportNameType::Ordinal(ord))); + let name = codegen_fn_attrs.link_name.unwrap_or_else(|| self.tcx.item_name(item)); + + if self.tcx.sess.target.binary_format == BinaryFormat::Elf { + let name = name.as_str(); + if name.contains('\0') { + self.tcx.dcx().emit_err(errors::RawDylibMalformed { span }); + } else if let Some((left, right)) = name.split_once('@') + && (left.is_empty() || right.is_empty() || right.contains('@')) + { + self.tcx.dcx().emit_err(errors::RawDylibMalformed { span }); + } + } + DllImport { - name: codegen_fn_attrs.link_name.unwrap_or_else(|| self.tcx.item_name(item)), + name, import_name_type, calling_convention, span, diff --git a/tests/ui/linkage-attr/raw-dylib/elf/empty.rs b/tests/ui/linkage-attr/raw-dylib/elf/empty.rs new file mode 100644 index 0000000000000..2e48a5f052697 --- /dev/null +++ b/tests/ui/linkage-attr/raw-dylib/elf/empty.rs @@ -0,0 +1,11 @@ +//@ only-x86_64-unknown-linux-gnu +//@ needs-dynamic-linking +//@ build-pass + +#![allow(incomplete_features)] +#![feature(raw_dylib_elf)] + +#[link(name = "hack", kind = "raw-dylib")] +unsafe extern "C" {} + +fn main() {} diff --git a/tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs b/tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs new file mode 100644 index 0000000000000..a923684d82061 --- /dev/null +++ b/tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs @@ -0,0 +1,74 @@ +//@ only-x86_64-unknown-linux-gnu +//@ needs-dynamic-linking +//@ run-pass +//@ compile-flags: -Cpanic=abort +//@ edition: 2024 + +#![allow(incomplete_features)] +#![feature(raw_dylib_elf)] +#![no_std] +#![no_main] + +use core::ffi::{c_char, c_int}; + +extern "C" fn callback( + _fpath: *const c_char, + _sb: *const (), + _tflag: c_int, + _ftwbuf: *const (), +) -> c_int { + 0 +} + +#[link(name = "libc.so.6", kind = "raw-dylib", modifiers = "+verbatim")] +unsafe extern "C" { + #[link_name = "nftw@GLIBC_2.2.5"] + unsafe fn nftw_2_2_5( + dirpath: *const c_char, + f: extern "C" fn(*const c_char, *const (), c_int, *const ()) -> c_int, + nopenfd: c_int, + flags: c_int, + ) -> c_int; + #[link_name = "nftw@GLIBC_2.3.3"] + unsafe fn nftw_2_3_3( + dirpath: *const c_char, + f: extern "C" fn(*const c_char, *const (), c_int, *const ()) -> c_int, + nopenfd: c_int, + flags: c_int, + ) -> c_int; + #[link_name = "exit@GLIBC_2.2.5"] + safe fn exit(status: i32) -> !; + unsafe fn __libc_start_main() -> c_int; +} + +#[unsafe(no_mangle)] +extern "C" fn main() -> ! { + unsafe { + // The old `nftw` does not check whether unknown flags are set. + let res = nftw_2_2_5(c".".as_ptr(), callback, 20, 1 << 30); + assert_eq!(res, 0); + } + unsafe { + // The new `nftw` does. + let res = nftw_2_3_3(c".".as_ptr(), callback, 20, 1 << 30); + assert_eq!(res, -1); + } + exit(0); +} + +#[cfg(not(test))] +#[panic_handler] +fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! { + exit(1); +} + +#[unsafe(no_mangle)] +extern "C" fn rust_eh_personality( + _version: i32, + _actions: i32, + _exception_class: u64, + _exception_object: *mut (), + _context: *mut (), +) -> i32 { + exit(1); +} diff --git a/tests/ui/linkage-attr/raw-dylib/elf/malformed-link-name.rs b/tests/ui/linkage-attr/raw-dylib/elf/malformed-link-name.rs new file mode 100644 index 0000000000000..46e3798284b25 --- /dev/null +++ b/tests/ui/linkage-attr/raw-dylib/elf/malformed-link-name.rs @@ -0,0 +1,20 @@ +//@ only-elf +//@ needs-dynamic-linking +//@ check-fail + +#![feature(raw_dylib_elf)] +#![allow(incomplete_features)] + +#[link(name = "libc.so.6", kind = "raw-dylib", modifiers = "+verbatim")] +unsafe extern "C" { + #[link_name = "exit@"] + pub safe fn exit_0(status: i32) -> !; //~ ERROR link name must be well-formed if link kind is `raw-dylib` + #[link_name = "@GLIBC_2.2.5"] + pub safe fn exit_1(status: i32) -> !; //~ ERROR link name must be well-formed if link kind is `raw-dylib` + #[link_name = "ex\0it@GLIBC_2.2.5"] + pub safe fn exit_2(status: i32) -> !; //~ ERROR link name must be well-formed if link kind is `raw-dylib` + #[link_name = "exit@@GLIBC_2.2.5"] + pub safe fn exit_3(status: i32) -> !; //~ ERROR link name must be well-formed if link kind is `raw-dylib` +} + +fn main() {} diff --git a/tests/ui/linkage-attr/raw-dylib/elf/malformed-link-name.stderr b/tests/ui/linkage-attr/raw-dylib/elf/malformed-link-name.stderr new file mode 100644 index 0000000000000..5a979e7a3b1af --- /dev/null +++ b/tests/ui/linkage-attr/raw-dylib/elf/malformed-link-name.stderr @@ -0,0 +1,26 @@ +error: link name must be well-formed if link kind is `raw-dylib` + --> $DIR/malformed-link-name.rs:11:5 + | +LL | pub safe fn exit_0(status: i32) -> !; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: link name must be well-formed if link kind is `raw-dylib` + --> $DIR/malformed-link-name.rs:13:5 + | +LL | pub safe fn exit_1(status: i32) -> !; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: link name must be well-formed if link kind is `raw-dylib` + --> $DIR/malformed-link-name.rs:15:5 + | +LL | pub safe fn exit_2(status: i32) -> !; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: link name must be well-formed if link kind is `raw-dylib` + --> $DIR/malformed-link-name.rs:17:5 + | +LL | pub safe fn exit_3(status: i32) -> !; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors +