Use TypeVisitor::BreakTy
in UnresolvedTypeFinder
This commit is contained in:
parent
44f7d8fcf6
commit
df6e87cc85
@ -1,5 +1,3 @@
|
||||
//! See the Book for more information.
|
||||
|
||||
pub use self::freshen::TypeFreshener;
|
||||
pub use self::LateBoundRegionConversionTime::*;
|
||||
pub use self::RegionVariableOrigin::*;
|
||||
@ -1334,9 +1332,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
||||
let mut r = resolve::UnresolvedTypeFinder::new(self);
|
||||
value.visit_with(&mut r);
|
||||
r.first_unresolved
|
||||
value.visit_with(&mut resolve::UnresolvedTypeFinder::new(self)).break_value()
|
||||
}
|
||||
|
||||
pub fn probe_const_var(
|
||||
|
@ -111,18 +111,16 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> {
|
||||
/// involve some hashing and so forth).
|
||||
pub struct UnresolvedTypeFinder<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
|
||||
/// Used to find the type parameter name and location for error reporting.
|
||||
pub first_unresolved: Option<(Ty<'tcx>, Option<Span>)>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
||||
UnresolvedTypeFinder { infcx, first_unresolved: None }
|
||||
UnresolvedTypeFinder { infcx }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
||||
type BreakTy = (Ty<'tcx>, Option<Span>);
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
let t = self.infcx.shallow_resolve(t);
|
||||
if t.has_infer_types() {
|
||||
@ -144,8 +142,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.first_unresolved = Some((t, ty_var_span));
|
||||
ControlFlow::BREAK
|
||||
ControlFlow::Break((t, ty_var_span))
|
||||
} else {
|
||||
// Otherwise, visit its contents.
|
||||
t.super_visit_with(self)
|
||||
|
Loading…
Reference in New Issue
Block a user