Skip to content

Commit df6e87c

Browse files
Use TypeVisitor::BreakTy in UnresolvedTypeFinder
1 parent 44f7d8f commit df6e87c

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

compiler/rustc_infer/src/infer/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//! See the Book for more information.
2-
31
pub use self::freshen::TypeFreshener;
42
pub use self::LateBoundRegionConversionTime::*;
53
pub use self::RegionVariableOrigin::*;
@@ -1334,9 +1332,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13341332
where
13351333
T: TypeFoldable<'tcx>,
13361334
{
1337-
let mut r = resolve::UnresolvedTypeFinder::new(self);
1338-
value.visit_with(&mut r);
1339-
r.first_unresolved
1335+
value.visit_with(&mut resolve::UnresolvedTypeFinder::new(self)).break_value()
13401336
}
13411337

13421338
pub fn probe_const_var(

compiler/rustc_infer/src/infer/resolve.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,16 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> {
111111
/// involve some hashing and so forth).
112112
pub struct UnresolvedTypeFinder<'a, 'tcx> {
113113
infcx: &'a InferCtxt<'a, 'tcx>,
114-
115-
/// Used to find the type parameter name and location for error reporting.
116-
pub first_unresolved: Option<(Ty<'tcx>, Option<Span>)>,
117114
}
118115

119116
impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
120117
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
121-
UnresolvedTypeFinder { infcx, first_unresolved: None }
118+
UnresolvedTypeFinder { infcx }
122119
}
123120
}
124121

125122
impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
123+
type BreakTy = (Ty<'tcx>, Option<Span>);
126124
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
127125
let t = self.infcx.shallow_resolve(t);
128126
if t.has_infer_types() {
@@ -144,8 +142,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
144142
} else {
145143
None
146144
};
147-
self.first_unresolved = Some((t, ty_var_span));
148-
ControlFlow::BREAK
145+
ControlFlow::Break((t, ty_var_span))
149146
} else {
150147
// Otherwise, visit its contents.
151148
t.super_visit_with(self)

0 commit comments

Comments
 (0)