non_local_defs: be more precise about what needs to be moved

This commit is contained in:
Urgau 2024-05-15 14:08:28 +02:00
parent 402580bcd5
commit d3dfe14b53
13 changed files with 171 additions and 232 deletions

View file

@ -1337,8 +1337,7 @@ pub enum NonLocalDefinitionsDiag {
cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>, cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
const_anon: Option<Option<Span>>, const_anon: Option<Option<Span>>,
move_help: Span, move_help: Span,
self_ty: Span, may_move: Vec<Span>,
of_trait: Option<Span>,
has_trait: bool, has_trait: bool,
}, },
MacroRules { MacroRules {
@ -1361,8 +1360,7 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
cargo_update, cargo_update,
const_anon, const_anon,
move_help, move_help,
self_ty, may_move,
of_trait,
has_trait, has_trait,
} => { } => {
diag.primary_message(fluent::lint_non_local_definitions_impl); diag.primary_message(fluent::lint_non_local_definitions_impl);
@ -1376,10 +1374,10 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
} else { } else {
diag.note(fluent::lint_without_trait); diag.note(fluent::lint_without_trait);
} }
let mut ms = MultiSpan::from_span(move_help); let mut ms = MultiSpan::from_span(move_help);
ms.push_span_label(self_ty, fluent::lint_non_local_definitions_may_move); for sp in may_move {
if let Some(of_trait) = of_trait { ms.push_span_label(sp, fluent::lint_non_local_definitions_may_move);
ms.push_span_label(of_trait, fluent::lint_non_local_definitions_may_move);
} }
diag.span_help(ms, fluent::lint_help); diag.span_help(ms, fluent::lint_help);

View file

@ -1,3 +1,5 @@
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::HirId;
use rustc_hir::{def::DefKind, Body, Item, ItemKind, Node, TyKind}; use rustc_hir::{def::DefKind, Body, Item, ItemKind, Node, TyKind};
use rustc_hir::{Path, QPath}; use rustc_hir::{Path, QPath};
use rustc_infer::infer::InferCtxt; use rustc_infer::infer::InferCtxt;
@ -214,6 +216,29 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
None None
}; };
let mut collector = PathCollector { paths: Vec::new() };
collector.visit_ty(&impl_.self_ty);
if let Some(of_trait) = &impl_.of_trait {
collector.visit_trait_ref(of_trait);
}
collector.visit_generics(&impl_.generics);
let may_move: Vec<Span> = collector
.paths
.into_iter()
.filter_map(|path| {
if path_has_local_parent(&path, cx, parent, parent_parent) {
if let Some(args) = &path.segments.last().unwrap().args {
Some(path.span.until(args.span_ext))
} else {
Some(path.span)
}
} else {
None
}
})
.collect();
let const_anon = matches!(parent_def_kind, DefKind::Const | DefKind::Static { .. }) let const_anon = matches!(parent_def_kind, DefKind::Const | DefKind::Static { .. })
.then_some(span_for_const_anon_suggestion); .then_some(span_for_const_anon_suggestion);
@ -223,14 +248,13 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
NonLocalDefinitionsDiag::Impl { NonLocalDefinitionsDiag::Impl {
depth: self.body_depth, depth: self.body_depth,
move_help: item.span, move_help: item.span,
self_ty: impl_.self_ty.span,
of_trait: impl_.of_trait.map(|t| t.path.span),
body_kind_descr: cx.tcx.def_kind_descr(parent_def_kind, parent), body_kind_descr: cx.tcx.def_kind_descr(parent_def_kind, parent),
body_name: parent_opt_item_name body_name: parent_opt_item_name
.map(|s| s.to_ident_string()) .map(|s| s.to_ident_string())
.unwrap_or_else(|| "<unnameable>".to_string()), .unwrap_or_else(|| "<unnameable>".to_string()),
cargo_update: cargo_update(), cargo_update: cargo_update(),
const_anon, const_anon,
may_move,
has_trait: impl_.of_trait.is_some(), has_trait: impl_.of_trait.is_some(),
}, },
) )
@ -348,6 +372,18 @@ impl<'a, 'tcx, F: FnMut(DefId) -> bool> TypeFolder<TyCtxt<'tcx>>
} }
} }
/// Simple hir::Path collector
struct PathCollector<'tcx> {
paths: Vec<Path<'tcx>>,
}
impl<'tcx> Visitor<'tcx> for PathCollector<'tcx> {
fn visit_path(&mut self, path: &Path<'tcx>, _id: HirId) {
self.paths.push(path.clone()); // need to clone, bc of the restricted lifetime
intravisit::walk_path(self, path)
}
}
/// Given a path and a parent impl def id, this checks if the if parent resolution /// Given a path and a parent impl def id, this checks if the if parent resolution
/// def id correspond to the def id of the parent impl definition. /// def id correspond to the def id of the parent impl definition.
/// ///

