mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 18:53:39 +00:00
rustc_span: Optimize syntax context comparisons
Including comparisons with root context
This commit is contained in:
parent
d2012259ca
commit
e10a05dff3
@ -145,7 +145,7 @@ pub(super) fn check<'tcx>(
|
||||
if cast_from.kind() == cast_to.kind() && !in_external_macro(cx.sess(), expr.span) {
|
||||
if let Some(id) = path_to_local(cast_expr)
|
||||
&& let Some(span) = cx.tcx.hir().opt_span(id)
|
||||
&& span.ctxt() != cast_expr.span.ctxt()
|
||||
&& !span.eq_ctxt(cast_expr.span)
|
||||
{
|
||||
// Binding context is different than the identifiers context.
|
||||
// Weird macro wizardry could be involved here.
|
||||
|
@ -118,7 +118,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
|
||||
vis.visit_ty(impl_.self_ty);
|
||||
|
||||
for target in &vis.found {
|
||||
if item.span.ctxt() != target.span().ctxt() {
|
||||
if !item.span.eq_ctxt(target.span()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitReturn {
|
||||
_: LocalDefId,
|
||||
) {
|
||||
if (!matches!(kind, FnKind::Closure) && matches!(decl.output, FnRetTy::DefaultReturn(_)))
|
||||
|| span.ctxt() != body.value.span.ctxt()
|
||||
|| !span.eq_ctxt(body.value.span)
|
||||
|| in_external_macro(cx.sess(), span)
|
||||
{
|
||||
return;
|
||||
|
@ -67,7 +67,7 @@ pub(super) fn check<'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
if unwrap_arg.span.ctxt() != map_span.ctxt() {
|
||||
if !unwrap_arg.span.eq_ctxt(map_span) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user