about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorJonathan Gruner <jogru0@gmail.com>2025-04-08 21:22:20 +0200
committerJonathan Gruner <jogru0@gmail.com>2025-04-08 21:22:20 +0200
commit6d71fc15d8983960745bf2f61ab74ca272f0585f (patch)
tree6d258a27c3ddc19906896ec1116f004f1018d087 /compiler
parentdf6254f7a204b383bd8346880247a68dc32cab32 (diff)
downloadrust-6d71fc15d8983960745bf2f61ab74ca272f0585f.tar.gz
rust-6d71fc15d8983960745bf2f61ab74ca272f0585f.zip
for large assignment lint, use the correct span for checking for duplicate lints
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_monomorphize/src/mono_checks/move_check.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs
index 946714e3e48..a484573f0d8 100644
--- a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs
+++ b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs
@@ -148,11 +148,7 @@ impl<'tcx> MoveCheckVisitor<'tcx> {
         span: Span,
     ) {
         let source_info = self.body.source_info(location);
-        for reported_span in &self.move_size_spans {
-            if reported_span.overlaps(span) {
-                return;
-            }
-        }
+
         let lint_root = source_info.scope.lint_root(&self.body.source_scopes);
         let Some(lint_root) = lint_root else {
             // This happens when the issue is in a function from a foreign crate that
@@ -172,6 +168,12 @@ impl<'tcx> MoveCheckVisitor<'tcx> {
             .map(|(_, call_site)| call_site)
             .unwrap_or(span);
 
+        for previously_reported_span in &self.move_size_spans {
+            if previously_reported_span.overlaps(reported_span) {
+                return;
+            }
+        }
+
         self.tcx.emit_node_span_lint(
             LARGE_ASSIGNMENTS,
             lint_root,
@@ -182,6 +184,7 @@ impl<'tcx> MoveCheckVisitor<'tcx> {
                 limit: limit as u64,
             },
         );
+
         self.move_size_spans.push(reported_span);
     }
 }