Skip to content

Commit 98033b2

Browse files
committed
Inline visit_spanned into visit and use the latter everywhere
1 parent f5f11e1 commit 98033b2

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

compiler/rustc_ty_utils/src/opaque_types.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rustc_trait_selection::traits::check_args_compatible;
1111
use std::ops::ControlFlow;
1212

1313
use crate::errors::{DuplicateArg, NotParam};
14+
use crate::sig_types::SpannedTypeVisitor;
1415

1516
struct OpaqueTypeCollector<'tcx> {
1617
tcx: TyCtxt<'tcx>,
@@ -35,13 +36,6 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
3536
})
3637
}
3738

38-
fn visit_spanned(&mut self, span: Span, value: impl TypeVisitable<TyCtxt<'tcx>>) {
39-
let old = self.span;
40-
self.span = Some(span);
41-
value.visit_with(self);
42-
self.span = old;
43-
}
44-
4539
fn parent_trait_ref(&self) -> Option<ty::TraitRef<'tcx>> {
4640
let parent = self.parent()?;
4741
if matches!(self.tcx.def_kind(parent), DefKind::Impl { .. }) {
@@ -162,7 +156,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
162156
.instantiate_identity_iter_copied()
163157
{
164158
trace!(?pred);
165-
self.visit_spanned(span, pred);
159+
self.visit(span, pred);
166160
}
167161
}
168162
Err(NotUniqueParam::NotParam(arg)) => {
@@ -183,10 +177,13 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
183177
}
184178
}
185179

186-
impl<'tcx> super::sig_types::SpannedTypeVisitor<'tcx> for OpaqueTypeCollector<'tcx> {
180+
impl<'tcx> SpannedTypeVisitor<'tcx> for OpaqueTypeCollector<'tcx> {
187181
#[instrument(skip(self), ret, level = "trace")]
188182
fn visit(&mut self, span: Span, value: impl TypeVisitable<TyCtxt<'tcx>>) -> ControlFlow<!> {
189-
self.visit_spanned(span, value);
183+
let old = self.span;
184+
self.span = Some(span);
185+
value.visit_with(self);
186+
self.span = old;
190187
ControlFlow::Continue(())
191188
}
192189
}
@@ -265,7 +262,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
265262
// would have to walk all generic parameters of an Adt, which can quickly
266263
// degenerate into looking at an exponential number of types.
267264
let ty = self.tcx.type_of(field.did).instantiate_identity();
268-
self.visit_spanned(self.tcx.def_span(field.did), ty);
265+
self.visit(self.tcx.def_span(field.did), ty);
269266
}
270267
}
271268
}
@@ -277,7 +274,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
277274

278275
struct ImplTraitInAssocTypeCollector<'tcx>(OpaqueTypeCollector<'tcx>);
279276

280-
impl<'tcx> super::sig_types::SpannedTypeVisitor<'tcx> for ImplTraitInAssocTypeCollector<'tcx> {
277+
impl<'tcx> SpannedTypeVisitor<'tcx> for ImplTraitInAssocTypeCollector<'tcx> {
281278
#[instrument(skip(self), ret, level = "trace")]
282279
fn visit(&mut self, span: Span, value: impl TypeVisitable<TyCtxt<'tcx>>) -> ControlFlow<!> {
283280
let old = self.0.span;

0 commit comments

Comments
 (0)