Skip to content

Commit b5d4867

Browse files
committed
non_local_defs: move cargo update suggestion upper
1 parent c4c8bda commit b5d4867

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/rustc_lint/src/lints.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,9 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
13971397
diag.arg("macro_kind", macro_kind);
13981398
diag.note(fluent::lint_macro_to_change);
13991399
}
1400+
if let Some(cargo_update) = cargo_update {
1401+
diag.subdiagnostic(&diag.dcx, cargo_update);
1402+
}
14001403

14011404
if has_trait {
14021405
diag.note(fluent::lint_bounds);
@@ -1423,9 +1426,6 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
14231426
);
14241427
}
14251428

1426-
if let Some(cargo_update) = cargo_update {
1427-
diag.subdiagnostic(&diag.dcx, cargo_update);
1428-
}
14291429
if let Some(const_anon) = const_anon {
14301430
diag.note(fluent::lint_exception);
14311431
if let Some(const_anon) = const_anon {

tests/ui/lint/non-local-defs/cargo-update.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
99
| move the `impl` block outside of this constant `_IMPL_DEBUG`
1010
|
1111
= note: the macro `non_local_macro::non_local_impl` defines the non-local `impl`, and may need to be changed
12+
= note: the macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
1213
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
1314
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
14-
= note: the macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
1515
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
1616
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
1717
= note: `#[warn(non_local_definitions)]` on by default

0 commit comments

Comments
 (0)