Use TypeVisitor::BreakTy
in UnresolvedTypeFinder
This commit is contained in:
parent
44f7d8fcf6
commit
df6e87cc85
2 changed files with 4 additions and 11 deletions
|
@ -1,5 +1,3 @@
|
||||||
//! See the Book for more information.
|
|
||||||
|
|
||||||
pub use self::freshen::TypeFreshener;
|
pub use self::freshen::TypeFreshener;
|
||||||
pub use self::LateBoundRegionConversionTime::*;
|
pub use self::LateBoundRegionConversionTime::*;
|
||||||
pub use self::RegionVariableOrigin::*;
|
pub use self::RegionVariableOrigin::*;
|
||||||
|
@ -1334,9 +1332,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
let mut r = resolve::UnresolvedTypeFinder::new(self);
|
value.visit_with(&mut resolve::UnresolvedTypeFinder::new(self)).break_value()
|
||||||
value.visit_with(&mut r);
|
|
||||||
r.first_unresolved
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn probe_const_var(
|
pub fn probe_const_var(
|
||||||
|
|
|
@ -111,18 +111,16 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> {
|
||||||
/// involve some hashing and so forth).
|
/// involve some hashing and so forth).
|
||||||
pub struct UnresolvedTypeFinder<'a, 'tcx> {
|
pub struct UnresolvedTypeFinder<'a, 'tcx> {
|
||||||
infcx: &'a InferCtxt<'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> {
|
impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
|
||||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
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> {
|
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> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
let t = self.infcx.shallow_resolve(t);
|
let t = self.infcx.shallow_resolve(t);
|
||||||
if t.has_infer_types() {
|
if t.has_infer_types() {
|
||||||
|
@ -144,8 +142,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
self.first_unresolved = Some((t, ty_var_span));
|
ControlFlow::Break((t, ty_var_span))
|
||||||
ControlFlow::BREAK
|
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, visit its contents.
|
// Otherwise, visit its contents.
|
||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue