mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
non_local_defs: improve exception note for impl and macro_rules!
- Remove wrong exception text for non-local macro_rules! - Simplify anonymous const exception note
This commit is contained in:
parent
22095fbd8d
commit
402580bcd5
@ -551,7 +551,7 @@ lint_non_local_definitions_impl = non-local `impl` definition, `impl` blocks sho
|
||||
.without_trait = methods and assoc const are still usable outside the current expression, only `impl Local` and `impl dyn Local` are local and only if the `Local` type is at the same nesting as the `impl` block
|
||||
.with_trait = 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`
|
||||
.bounds = `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
|
||||
.exception = anon-const (`const _: () = {"{"} ... {"}"}`) at top-level module and anon-const at the same nesting as the trait or type are consider to be transparent regarding the nesting level
|
||||
.exception = items in an anonymous const item (`const _: () = {"{"} ... {"}"}`) are treated as in the same scope as the anonymous const's declaration
|
||||
.const_anon = use a const-anon item to suppress this lint
|
||||
|
||||
lint_non_local_definitions_macro_rules = non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
|
||||
@ -563,7 +563,6 @@ lint_non_local_definitions_macro_rules = non-local `macro_rules!` definition, `#
|
||||
.help_doctest =
|
||||
remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() {"{"} ... {"}"}`
|
||||
.non_local = a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
.exception = one exception to the rule are anon-const (`const _: () = {"{"} ... {"}"}`) at top-level module
|
||||
|
||||
lint_non_local_definitions_may_move = may need to be moved as well
|
||||
|
||||
|
@ -1421,7 +1421,6 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
|
||||
}
|
||||
|
||||
diag.note(fluent::lint_non_local);
|
||||
diag.note(fluent::lint_exception);
|
||||
diag.note(fluent::lint_non_local_definitions_deprecation);
|
||||
|
||||
if let Some(cargo_update) = cargo_update {
|
||||
|
@ -6,7 +6,6 @@ LL | macro_rules! a_macro { () => {} }
|
||||
|
|
||||
= help: remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() { ... }`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
= note: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
|
@ -15,7 +15,7 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
|
||||
| may need to be moved as well
|
||||
| may need to be moved as well
|
||||
= 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`
|
||||
= note: anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type are consider to be transparent regarding the nesting level
|
||||
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
|
||||
= 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>
|
||||
= note: `#[warn(non_local_definitions)]` on by default
|
||||
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
@ -17,7 +17,7 @@ LL | impl Uto for &Test {}
|
||||
| | |
|
||||
| | may need to be moved as well
|
||||
| may need to be moved as well
|
||||
= note: anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type are consider to be transparent regarding the nesting level
|
||||
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
|
||||
= 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>
|
||||
= note: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
@ -37,7 +37,7 @@ LL | impl Uto2 for Test {}
|
||||
| | |
|
||||
| | may need to be moved as well
|
||||
| may need to be moved as well
|
||||
= note: anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type are consider to be transparent regarding the nesting level
|
||||
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
|
||||
@ -56,7 +56,7 @@ LL | impl Uto3 for Test {}
|
||||
| | |
|
||||
| | may need to be moved as well
|
||||
| may need to be moved as well
|
||||
= note: anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type are consider to be transparent regarding the nesting level
|
||||
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
|
||||
@ -117,7 +117,7 @@ LL | |
|
||||
LL | | fn foo2() {}
|
||||
LL | | }
|
||||
| |_________^
|
||||
= note: anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type are consider to be transparent regarding the nesting level
|
||||
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
|
||||
= 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>
|
||||
|
||||
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
|
||||
|
@ -6,7 +6,6 @@ LL | macro_rules! m0 { () => { } };
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `B`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
= note: `#[warn(non_local_definitions)]` on by default
|
||||
|
||||
@ -18,7 +17,6 @@ LL | non_local_macro::non_local_macro_rules!(my_macro);
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `_MACRO_EXPORT`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
= note: the macro `non_local_macro::non_local_macro_rules` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
|
||||
= note: this warning originates in the macro `non_local_macro::non_local_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@ -31,7 +29,6 @@ LL | macro_rules! m { () => { } };
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current function `main`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
|
||||
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
|
||||
@ -42,7 +39,6 @@ LL | macro_rules! m2 { () => { } };
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current associated function `bar` and up 2 bodies
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
|
||||
warning: 4 warnings emitted
|
||||
|
@ -19,7 +19,6 @@ LL | nested_macro_rules::outer_macro!(SecondStruct, SecondAttrStruct);
|
||||
|
|
||||
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current function `main`
|
||||
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
|
||||
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
|
||||
= 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>
|
||||
note: the lint level is defined here
|
||||
--> $DIR/nested-macro-rules.rs:8:9
|
||||
|
Loading…
Reference in New Issue
Block a user