Use Span::eq_ctxt
method instead of .ctxt() == .ctxt()
This commit is contained in:
parent
2c3bb42ebd
commit
52c9906c4b
@ -667,7 +667,7 @@ fn trim_span_hi(span: Span, to_pos: BytePos) -> Span {
|
||||
fn fn_span<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Span {
|
||||
let fn_decl_span = tcx.def_span(def_id);
|
||||
if let Some(body_span) = hir_body(tcx, def_id).map(|hir_body| hir_body.value.span) {
|
||||
if fn_decl_span.ctxt() == body_span.ctxt() { fn_decl_span.to(body_span) } else { body_span }
|
||||
if fn_decl_span.eq_ctxt(body_span) { fn_decl_span.to(body_span) } else { body_span }
|
||||
} else {
|
||||
fn_decl_span
|
||||
}
|
||||
|
@ -803,7 +803,7 @@ fn non_exhaustive_match<'p, 'tcx>(
|
||||
let mut suggestion = None;
|
||||
let sm = cx.tcx.sess.source_map();
|
||||
match arms {
|
||||
[] if sp.ctxt() == expr_span.ctxt() => {
|
||||
[] if sp.eq_ctxt(expr_span) => {
|
||||
// Get the span for the empty match body `{}`.
|
||||
let (indentation, more) = if let Some(snippet) = sm.indentation_before(sp) {
|
||||
(format!("\n{}", snippet), " ")
|
||||
@ -830,7 +830,7 @@ fn non_exhaustive_match<'p, 'tcx>(
|
||||
" ".to_string()
|
||||
};
|
||||
let comma = if matches!(only.body.kind, hir::ExprKind::Block(..))
|
||||
&& only.span.ctxt() == only.body.span.ctxt()
|
||||
&& only.span.eq_ctxt(only.body.span)
|
||||
{
|
||||
""
|
||||
} else {
|
||||
@ -841,10 +841,10 @@ fn non_exhaustive_match<'p, 'tcx>(
|
||||
format!("{}{}{} => todo!()", comma, pre_indentation, pattern),
|
||||
));
|
||||
}
|
||||
[.., prev, last] if prev.span.ctxt() == last.span.ctxt() => {
|
||||
[.., prev, last] if prev.span.eq_ctxt(last.span) => {
|
||||
if let Ok(snippet) = sm.span_to_snippet(prev.span.between(last.span)) {
|
||||
let comma = if matches!(last.body.kind, hir::ExprKind::Block(..))
|
||||
&& last.span.ctxt() == last.body.span.ctxt()
|
||||
&& last.span.eq_ctxt(last.body.span)
|
||||
{
|
||||
""
|
||||
} else {
|
||||
|
@ -121,7 +121,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
|
||||
|
||||
let source_file = source_map.lookup_source_file(body_span.lo());
|
||||
let fn_sig_span = match some_fn_sig.filter(|fn_sig| {
|
||||
fn_sig.span.ctxt() == body_span.ctxt()
|
||||
fn_sig.span.eq_ctxt(body_span)
|
||||
&& Lrc::ptr_eq(&source_file, &source_map.lookup_source_file(fn_sig.span.lo()))
|
||||
}) {
|
||||
Some(fn_sig) => fn_sig.span.with_hi(body_span.lo()),
|
||||
|
@ -195,7 +195,7 @@ impl CoverageSpan {
|
||||
.expn_span
|
||||
.parent_callsite()
|
||||
.unwrap_or_else(|| bug!("macro must have a parent"))
|
||||
.ctxt() == body_span.ctxt()
|
||||
.eq_ctxt(body_span)
|
||||
{
|
||||
return Some(current_macro);
|
||||
}
|
||||
|
@ -1875,7 +1875,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||
let names = rib
|
||||
.bindings
|
||||
.iter()
|
||||
.filter(|(id, _)| id.span.ctxt() == label.span.ctxt())
|
||||
.filter(|(id, _)| id.span.eq_ctxt(label.span))
|
||||
.map(|(id, _)| id.name)
|
||||
.collect::<Vec<Symbol>>();
|
||||
|
||||
|
@ -537,6 +537,9 @@ impl Span {
|
||||
pub fn ctxt(self) -> SyntaxContext {
|
||||
self.data_untracked().ctxt
|
||||
}
|
||||
pub fn eq_ctxt(self, other: Span) -> bool {
|
||||
self.data_untracked().ctxt == other.data_untracked().ctxt
|
||||
}
|
||||
#[inline]
|
||||
pub fn with_ctxt(self, ctxt: SyntaxContext) -> Span {
|
||||
self.data_untracked().with_ctxt(ctxt)
|
||||
|
@ -1641,7 +1641,7 @@ impl Ident {
|
||||
|
||||
impl PartialEq for Ident {
|
||||
fn eq(&self, rhs: &Self) -> bool {
|
||||
self.name == rhs.name && self.span.ctxt() == rhs.span.ctxt()
|
||||
self.name == rhs.name && self.span.eq_ctxt(rhs.span)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user