mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-14 07:53:24 +00:00
hir_typeck: use end_point
over BytePos
manipulations
Parser has error recovery for Unicode-confusables, which includes the right parentheses `)`. If a multi-byte right parentheses look-alike reaches the argument removal suggestion diagnostics, it would trigger an assertion because the diagnostics used `- BytePos(1)` which can land within a multi-byte codepoint. This is fixed by using `SourceMap::end_point` to find the final right delimiter codepoint, which correctly respects codepoint boundaries.
This commit is contained in:
parent
b589f86a09
commit
879bfd7ad0
@ -22,7 +22,7 @@ use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::{kw, Ident};
|
||||
use rustc_span::{sym, BytePos, Span, DUMMY_SP};
|
||||
use rustc_span::{sym, Span, DUMMY_SP};
|
||||
use rustc_trait_selection::error_reporting::infer::{FailureCode, ObligationCauseExt};
|
||||
use rustc_trait_selection::infer::InferCtxtExt;
|
||||
use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext};
|
||||
@ -1140,8 +1140,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
.get(arg_idx + 1)
|
||||
.map(|&(_, sp)| sp)
|
||||
.unwrap_or_else(|| {
|
||||
// Subtract one to move before `)`
|
||||
call_expr.span.with_lo(call_expr.span.hi() - BytePos(1))
|
||||
// Try to move before `)`. Note that `)` here is not necessarily
|
||||
// the latin right paren, it could be a Unicode-confusable that
|
||||
// looks like a `)`, so we must not use `- BytePos(1)`
|
||||
// manipulations here.
|
||||
self.tcx().sess.source_map().end_point(call_expr.span)
|
||||
});
|
||||
|
||||
// Include next comma
|
||||
|
Loading…
Reference in New Issue
Block a user