about summary refs log tree commit diff
path: root/compiler/rustc_monomorphize/src
diff options
context:
space:
mode:
authorJonathan Gruner <jogru0@gmail.com>2025-04-08 20:49:50 +0200
committerJonathan Gruner <jogru0@gmail.com>2025-04-08 20:49:50 +0200
commitdf6254f7a204b383bd8346880247a68dc32cab32 (patch)
treea4f3c6107baf072de83f30027e0738c445dbfe29 /compiler/rustc_monomorphize/src
parentf820b75feef00654924c9351a2faca8d34818339 (diff)
report call site of inlined scopes for large assignment lints
Diffstat (limited to 'compiler/rustc_monomorphize/src')
-rw-r--r--compiler/rustc_monomorphize/src/mono_checks/move_check.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs
index 838bfdab1ea..946714e3e48 100644
--- a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs
+++ b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs
@@ -162,13 +162,27 @@ impl<'tcx> MoveCheckVisitor<'tcx> {
             // but correct span? This would make the lint at least accept crate-level lint attributes.
             return;
         };
+
+        // If the source scope is inlined by the MIR inliner, report the lint on the call site.
+        let reported_span = self
+            .body
+            .source_scopes
+            .get(source_info.scope)
+            .and_then(|source_scope_data| source_scope_data.inlined)
+            .map(|(_, call_site)| call_site)
+            .unwrap_or(span);
+
         self.tcx.emit_node_span_lint(
             LARGE_ASSIGNMENTS,
             lint_root,
-            span,
-            LargeAssignmentsLint { span, size: too_large_size.bytes(), limit: limit as u64 },
+            reported_span,
+            LargeAssignmentsLint {
+                span: reported_span,
+                size: too_large_size.bytes(),
+                limit: limit as u64,
+            },
         );
-        self.move_size_spans.push(span);
+        self.move_size_spans.push(reported_span);
     }
 }