View file

@ -11,9 +11,6 @@ help: move this `impl` block outside of the current constant `_IMPL_DEBUG`
| |
LL | non_local_macro::non_local_impl!(LocalStruct); 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: 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: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration = 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: 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>

View file

@ -13,10 +13,7 @@ help: move this `impl` block outside of the current constant `Z`
--> $DIR/consts.rs:13:5 --> $DIR/consts.rs:13:5
| |
LL | impl Uto for &Test {} LL | impl Uto for &Test {}
| ^^^^^---^^^^^-----^^^ | ^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration = 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: 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: `#[warn(non_local_definitions)]` on by default
@ -33,10 +30,7 @@ help: move this `impl` block outside of the current static `A`
--> $DIR/consts.rs:24:5 --> $DIR/consts.rs:24:5
| |
LL | impl Uto2 for Test {} LL | impl Uto2 for Test {}
| ^^^^^----^^^^^----^^^ | ^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration = 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: 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>
@ -52,10 +46,7 @@ help: move this `impl` block outside of the current constant `B`
--> $DIR/consts.rs:32:5 --> $DIR/consts.rs:32:5
| |
LL | impl Uto3 for Test {} LL | impl Uto3 for Test {}
| ^^^^^----^^^^^----^^^ | ^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration = 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: 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>
@ -69,10 +60,7 @@ LL | impl Test {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/consts.rs:43:5 --> $DIR/consts.rs:43:5
| |
LL | impl Test { LL | / impl Test {
| ^ ---- may need to be moved as well
| _____|
| |
LL | | LL | |
LL | | fn foo() {} LL | | fn foo() {}
LL | | } LL | | }
@ -89,10 +77,7 @@ LL | impl Test {
help: move this `impl` block outside of the current inline constant `<unnameable>` and up 2 bodies help: move this `impl` block outside of the current inline constant `<unnameable>` and up 2 bodies
--> $DIR/consts.rs:50:9 --> $DIR/consts.rs:50:9
| |
LL | impl Test { LL | / impl Test {
| ^ ---- may need to be moved as well
| _________|
| |
LL | | LL | |
LL | | fn hoo() {} LL | | fn hoo() {}
LL | | } LL | | }
@ -109,10 +94,7 @@ LL | impl Test {
help: move this `impl` block outside of the current constant `_` and up 2 bodies help: move this `impl` block outside of the current constant `_` and up 2 bodies
--> $DIR/consts.rs:59:9 --> $DIR/consts.rs:59:9
| |
LL | impl Test { LL | / impl Test {
| ^ ---- may need to be moved as well
| _________|
| |
LL | | LL | |
LL | | fn foo2() {} LL | | fn foo2() {}
LL | | } LL | | }
@ -132,10 +114,7 @@ help: move this `impl` block outside of the current closure `<unnameable>` and u
--> $DIR/consts.rs:72:9 --> $DIR/consts.rs:72:9
| |
LL | impl Uto9 for Test {} LL | impl Uto9 for Test {}
| ^^^^^----^^^^^----^^^ | ^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -150,10 +129,7 @@ help: move this `impl` block outside of the current constant expression `<unname
--> $DIR/consts.rs:79:9 --> $DIR/consts.rs:79:9
| |
LL | impl Uto10 for Test {} LL | impl Uto10 for Test {}
| ^^^^^-----^^^^^----^^^ | ^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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: 8 warnings emitted warning: 8 warnings emitted

View file

@ -9,11 +9,7 @@ LL | impl PartialEq<()> for Dog {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive-trait.rs:7:5 --> $DIR/exhaustive-trait.rs:7:5
| |
LL | impl PartialEq<()> for Dog { LL | / impl PartialEq<()> for Dog {
| ^ ------------- --- may need to be moved as well
| | |
| _____| may need to be moved as well
| |
LL | | LL | |
LL | | fn eq(&self, _: &()) -> bool { LL | | fn eq(&self, _: &()) -> bool {
LL | | todo!() LL | | todo!()
@ -34,11 +30,7 @@ LL | impl PartialEq<()> for &Dog {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive-trait.rs:14:5 --> $DIR/exhaustive-trait.rs:14:5
| |
LL | impl PartialEq<()> for &Dog { LL | / impl PartialEq<()> for &Dog {
| ^ ------------- ---- may need to be moved as well
| | |
| _____| may need to be moved as well
| |
LL | | LL | |
LL | | fn eq(&self, _: &()) -> bool { LL | | fn eq(&self, _: &()) -> bool {
LL | | todo!() LL | | todo!()
@ -58,11 +50,7 @@ LL | impl PartialEq<Dog> for () {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive-trait.rs:21:5 --> $DIR/exhaustive-trait.rs:21:5
| |
LL | impl PartialEq<Dog> for () { LL | / impl PartialEq<Dog> for () {
| ^ -------------- -- may need to be moved as well
| | |
| _____| may need to be moved as well
| |
LL | | LL | |
LL | | fn eq(&self, _: &Dog) -> bool { LL | | fn eq(&self, _: &Dog) -> bool {
LL | | todo!() LL | | todo!()
@ -82,11 +70,7 @@ LL | impl PartialEq<&Dog> for () {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive-trait.rs:28:5 --> $DIR/exhaustive-trait.rs:28:5
| |
LL | impl PartialEq<&Dog> for () { LL | / impl PartialEq<&Dog> for () {
| ^ --------------- -- may need to be moved as well
| | |
| _____| may need to be moved as well
| |
LL | | LL | |
LL | | fn eq(&self, _: &&Dog) -> bool { LL | | fn eq(&self, _: &&Dog) -> bool {
LL | | todo!() LL | | todo!()
@ -106,11 +90,7 @@ LL | impl PartialEq<Dog> for &Dog {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive-trait.rs:35:5 --> $DIR/exhaustive-trait.rs:35:5
| |
LL | impl PartialEq<Dog> for &Dog { LL | / impl PartialEq<Dog> for &Dog {
| ^ -------------- ---- may need to be moved as well
| | |
| _____| may need to be moved as well
| |
LL | | LL | |
LL | | fn eq(&self, _: &Dog) -> bool { LL | | fn eq(&self, _: &Dog) -> bool {
LL | | todo!() LL | | todo!()
@ -130,11 +110,7 @@ LL | impl PartialEq<&Dog> for &Dog {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive-trait.rs:42:5 --> $DIR/exhaustive-trait.rs:42:5
| |
LL | impl PartialEq<&Dog> for &Dog { LL | / impl PartialEq<&Dog> for &Dog {
| ^ --------------- ---- may need to be moved as well
| | |
| _____| may need to be moved as well
| |
LL | | LL | |
LL | | fn eq(&self, _: &&Dog) -> bool { LL | | fn eq(&self, _: &&Dog) -> bool {
LL | | todo!() LL | | todo!()

View file

@ -8,10 +8,7 @@ LL | impl Test {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:10:5 --> $DIR/exhaustive.rs:10:5
| |
LL | impl Test { LL | / impl Test {
| ^ ---- may need to be moved as well
| _____|
| |
LL | | LL | |
LL | | fn foo() {} LL | | fn foo() {}
LL | | } LL | | }
@ -30,11 +27,7 @@ LL | impl Display for Test {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:15:5 --> $DIR/exhaustive.rs:15:5
| |
LL | impl Display for Test { LL | / impl Display for Test {
| ^ ------- ---- may need to be moved as well
| | |
| _____| may need to be moved as well
| |
LL | | LL | |
LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
LL | | todo!() LL | | todo!()
@ -54,9 +47,7 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:22:5 --> $DIR/exhaustive.rs:22:5
| |
LL | impl dyn Trait {} LL | impl dyn Trait {}
| ^^^^^---------^^^ | ^^^^^^^^^^^^^^^^^
| |
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -71,10 +62,7 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:25:5 --> $DIR/exhaustive.rs:25:5
| |
LL | impl<T: Trait> Trait for Vec<T> { } LL | impl<T: Trait> Trait for Vec<T> { }
| ^^^^^^^^^^^^^^^-----^^^^^------^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -89,10 +77,7 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:28:5 --> $DIR/exhaustive.rs:28:5
| |
LL | impl Trait for &dyn Trait {} LL | impl Trait for &dyn Trait {}
| ^^^^^-----^^^^^----------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -107,10 +92,7 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:31:5 --> $DIR/exhaustive.rs:31:5
| |
LL | impl Trait for *mut Test {} LL | impl Trait for *mut Test {}
| ^^^^^-----^^^^^---------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -125,10 +107,7 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:34:5 --> $DIR/exhaustive.rs:34:5
| |
LL | impl Trait for *mut [Test] {} LL | impl Trait for *mut [Test] {}
| ^^^^^-----^^^^^-----------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -143,10 +122,7 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:37:5 --> $DIR/exhaustive.rs:37:5
| |
LL | impl Trait for [Test; 8] {} LL | impl Trait for [Test; 8] {}
| ^^^^^-----^^^^^---------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -161,10 +137,7 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:40:5 --> $DIR/exhaustive.rs:40:5
| |
LL | impl Trait for (Test,) {} LL | impl Trait for (Test,) {}
| ^^^^^-----^^^^^-------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -179,10 +152,7 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:43:5 --> $DIR/exhaustive.rs:43:5
| |
LL | impl Trait for fn(Test) -> () {} LL | impl Trait for fn(Test) -> () {}
| ^^^^^-----^^^^^--------------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -197,10 +167,7 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:46:5 --> $DIR/exhaustive.rs:46:5
| |
LL | impl Trait for fn() -> Test {} LL | impl Trait for fn() -> Test {}
| ^^^^^-----^^^^^------------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -215,10 +182,7 @@ help: move this `impl` block outside of the current closure `<unnameable>` and u
--> $DIR/exhaustive.rs:50:9 --> $DIR/exhaustive.rs:50:9
| |
LL | impl Trait for Test {} LL | impl Trait for Test {}
| ^^^^^-----^^^^^----^^^ | ^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -233,10 +197,9 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:58:5 --> $DIR/exhaustive.rs:58:5
| |
LL | impl Trait for *mut InsideMain {} LL | impl Trait for *mut InsideMain {}
| ^^^^^-----^^^^^---------------^^^ | ^^^^^^^^^^^^^^^^^^^^----------^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -251,10 +214,9 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:60:5 --> $DIR/exhaustive.rs:60:5
| |
LL | impl Trait for *mut [InsideMain] {} LL | impl Trait for *mut [InsideMain] {}
| ^^^^^-----^^^^^-----------------^^^ | ^^^^^^^^^^^^^^^^^^^^^----------^^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -269,10 +231,9 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:62:5 --> $DIR/exhaustive.rs:62:5
| |
LL | impl Trait for [InsideMain; 8] {} LL | impl Trait for [InsideMain; 8] {}
| ^^^^^-----^^^^^---------------^^^ | ^^^^^^^^^^^^^^^^----------^^^^^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -287,10 +248,9 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:64:5 --> $DIR/exhaustive.rs:64:5
| |
LL | impl Trait for (InsideMain,) {} LL | impl Trait for (InsideMain,) {}
| ^^^^^-----^^^^^-------------^^^ | ^^^^^^^^^^^^^^^^----------^^^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -305,10 +265,9 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:66:5 --> $DIR/exhaustive.rs:66:5
| |
LL | impl Trait for fn(InsideMain) -> () {} LL | impl Trait for fn(InsideMain) -> () {}
| ^^^^^-----^^^^^--------------------^^^ | ^^^^^^^^^^^^^^^^^^----------^^^^^^^^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -323,10 +282,9 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/exhaustive.rs:68:5 --> $DIR/exhaustive.rs:68:5
| |
LL | impl Trait for fn() -> InsideMain {} LL | impl Trait for fn() -> InsideMain {}
| ^^^^^-----^^^^^------------------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^----------^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -340,11 +298,7 @@ LL | impl Display for InsideMain {
help: move this `impl` block outside of the current function `inside_inside` and up 2 bodies help: move this `impl` block outside of the current function `inside_inside` and up 2 bodies
--> $DIR/exhaustive.rs:72:9 --> $DIR/exhaustive.rs:72:9
| |
LL | impl Display for InsideMain { LL | / impl Display for InsideMain {
| ^ ------- ---------- may need to be moved as well
| | |
| _________| may need to be moved as well
| |
LL | | LL | |
LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { LL | | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
LL | | todo!() LL | | todo!()
@ -363,10 +317,7 @@ LL | impl InsideMain {
help: move this `impl` block outside of the current function `inside_inside` and up 2 bodies help: move this `impl` block outside of the current function `inside_inside` and up 2 bodies
--> $DIR/exhaustive.rs:79:9 --> $DIR/exhaustive.rs:79:9
| |
LL | impl InsideMain { LL | / impl InsideMain {
| ^ ---------- may need to be moved as well
| _________|
| |
LL | | LL | |
LL | | fn bar() {} LL | | fn bar() {}
LL | | } LL | | }

View file

@ -9,11 +9,7 @@ LL | impl From<Cat> for () {
help: move this `impl` block outside of the current function `main` help: move this `impl` block outside of the current function `main`
--> $DIR/from-local-for-global.rs:8:5 --> $DIR/from-local-for-global.rs:8:5
| |
LL | impl From<Cat> for () { LL | / impl From<Cat> for () {
| ^ --------- -- may need to be moved as well
| | |
| _____| may need to be moved as well
| |
LL | | LL | |
LL | | fn from(_: Cat) -> () { LL | | fn from(_: Cat) -> () {
LL | | todo!() LL | | todo!()
@ -35,9 +31,8 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/from-local-for-global.rs:18:5 --> $DIR/from-local-for-global.rs:18:5
| |
LL | impl From<Wrap<Wrap<Elephant>>> for () { LL | impl From<Wrap<Wrap<Elephant>>> for () {
| ^ -------------------------- -- may need to be moved as well | ^ -------- may need to be moved as well
| | | | _____|
| _____| may need to be moved as well
| | | |
LL | | LL | |
LL | | fn from(_: Wrap<Wrap<Elephant>>) -> Self { LL | | fn from(_: Wrap<Wrap<Elephant>>) -> Self {
@ -59,10 +54,9 @@ help: move this `impl` block outside of the current function `only_global`
--> $DIR/from-local-for-global.rs:32:5 --> $DIR/from-local-for-global.rs:32:5
| |
LL | impl StillNonLocal for &Foo {} LL | impl StillNonLocal for &Foo {}
| ^^^^^-------------^^^^^----^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^---^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -77,9 +71,8 @@ help: move this `impl` block outside of the current function `same_function`
--> $DIR/from-local-for-global.rs:40:5 --> $DIR/from-local-for-global.rs:40:5
| |
LL | impl From<Local1> for GlobalSameFunction { LL | impl From<Local1> for GlobalSameFunction {
| ^ ------------ ------------------ may need to be moved as well | ^ ------ may need to be moved as well
| | | | _____|
| _____| may need to be moved as well
| | | |
LL | | LL | |
LL | | fn from(x: Local1) -> GlobalSameFunction { LL | | fn from(x: Local1) -> GlobalSameFunction {
@ -101,9 +94,8 @@ help: move this `impl` block outside of the current function `same_function`
--> $DIR/from-local-for-global.rs:48:5 --> $DIR/from-local-for-global.rs:48:5
| |
LL | impl From<Local2> for GlobalSameFunction { LL | impl From<Local2> for GlobalSameFunction {
| ^ ------------ ------------------ may need to be moved as well | ^ ------ may need to be moved as well
| | | | _____|
| _____| may need to be moved as well
| | | |
LL | | LL | |
LL | | fn from(x: Local2) -> GlobalSameFunction { LL | | fn from(x: Local2) -> GlobalSameFunction {

View file

@ -10,10 +10,9 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/generics.rs:9:5 --> $DIR/generics.rs:9:5
| |
LL | impl<T: Local> Global for Vec<T> { } LL | impl<T: Local> Global for Vec<T> { }
| ^^^^^^^^^^^^^^^------^^^^^------^^^^ | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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: `#[warn(non_local_definitions)]` on by default
@ -29,10 +28,9 @@ help: move this `impl` block outside of the current function `bad`
--> $DIR/generics.rs:20:5 --> $DIR/generics.rs:20:5
| |
LL | impl Uto7 for Test where Local: std::any::Any {} LL | impl Uto7 for Test where Local: std::any::Any {}
| ^^^^^----^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -47,10 +45,7 @@ help: move this `impl` block outside of the current function `bad`
--> $DIR/generics.rs:23:5 --> $DIR/generics.rs:23:5
| |
LL | impl<T> Uto8 for T {} LL | impl<T> Uto8 for T {}
| ^^^^^^^^----^^^^^-^^^ | ^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -65,9 +60,8 @@ help: move this `impl` block outside of the current function `fun`
--> $DIR/generics.rs:32:5 --> $DIR/generics.rs:32:5
| |
LL | impl Default for UwU<OwO> { LL | impl Default for UwU<OwO> {
| ^ ------- -------- may need to be moved as well | ^ --- may need to be moved as well
| | | | _____|
| _____| may need to be moved as well
| | | |
LL | | LL | |
LL | | fn default() -> Self { LL | | fn default() -> Self {
@ -89,9 +83,8 @@ help: move this `impl` block outside of the current function `meow`
--> $DIR/generics.rs:43:5 --> $DIR/generics.rs:43:5
| |
LL | impl AsRef<Cat> for () { LL | impl AsRef<Cat> for () {
| ^ ---------- -- may need to be moved as well | ^ --- may need to be moved as well
| | | | _____|
| _____| may need to be moved as well
| | | |
LL | | LL | |
LL | | fn as_ref(&self) -> &Cat { &Cat } LL | | fn as_ref(&self) -> &Cat { &Cat }
@ -111,9 +104,8 @@ help: move this `impl` block outside of the current function `fun2`
--> $DIR/generics.rs:54:5 --> $DIR/generics.rs:54:5
| |
LL | impl PartialEq<B> for G { LL | impl PartialEq<B> for G {
| ^ ------------ - may need to be moved as well | ^ - may need to be moved as well
| | | | _____|
| _____| may need to be moved as well
| | | |
LL | | LL | |
LL | | fn eq(&self, _: &B) -> bool { LL | | fn eq(&self, _: &B) -> bool {
@ -135,9 +127,8 @@ help: move this `impl` block outside of the current function `rawr`
--> $DIR/generics.rs:69:5 --> $DIR/generics.rs:69:5
| |
LL | impl From<Wrap<Wrap<Lion>>> for () { LL | impl From<Wrap<Wrap<Lion>>> for () {
| ^ ---------------------- -- may need to be moved as well | ^ ---- may need to be moved as well
| | | | _____|
| _____| may need to be moved as well
| | | |
LL | | LL | |
LL | | fn from(_: Wrap<Wrap<Lion>>) -> Self { LL | | fn from(_: Wrap<Wrap<Lion>>) -> Self {
@ -159,9 +150,8 @@ help: move this `impl` block outside of the current function `rawr`
--> $DIR/generics.rs:76:5 --> $DIR/generics.rs:76:5
| |
LL | impl From<()> for Wrap<Lion> { LL | impl From<()> for Wrap<Lion> {
| ^ -------- ---------- may need to be moved as well | ^ ---- may need to be moved as well
| | | | _____|
| _____| may need to be moved as well
| | | |
LL | | LL | |
LL | | fn from(_: ()) -> Self { LL | | fn from(_: ()) -> Self {

View file

@ -13,10 +13,7 @@ help: move this `impl` block outside of the current function `my_func`
--> $DIR/inside-macro_rules.rs:9:13 --> $DIR/inside-macro_rules.rs:9:13
| |
LL | impl MacroTrait for OutsideStruct {} LL | impl MacroTrait for OutsideStruct {}
| ^^^^^----------^^^^^-------------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
... ...
LL | m!(); LL | m!();
| ---- in this macro invocation | ---- in this macro invocation

View file

@ -0,0 +1,17 @@
//@ check-pass
trait Trait<T> {}
fn main() {
mod below {
pub struct Type<T>(T);
}
struct InsideMain;
trait HasFoo {}
impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
//~^ WARN non-local `impl` definition
where
T: HasFoo
{}
}

View file

@ -0,0 +1,28 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/suggest-moving-inner.rs:12:5
|
LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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
= 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`
help: move this `impl` block outside of the current function `main`
--> $DIR/suggest-moving-inner.rs:12:5
|
LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
| ^ ---------- ----------- ---------- may need to be moved as well
| | | |
| | | may need to be moved as well
| _____| may need to be moved as well
| |
LL | |
LL | | where
LL | | T: HasFoo
| | ------ may need to be moved as well
LL | | {}
| |______^
= 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
warning: 1 warning emitted

View file

@ -10,10 +10,9 @@ help: move this `impl` block outside of the current function `main`
--> $DIR/trait-solver-overflow-123573.rs:12:5 --> $DIR/trait-solver-overflow-123573.rs:12:5
| |
LL | impl Test for &Local {} LL | impl Test for &Local {}
| ^^^^^----^^^^^------^^^ | ^^^^^^^^^^^^^^^-----^^^
| | | | |
| | may need to be moved as well | may need to be moved as well
| may need to be moved as well
= 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: 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: `#[warn(non_local_definitions)]` on by default

View file

@ -10,10 +10,7 @@ help: move this `impl` block outside of the current constant expression `<unname
--> $DIR/weird-exprs.rs:8:5 --> $DIR/weird-exprs.rs:8:5
| |
LL | impl Uto for *mut Test {} LL | impl Uto for *mut Test {}
| ^^^^^---^^^^^---------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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: `#[warn(non_local_definitions)]` on by default
@ -29,10 +26,7 @@ help: move this `impl` block outside of the current constant expression `<unname
--> $DIR/weird-exprs.rs:16:9 --> $DIR/weird-exprs.rs:16:9
| |
LL | impl Uto for Test {} LL | impl Uto for Test {}
| ^^^^^---^^^^^----^^^ | ^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -45,10 +39,7 @@ LL | impl Test {
help: move this `impl` block outside of the current constant expression `<unnameable>` and up 2 bodies help: move this `impl` block outside of the current constant expression `<unnameable>` and up 2 bodies
--> $DIR/weird-exprs.rs:25:9 --> $DIR/weird-exprs.rs:25:9
| |
LL | impl Test { LL | / impl Test {
| ^ ---- may need to be moved as well
| _________|
| |
LL | | LL | |
LL | | fn bar() {} LL | | fn bar() {}
LL | | } LL | | }
@ -67,10 +58,7 @@ help: move this `impl` block outside of the current constant expression `<unname
--> $DIR/weird-exprs.rs:34:9 --> $DIR/weird-exprs.rs:34:9
| |
LL | impl Uto for &Test {} LL | impl Uto for &Test {}
| ^^^^^---^^^^^-----^^^ | ^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -85,10 +73,7 @@ help: move this `impl` block outside of the current constant expression `<unname
--> $DIR/weird-exprs.rs:41:9 --> $DIR/weird-exprs.rs:41:9
| |
LL | impl Uto for &(Test,) {} LL | impl Uto for &(Test,) {}
| ^^^^^---^^^^^--------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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 warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@ -103,10 +88,7 @@ help: move this `impl` block outside of the current constant expression `<unname
--> $DIR/weird-exprs.rs:48:9 --> $DIR/weird-exprs.rs:48:9
| |
LL | impl Uto for &(Test,Test) {} LL | impl Uto for &(Test,Test) {}
| ^^^^^---^^^^^------------^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | may need to be moved as well
| may need to be moved as well
= 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: 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: 6 warnings emitted warning: 6 warnings emitted