Skip to content

Commit 26c590d

Browse files
committed
Improve fallback span for closure migration lint.
1 parent cd7f960 commit 26c590d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/rustc_typeck/src/check/upvar.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
655655
closure_body_span = closure_body_span.parent().unwrap_or(DUMMY_SP);
656656
}
657657

658-
let (sugg, app) =
658+
let (span, sugg, app) =
659659
match self.tcx.sess.source_map().span_to_snippet(closure_body_span) {
660660
Ok(s) => {
661661
let trimmed = s.trim_start();
@@ -667,9 +667,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
667667
} else {
668668
format!("{{ {}; {} }}", migration_string, s)
669669
};
670-
(sugg, Applicability::MachineApplicable)
670+
(closure_body_span, sugg, Applicability::MachineApplicable)
671671
}
672-
Err(_) => (migration_string.clone(), Applicability::HasPlaceholders),
672+
Err(_) => (closure_span, migration_string.clone(), Applicability::HasPlaceholders),
673673
};
674674

675675
let diagnostic_msg = format!(
@@ -678,7 +678,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
678678
);
679679

680680
diagnostics_builder.span_suggestion(
681-
closure_body_span,
681+
span,
682682
&diagnostic_msg,
683683
sugg,
684684
app,

0 commit comments

Comments
 (0)