Skip to content

Commit 452c14e

Browse files
committed
re-add explicit with_ctxt and tweak comments
1 parent 51a2ee3 commit 452c14e

File tree

1 file changed

+5
-4
lines changed
  • compiler/rustc_hir_typeck/src

1 file changed

+5
-4
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2783,14 +2783,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27832783
def_br_mutbl: Mutability,
27842784
) {
27852785
// Try to trim the span we're labeling to just the `&` or binding mode that's an issue.
2786-
// If the subpattern's span is is from an expansion, the emitted label will not be trimmed.
2787-
// Importantly, the edition of the trimmed span should be the same as `subpat.span`; this
2788-
// will be a hard error if the subpattern is of edition >= 2024.
27892786
let from_expansion = subpat.span.from_expansion();
27902787
let trimmed_span = if from_expansion {
2788+
// If the subpattern is from an expansion, highlight the whole macro call instead.
27912789
subpat.span
27922790
} else {
2793-
self.tcx.sess.source_map().span_through_char(subpat.span, final_char)
2791+
let trimmed = self.tcx.sess.source_map().span_through_char(subpat.span, final_char);
2792+
// The edition of the trimmed span should be the same as `subpat.span`; this will be a
2793+
// a hard error if the subpattern is of edition >= 2024. We set it manually to be sure:
2794+
trimmed.with_ctxt(subpat.span.ctxt())
27942795
};
27952796

27962797
let mut typeck_results = self.typeck_results.borrow_mut();

0 commit comments

Comments
 (0)