Rollup merge of #99140 - TaKO8Ki:implement-is-accessible-span, r=fee1-dead
Implement `SourceMap::is_span_accessible` This patch adds `SourceMap::is_span_accessible` and replaces `span_to_snippet(span).is_ok()` and `span_to_snippet(span).is_err()` with it. This removes a `&str` to `String` conversion.
This commit is contained in:
commit
9fc297a2ae
9 changed files with 16 additions and 16 deletions
|
@ -432,7 +432,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
|
|||
"`let` bindings require an \"irrefutable pattern\", like a `struct` or \
|
||||
an `enum` with only one variant",
|
||||
);
|
||||
if self.tcx.sess.source_map().span_to_snippet(span).is_ok() {
|
||||
if self.tcx.sess.source_map().is_span_accessible(span) {
|
||||
let semi_span = span.shrink_to_hi().with_lo(span.hi() - BytePos(1));
|
||||
let start_span = span.shrink_to_lo();
|
||||
let end_span = semi_span.shrink_to_lo();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue