Remove implicit Continue
type
This commit is contained in:
parent
24e1a7e656
commit
9433eb83fe
@ -1498,7 +1498,7 @@ fn add_labels_for_types(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
|
impl<'tcx> ty::fold::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
if let Some((kind, def_id)) = TyCategory::from_ty(t) {
|
if let Some((kind, def_id)) = TyCategory::from_ty(t) {
|
||||||
let span = self.tcx.def_span(def_id);
|
let span = self.tcx.def_span(def_id);
|
||||||
// Avoid cluttering the output when the "found" and error span overlap:
|
// Avoid cluttering the output when the "found" and error span overlap:
|
||||||
|
@ -474,7 +474,7 @@ fn suggest_constrain_dyn_trait_in_impl(
|
|||||||
struct TraitObjectVisitor(Vec<DefId>);
|
struct TraitObjectVisitor(Vec<DefId>);
|
||||||
|
|
||||||
impl TypeVisitor<'_> for TraitObjectVisitor {
|
impl TypeVisitor<'_> for TraitObjectVisitor {
|
||||||
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<()> {
|
||||||
match t.kind() {
|
match t.kind() {
|
||||||
ty::Dynamic(preds, RegionKind::ReStatic) => {
|
ty::Dynamic(preds, RegionKind::ReStatic) => {
|
||||||
if let Some(def_id) = preds.principal_def_id() {
|
if let Some(def_id) = preds.principal_def_id() {
|
||||||
|
@ -741,7 +741,7 @@ struct ScopeInstantiator<'me, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
|
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ControlFlow<(), ()> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ControlFlow<()> {
|
||||||
self.target_index.shift_in(1);
|
self.target_index.shift_in(1);
|
||||||
t.super_visit_with(self);
|
t.super_visit_with(self);
|
||||||
self.target_index.shift_out(1);
|
self.target_index.shift_out(1);
|
||||||
@ -749,7 +749,7 @@ fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ControlF
|
|||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
let ScopeInstantiator { bound_region_scope, next_region, .. } = self;
|
let ScopeInstantiator { bound_region_scope, next_region, .. } = self;
|
||||||
|
|
||||||
match r {
|
match r {
|
||||||
|
@ -123,7 +123,7 @@ pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
let t = self.infcx.shallow_resolve(t);
|
let t = self.infcx.shallow_resolve(t);
|
||||||
if t.has_infer_types() {
|
if t.has_infer_types() {
|
||||||
if let ty::Infer(infer_ty) = *t.kind() {
|
if let ty::Infer(infer_ty) = *t.kind() {
|
||||||
|
@ -69,7 +69,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.predicate.visit_with(visitor)
|
self.predicate.visit_with(visitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1136,7 +1136,7 @@ struct ProhibitOpaqueTypes<'a, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> {
|
impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> {
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
ty::Opaque(..) => {
|
ty::Opaque(..) => {
|
||||||
self.ty = Some(ty);
|
self.ty = Some(ty);
|
||||||
|
@ -36,7 +36,7 @@ fn super_fold_with<__F: ::rustc_middle::ty::fold::TypeFolder<'tcx>>(
|
|||||||
fn super_visit_with<__F: ::rustc_middle::ty::fold::TypeVisitor<'tcx>>(
|
fn super_visit_with<__F: ::rustc_middle::ty::fold::TypeVisitor<'tcx>>(
|
||||||
&self,
|
&self,
|
||||||
__folder: &mut __F
|
__folder: &mut __F
|
||||||
) -> ::std::ops::ControlFlow<(), ()> {
|
) -> ::std::ops::ControlFlow<()> {
|
||||||
match *self { #body_visit }
|
match *self { #body_visit }
|
||||||
::std::ops::ControlFlow::CONTINUE
|
::std::ops::ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ fn super_fold_with<F: $crate::ty::fold::TypeFolder<$tcx>>(
|
|||||||
fn super_visit_with<F: $crate::ty::fold::TypeVisitor<$tcx>>(
|
fn super_visit_with<F: $crate::ty::fold::TypeVisitor<$tcx>>(
|
||||||
&self,
|
&self,
|
||||||
_: &mut F)
|
_: &mut F)
|
||||||
-> ::std::ops::ControlFlow<(), ()>
|
-> ::std::ops::ControlFlow<()>
|
||||||
{
|
{
|
||||||
::std::ops::ControlFlow::CONTINUE
|
::std::ops::ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ fn super_fold_with<V: $crate::ty::fold::TypeFolder<$tcx>>(
|
|||||||
fn super_visit_with<V: $crate::ty::fold::TypeVisitor<$tcx>>(
|
fn super_visit_with<V: $crate::ty::fold::TypeVisitor<$tcx>>(
|
||||||
&self,
|
&self,
|
||||||
visitor: &mut V,
|
visitor: &mut V,
|
||||||
) -> ::std::ops::ControlFlow<(), ()> {
|
) -> ::std::ops::ControlFlow<()> {
|
||||||
EnumTypeFoldableImpl!(@VisitVariants(self, visitor) input($($variants)*) output())
|
EnumTypeFoldableImpl!(@VisitVariants(self, visitor) input($($variants)*) output())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2489,7 +2489,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
UserTypeProjection { base, projs }
|
UserTypeProjection { base, projs }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> ControlFlow<(), ()> {
|
fn super_visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> ControlFlow<()> {
|
||||||
self.base.visit_with(visitor)
|
self.base.visit_with(visitor)
|
||||||
// Note: there's nothing in `self.proj` to visit.
|
// Note: there's nothing in `self.proj` to visit.
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
Terminator { source_info: self.source_info, kind }
|
Terminator { source_info: self.source_info, kind }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
use crate::mir::TerminatorKind::*;
|
use crate::mir::TerminatorKind::*;
|
||||||
|
|
||||||
match self.kind {
|
match self.kind {
|
||||||
@ -147,7 +147,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
|
|||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<()> {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
Place { local: self.local.fold_with(folder), projection: self.projection.fold_with(folder) }
|
Place { local: self.local.fold_with(folder), projection: self.projection.fold_with(folder) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.local.visit_with(visitor)?;
|
self.local.visit_with(visitor)?;
|
||||||
self.projection.visit_with(visitor)
|
self.projection.visit_with(visitor)
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
folder.tcx().intern_place_elems(&v)
|
folder.tcx().intern_place_elems(&v)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
use crate::mir::Rvalue::*;
|
use crate::mir::Rvalue::*;
|
||||||
match *self {
|
match *self {
|
||||||
Use(ref op) => op.visit_with(visitor),
|
Use(ref op) => op.visit_with(visitor),
|
||||||
@ -274,7 +274,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
match *self {
|
match *self {
|
||||||
Operand::Copy(ref place) | Operand::Move(ref place) => place.visit_with(visitor),
|
Operand::Copy(ref place) | Operand::Move(ref place) => place.visit_with(visitor),
|
||||||
Operand::Constant(ref c) => c.visit_with(visitor),
|
Operand::Constant(ref c) => c.visit_with(visitor),
|
||||||
@ -298,7 +298,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> ControlFlow<(), ()> {
|
fn super_visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> ControlFlow<()> {
|
||||||
use crate::mir::ProjectionElem::*;
|
use crate::mir::ProjectionElem::*;
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
@ -313,7 +313,7 @@ impl<'tcx> TypeFoldable<'tcx> for Field {
|
|||||||
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<()> {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal {
|
|||||||
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<()> {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,7 +331,7 @@ impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> {
|
|||||||
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
|
||||||
self.clone()
|
self.clone()
|
||||||
}
|
}
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<()> {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
literal: self.literal.fold_with(folder),
|
literal: self.literal.fold_with(folder),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.literal.visit_with(visitor)
|
self.literal.visit_with(visitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
self.super_fold_with(folder)
|
self.super_fold_with(folder)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()>;
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()>;
|
||||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.super_visit_with(visitor)
|
self.super_visit_with(visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,14 +144,11 @@ fn still_further_specializable(&self) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A visitor that does not recurse into types, works like `fn walk_shallow` in `Ty`.
|
/// A visitor that does not recurse into types, works like `fn walk_shallow` in `Ty`.
|
||||||
fn visit_tys_shallow(
|
fn visit_tys_shallow(&self, visit: impl FnMut(Ty<'tcx>) -> ControlFlow<()>) -> ControlFlow<()> {
|
||||||
&self,
|
|
||||||
visit: impl FnMut(Ty<'tcx>) -> ControlFlow<(), ()>,
|
|
||||||
) -> ControlFlow<(), ()> {
|
|
||||||
pub struct Visitor<F>(F);
|
pub struct Visitor<F>(F);
|
||||||
|
|
||||||
impl<'tcx, F: FnMut(Ty<'tcx>) -> ControlFlow<(), ()>> TypeVisitor<'tcx> for Visitor<F> {
|
impl<'tcx, F: FnMut(Ty<'tcx>) -> ControlFlow<()>> TypeVisitor<'tcx> for Visitor<F> {
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
self.0(ty)
|
self.0(ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,7 +161,7 @@ impl TypeFoldable<'tcx> for hir::Constness {
|
|||||||
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<()> {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,23 +195,23 @@ fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait TypeVisitor<'tcx>: Sized {
|
pub trait TypeVisitor<'tcx>: Sized {
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<(), ()> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<()> {
|
||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
r.super_visit_with(self)
|
r.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
c.super_visit_with(self)
|
c.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> ControlFlow<()> {
|
||||||
p.super_visit_with(self)
|
p.super_visit_with(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,17 +329,14 @@ impl<'tcx, F> TypeVisitor<'tcx> for RegionVisitor<F>
|
|||||||
where
|
where
|
||||||
F: FnMut(ty::Region<'tcx>) -> bool,
|
F: FnMut(ty::Region<'tcx>) -> bool,
|
||||||
{
|
{
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(
|
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<()> {
|
||||||
&mut self,
|
|
||||||
t: &Binder<T>,
|
|
||||||
) -> ControlFlow<(), ()> {
|
|
||||||
self.outer_index.shift_in(1);
|
self.outer_index.shift_in(1);
|
||||||
let result = t.as_ref().skip_binder().visit_with(self);
|
let result = t.as_ref().skip_binder().visit_with(self);
|
||||||
self.outer_index.shift_out(1);
|
self.outer_index.shift_out(1);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
match *r {
|
match *r {
|
||||||
ty::ReLateBound(debruijn, _) if debruijn < self.outer_index => {
|
ty::ReLateBound(debruijn, _) if debruijn < self.outer_index => {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
@ -357,7 +351,7 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
// We're only interested in types involving regions
|
// We're only interested in types involving regions
|
||||||
if ty.flags().intersects(TypeFlags::HAS_FREE_REGIONS) {
|
if ty.flags().intersects(TypeFlags::HAS_FREE_REGIONS) {
|
||||||
ty.super_visit_with(self)
|
ty.super_visit_with(self)
|
||||||
@ -849,14 +843,14 @@ struct HasEscapingVarsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<(), ()> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<()> {
|
||||||
self.outer_index.shift_in(1);
|
self.outer_index.shift_in(1);
|
||||||
let result = t.super_visit_with(self);
|
let result = t.super_visit_with(self);
|
||||||
self.outer_index.shift_out(1);
|
self.outer_index.shift_out(1);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
// If the outer-exclusive-binder is *strictly greater* than
|
// If the outer-exclusive-binder is *strictly greater* than
|
||||||
// `outer_index`, that means that `t` contains some content
|
// `outer_index`, that means that `t` contains some content
|
||||||
// bound at `outer_index` or above (because
|
// bound at `outer_index` or above (because
|
||||||
@ -869,7 +863,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
// If the region is bound by `outer_index` or anything outside
|
// If the region is bound by `outer_index` or anything outside
|
||||||
// of outer index, then it escapes the binders we have
|
// of outer index, then it escapes the binders we have
|
||||||
// visited.
|
// visited.
|
||||||
@ -880,7 +874,7 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
// we don't have a `visit_infer_const` callback, so we have to
|
// we don't have a `visit_infer_const` callback, so we have to
|
||||||
// hook in here to catch this case (annoying...), but
|
// hook in here to catch this case (annoying...), but
|
||||||
// otherwise we do want to remember to visit the rest of the
|
// otherwise we do want to remember to visit the rest of the
|
||||||
@ -892,7 +886,7 @@ fn visit_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<()> {
|
||||||
if predicate.inner.outer_exclusive_binder > self.outer_index {
|
if predicate.inner.outer_exclusive_binder > self.outer_index {
|
||||||
ControlFlow::BREAK
|
ControlFlow::BREAK
|
||||||
} else {
|
} else {
|
||||||
@ -907,7 +901,7 @@ struct HasTypeFlagsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
|
impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
|
||||||
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<()> {
|
||||||
debug!(
|
debug!(
|
||||||
"HasTypeFlagsVisitor: t={:?} t.flags={:?} self.flags={:?}",
|
"HasTypeFlagsVisitor: t={:?} t.flags={:?} self.flags={:?}",
|
||||||
t,
|
t,
|
||||||
@ -917,19 +911,19 @@ fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<(), ()> {
|
|||||||
if t.flags().intersects(self.flags) { ControlFlow::BREAK } else { ControlFlow::CONTINUE }
|
if t.flags().intersects(self.flags) { ControlFlow::BREAK } else { ControlFlow::CONTINUE }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
let flags = r.type_flags();
|
let flags = r.type_flags();
|
||||||
debug!("HasTypeFlagsVisitor: r={:?} r.flags={:?} self.flags={:?}", r, flags, self.flags);
|
debug!("HasTypeFlagsVisitor: r={:?} r.flags={:?} self.flags={:?}", r, flags, self.flags);
|
||||||
if flags.intersects(self.flags) { ControlFlow::BREAK } else { ControlFlow::CONTINUE }
|
if flags.intersects(self.flags) { ControlFlow::BREAK } else { ControlFlow::CONTINUE }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
let flags = FlagComputation::for_const(c);
|
let flags = FlagComputation::for_const(c);
|
||||||
debug!("HasTypeFlagsVisitor: c={:?} c.flags={:?} self.flags={:?}", c, flags, self.flags);
|
debug!("HasTypeFlagsVisitor: c={:?} c.flags={:?} self.flags={:?}", c, flags, self.flags);
|
||||||
if flags.intersects(self.flags) { ControlFlow::BREAK } else { ControlFlow::CONTINUE }
|
if flags.intersects(self.flags) { ControlFlow::BREAK } else { ControlFlow::CONTINUE }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<()> {
|
||||||
debug!(
|
debug!(
|
||||||
"HasTypeFlagsVisitor: predicate={:?} predicate.flags={:?} self.flags={:?}",
|
"HasTypeFlagsVisitor: predicate={:?} predicate.flags={:?} self.flags={:?}",
|
||||||
predicate, predicate.inner.flags, self.flags
|
predicate, predicate.inner.flags, self.flags
|
||||||
@ -969,14 +963,14 @@ fn new(just_constrained: bool) -> Self {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
|
impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<(), ()> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<()> {
|
||||||
self.current_index.shift_in(1);
|
self.current_index.shift_in(1);
|
||||||
let result = t.super_visit_with(self);
|
let result = t.super_visit_with(self);
|
||||||
self.current_index.shift_out(1);
|
self.current_index.shift_out(1);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
// if we are only looking for "constrained" region, we have to
|
// if we are only looking for "constrained" region, we have to
|
||||||
// ignore the inputs to a projection, as they may not appear
|
// ignore the inputs to a projection, as they may not appear
|
||||||
// in the normalized form
|
// in the normalized form
|
||||||
@ -989,7 +983,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
// if we are only looking for "constrained" region, we have to
|
// if we are only looking for "constrained" region, we have to
|
||||||
// ignore the inputs of an unevaluated const, as they may not appear
|
// ignore the inputs of an unevaluated const, as they may not appear
|
||||||
// in the normalized form
|
// in the normalized form
|
||||||
@ -1002,7 +996,7 @@ fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
c.super_visit_with(self)
|
c.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::ReLateBound(debruijn, br) = *r {
|
if let ty::ReLateBound(debruijn, br) = *r {
|
||||||
if debruijn == self.current_index {
|
if debruijn == self.current_index {
|
||||||
self.regions.insert(br);
|
self.regions.insert(br);
|
||||||
|
@ -1776,7 +1776,7 @@ fn super_fold_with<F: ty::fold::TypeFolder<'tcx>>(&self, folder: &mut F) -> Self
|
|||||||
ParamEnv::new(self.caller_bounds().fold_with(folder), self.reveal().fold_with(folder))
|
ParamEnv::new(self.caller_bounds().fold_with(folder), self.reveal().fold_with(folder))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.caller_bounds().visit_with(visitor)?;
|
self.caller_bounds().visit_with(visitor)?;
|
||||||
self.reveal().visit_with(visitor)
|
self.reveal().visit_with(visitor)
|
||||||
}
|
}
|
||||||
|
@ -1803,7 +1803,7 @@ fn prepare_late_bound_region_info<T>(&mut self, value: &ty::Binder<T>)
|
|||||||
{
|
{
|
||||||
struct LateBoundRegionNameCollector<'a>(&'a mut FxHashSet<Symbol>);
|
struct LateBoundRegionNameCollector<'a>(&'a mut FxHashSet<Symbol>);
|
||||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for LateBoundRegionNameCollector<'_> {
|
impl<'tcx> ty::fold::TypeVisitor<'tcx> for LateBoundRegionNameCollector<'_> {
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::ReLateBound(_, ty::BrNamed(_, name)) = *r {
|
if let ty::ReLateBound(_, ty::BrNamed(_, name)) = *r {
|
||||||
self.0.insert(name);
|
self.0.insert(name);
|
||||||
}
|
}
|
||||||
|
@ -728,7 +728,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> Self {
|
|||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<()> {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -738,7 +738,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> (T, U) {
|
|||||||
(self.0.fold_with(folder), self.1.fold_with(folder))
|
(self.0.fold_with(folder), self.1.fold_with(folder))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.0.visit_with(visitor)?;
|
self.0.visit_with(visitor)?;
|
||||||
self.1.visit_with(visitor)
|
self.1.visit_with(visitor)
|
||||||
}
|
}
|
||||||
@ -751,7 +751,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> (A, B, C) {
|
|||||||
(self.0.fold_with(folder), self.1.fold_with(folder), self.2.fold_with(folder))
|
(self.0.fold_with(folder), self.1.fold_with(folder), self.2.fold_with(folder))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.0.visit_with(visitor)?;
|
self.0.visit_with(visitor)?;
|
||||||
self.1.visit_with(visitor)?;
|
self.1.visit_with(visitor)?;
|
||||||
self.2.visit_with(visitor)
|
self.2.visit_with(visitor)
|
||||||
@ -777,7 +777,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
Rc::new((**self).fold_with(folder))
|
Rc::new((**self).fold_with(folder))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
(**self).visit_with(visitor)
|
(**self).visit_with(visitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -787,7 +787,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
Arc::new((**self).fold_with(folder))
|
Arc::new((**self).fold_with(folder))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
(**self).visit_with(visitor)
|
(**self).visit_with(visitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -798,7 +798,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
box content
|
box content
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
(**self).visit_with(visitor)
|
(**self).visit_with(visitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -808,7 +808,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
self.iter().map(|t| t.fold_with(folder)).collect()
|
self.iter().map(|t| t.fold_with(folder)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -818,7 +818,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
self.iter().map(|t| t.fold_with(folder)).collect::<Vec<_>>().into_boxed_slice()
|
self.iter().map(|t| t.fold_with(folder)).collect::<Vec<_>>().into_boxed_slice()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -832,11 +832,11 @@ fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
folder.fold_binder(self)
|
folder.fold_binder(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.as_ref().skip_binder().visit_with(visitor)
|
self.as_ref().skip_binder().visit_with(visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
visitor.visit_binder(self)
|
visitor.visit_binder(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -846,7 +846,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
fold_list(*self, folder, |tcx, v| tcx.intern_existential_predicates(v))
|
fold_list(*self, folder, |tcx, v| tcx.intern_existential_predicates(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.iter().try_for_each(|p| p.visit_with(visitor))
|
self.iter().try_for_each(|p| p.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -856,7 +856,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
fold_list(*self, folder, |tcx, v| tcx.intern_type_list(v))
|
fold_list(*self, folder, |tcx, v| tcx.intern_type_list(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -866,7 +866,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
fold_list(*self, folder, |tcx, v| tcx.intern_projs(v))
|
fold_list(*self, folder, |tcx, v| tcx.intern_projs(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -892,7 +892,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
use crate::ty::InstanceDef::*;
|
use crate::ty::InstanceDef::*;
|
||||||
self.substs.visit_with(visitor)?;
|
self.substs.visit_with(visitor)?;
|
||||||
match self.def {
|
match self.def {
|
||||||
@ -918,7 +918,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
Self { instance: self.instance.fold_with(folder), promoted: self.promoted }
|
Self { instance: self.instance.fold_with(folder), promoted: self.promoted }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.instance.visit_with(visitor)
|
self.instance.visit_with(visitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -967,7 +967,7 @@ fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
folder.fold_ty(*self)
|
folder.fold_ty(*self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
ty::RawPtr(ref tm) => tm.visit_with(visitor),
|
ty::RawPtr(ref tm) => tm.visit_with(visitor),
|
||||||
ty::Array(typ, sz) => {
|
ty::Array(typ, sz) => {
|
||||||
@ -1009,7 +1009,7 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
visitor.visit_ty(self)
|
visitor.visit_ty(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1023,11 +1023,11 @@ fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
folder.fold_region(*self)
|
folder.fold_region(*self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<()> {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
visitor.visit_region(*self)
|
visitor.visit_region(*self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1038,11 +1038,11 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
folder.tcx().reuse_or_mk_predicate(*self, new)
|
folder.tcx().reuse_or_mk_predicate(*self, new)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
ty::PredicateKind::super_visit_with(&self.inner.kind, visitor)
|
ty::PredicateKind::super_visit_with(&self.inner.kind, visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
visitor.visit_predicate(*self)
|
visitor.visit_predicate(*self)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1060,7 +1060,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
fold_list(*self, folder, |tcx, v| tcx.intern_predicates(v))
|
fold_list(*self, folder, |tcx, v| tcx.intern_predicates(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.iter().try_for_each(|p| p.visit_with(visitor))
|
self.iter().try_for_each(|p| p.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1070,7 +1070,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
self.iter().map(|x| x.fold_with(folder)).collect()
|
self.iter().map(|x| x.fold_with(folder)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1090,12 +1090,12 @@ fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
folder.fold_const(*self)
|
folder.fold_const(*self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.ty.visit_with(visitor)?;
|
self.ty.visit_with(visitor)?;
|
||||||
self.val.visit_with(visitor)
|
self.val.visit_with(visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
visitor.visit_const(self)
|
visitor.visit_const(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1115,7 +1115,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
match *self {
|
match *self {
|
||||||
ty::ConstKind::Infer(ic) => ic.visit_with(visitor),
|
ty::ConstKind::Infer(ic) => ic.visit_with(visitor),
|
||||||
ty::ConstKind::Param(p) => p.visit_with(visitor),
|
ty::ConstKind::Param(p) => p.visit_with(visitor),
|
||||||
@ -1133,7 +1133,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> Self {
|
|||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<()> {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
match self.unpack() {
|
match self.unpack() {
|
||||||
GenericArgKind::Lifetime(lt) => lt.visit_with(visitor),
|
GenericArgKind::Lifetime(lt) => lt.visit_with(visitor),
|
||||||
GenericArgKind::Type(ty) => ty.visit_with(visitor),
|
GenericArgKind::Type(ty) => ty.visit_with(visitor),
|
||||||
@ -392,7 +392,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<(), ()> {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
|
||||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ struct UsedParamsNeedSubstVisitor<'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for UsedParamsNeedSubstVisitor<'tcx> {
|
impl<'tcx> TypeVisitor<'tcx> for UsedParamsNeedSubstVisitor<'tcx> {
|
||||||
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
if !c.needs_subst() {
|
if !c.needs_subst() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
if !ty.needs_subst() {
|
if !ty.needs_subst() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>, _: TyContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
|
impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
|
||||||
fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<()> {
|
||||||
debug!("visit_const: c={:?}", c);
|
debug!("visit_const: c={:?}", c);
|
||||||
if !c.has_param_types_or_consts() {
|
if !c.has_param_types_or_consts() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
@ -283,7 +283,7 @@ fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
debug!("visit_ty: ty={:?}", ty);
|
debug!("visit_ty: ty={:?}", ty);
|
||||||
if !ty.has_param_types_or_consts() {
|
if !ty.has_param_types_or_consts() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
@ -318,7 +318,7 @@ struct HasUsedGenericParams<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a> {
|
impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a> {
|
||||||
fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<()> {
|
||||||
debug!("visit_const: c={:?}", c);
|
debug!("visit_const: c={:?}", c);
|
||||||
if !c.has_param_types_or_consts() {
|
if !c.has_param_types_or_consts() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
@ -336,7 +336,7 @@ fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
debug!("visit_ty: ty={:?}", ty);
|
debug!("visit_ty: ty={:?}", ty);
|
||||||
if !ty.has_param_types_or_consts() {
|
if !ty.has_param_types_or_consts() {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
|
@ -640,7 +640,7 @@ fn alloc_ids_from_const(val: ConstValue<'_>) -> impl Iterator<Item = AllocId> +
|
|||||||
}
|
}
|
||||||
struct CollectAllocIds(BTreeSet<AllocId>);
|
struct CollectAllocIds(BTreeSet<AllocId>);
|
||||||
impl<'tcx> TypeVisitor<'tcx> for CollectAllocIds {
|
impl<'tcx> TypeVisitor<'tcx> for CollectAllocIds {
|
||||||
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::ConstKind::Value(val) = c.val {
|
if let ty::ConstKind::Value(val) = c.val {
|
||||||
self.0.extend(alloc_ids_from_const(val));
|
self.0.extend(alloc_ids_from_const(val));
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ fn visit_def_id(
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
kind: &str,
|
kind: &str,
|
||||||
descr: &dyn fmt::Display,
|
descr: &dyn fmt::Display,
|
||||||
) -> ControlFlow<(), ()>;
|
) -> ControlFlow<()>;
|
||||||
|
|
||||||
/// Not overridden, but used to actually visit types and traits.
|
/// Not overridden, but used to actually visit types and traits.
|
||||||
fn skeleton(&mut self) -> DefIdVisitorSkeleton<'_, 'tcx, Self> {
|
fn skeleton(&mut self) -> DefIdVisitorSkeleton<'_, 'tcx, Self> {
|
||||||
@ -66,13 +66,13 @@ fn skeleton(&mut self) -> DefIdVisitorSkeleton<'_, 'tcx, Self> {
|
|||||||
dummy: Default::default(),
|
dummy: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn visit(&mut self, ty_fragment: impl TypeFoldable<'tcx>) -> ControlFlow<(), ()> {
|
fn visit(&mut self, ty_fragment: impl TypeFoldable<'tcx>) -> ControlFlow<()> {
|
||||||
ty_fragment.visit_with(&mut self.skeleton())
|
ty_fragment.visit_with(&mut self.skeleton())
|
||||||
}
|
}
|
||||||
fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow<()> {
|
||||||
self.skeleton().visit_trait(trait_ref)
|
self.skeleton().visit_trait(trait_ref)
|
||||||
}
|
}
|
||||||
fn visit_predicates(&mut self, predicates: ty::GenericPredicates<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_predicates(&mut self, predicates: ty::GenericPredicates<'tcx>) -> ControlFlow<()> {
|
||||||
self.skeleton().visit_predicates(predicates)
|
self.skeleton().visit_predicates(predicates)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,13 +87,13 @@ impl<'tcx, V> DefIdVisitorSkeleton<'_, 'tcx, V>
|
|||||||
where
|
where
|
||||||
V: DefIdVisitor<'tcx> + ?Sized,
|
V: DefIdVisitor<'tcx> + ?Sized,
|
||||||
{
|
{
|
||||||
fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow<()> {
|
||||||
let TraitRef { def_id, substs } = trait_ref;
|
let TraitRef { def_id, substs } = trait_ref;
|
||||||
self.def_id_visitor.visit_def_id(def_id, "trait", &trait_ref.print_only_trait_path())?;
|
self.def_id_visitor.visit_def_id(def_id, "trait", &trait_ref.print_only_trait_path())?;
|
||||||
if self.def_id_visitor.shallow() { ControlFlow::CONTINUE } else { substs.visit_with(self) }
|
if self.def_id_visitor.shallow() { ControlFlow::CONTINUE } else { substs.visit_with(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<()> {
|
||||||
match predicate.skip_binders() {
|
match predicate.skip_binders() {
|
||||||
ty::PredicateAtom::Trait(ty::TraitPredicate { trait_ref }, _) => {
|
ty::PredicateAtom::Trait(ty::TraitPredicate { trait_ref }, _) => {
|
||||||
self.visit_trait(trait_ref)
|
self.visit_trait(trait_ref)
|
||||||
@ -119,7 +119,7 @@ fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_predicates(&mut self, predicates: ty::GenericPredicates<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_predicates(&mut self, predicates: ty::GenericPredicates<'tcx>) -> ControlFlow<()> {
|
||||||
let ty::GenericPredicates { parent: _, predicates } = predicates;
|
let ty::GenericPredicates { parent: _, predicates } = predicates;
|
||||||
predicates.iter().try_for_each(|&(predicate, _span)| self.visit_predicate(predicate))
|
predicates.iter().try_for_each(|&(predicate, _span)| self.visit_predicate(predicate))
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ impl<'tcx, V> TypeVisitor<'tcx> for DefIdVisitorSkeleton<'_, 'tcx, V>
|
|||||||
where
|
where
|
||||||
V: DefIdVisitor<'tcx> + ?Sized,
|
V: DefIdVisitor<'tcx> + ?Sized,
|
||||||
{
|
{
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
let tcx = self.def_id_visitor.tcx();
|
let tcx = self.def_id_visitor.tcx();
|
||||||
// InternalSubsts are not visited here because they are visited below in `super_visit_with`.
|
// InternalSubsts are not visited here because they are visited below in `super_visit_with`.
|
||||||
match *ty.kind() {
|
match *ty.kind() {
|
||||||
@ -283,7 +283,7 @@ fn visit_def_id(
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
_kind: &str,
|
_kind: &str,
|
||||||
_descr: &dyn fmt::Display,
|
_descr: &dyn fmt::Display,
|
||||||
) -> ControlFlow<(), ()> {
|
) -> ControlFlow<()> {
|
||||||
self.min = VL::new_min(self, def_id);
|
self.min = VL::new_min(self, def_id);
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
@ -902,7 +902,7 @@ fn visit_def_id(
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
_kind: &str,
|
_kind: &str,
|
||||||
_descr: &dyn fmt::Display,
|
_descr: &dyn fmt::Display,
|
||||||
) -> ControlFlow<(), ()> {
|
) -> ControlFlow<()> {
|
||||||
if let Some(def_id) = def_id.as_local() {
|
if let Some(def_id) = def_id.as_local() {
|
||||||
if let (ty::Visibility::Public, _) | (_, Some(AccessLevel::ReachableFromImplTrait)) =
|
if let (ty::Visibility::Public, _) | (_, Some(AccessLevel::ReachableFromImplTrait)) =
|
||||||
(self.tcx().visibility(def_id.to_def_id()), self.access_level)
|
(self.tcx().visibility(def_id.to_def_id()), self.access_level)
|
||||||
@ -1079,7 +1079,7 @@ fn item_is_accessible(&self, did: DefId) -> bool {
|
|||||||
fn check_expr_pat_type(&mut self, id: hir::HirId, span: Span) -> bool {
|
fn check_expr_pat_type(&mut self, id: hir::HirId, span: Span) -> bool {
|
||||||
self.span = span;
|
self.span = span;
|
||||||
let typeck_results = self.typeck_results();
|
let typeck_results = self.typeck_results();
|
||||||
let result: ControlFlow<(), ()> = try {
|
let result: ControlFlow<()> = try {
|
||||||
self.visit(typeck_results.node_type(id))?;
|
self.visit(typeck_results.node_type(id))?;
|
||||||
self.visit(typeck_results.node_substs(id))?;
|
self.visit(typeck_results.node_substs(id))?;
|
||||||
if let Some(adjustments) = typeck_results.adjustments().get(id) {
|
if let Some(adjustments) = typeck_results.adjustments().get(id) {
|
||||||
@ -1297,7 +1297,7 @@ fn visit_def_id(
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
kind: &str,
|
kind: &str,
|
||||||
descr: &dyn fmt::Display,
|
descr: &dyn fmt::Display,
|
||||||
) -> ControlFlow<(), ()> {
|
) -> ControlFlow<()> {
|
||||||
if self.check_def_id(def_id, kind, descr) {
|
if self.check_def_id(def_id, kind, descr) {
|
||||||
ControlFlow::BREAK
|
ControlFlow::BREAK
|
||||||
} else {
|
} else {
|
||||||
@ -1797,7 +1797,7 @@ fn visit_def_id(
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
kind: &str,
|
kind: &str,
|
||||||
descr: &dyn fmt::Display,
|
descr: &dyn fmt::Display,
|
||||||
) -> ControlFlow<(), ()> {
|
) -> ControlFlow<()> {
|
||||||
if self.check_def_id(def_id, kind, descr) {
|
if self.check_def_id(def_id, kind, descr) {
|
||||||
ControlFlow::BREAK
|
ControlFlow::BREAK
|
||||||
} else {
|
} else {
|
||||||
|
@ -693,12 +693,12 @@ impl<'tcx, OP> TypeVisitor<'tcx> for ConstrainOpaqueTypeRegionVisitor<OP>
|
|||||||
where
|
where
|
||||||
OP: FnMut(ty::Region<'tcx>),
|
OP: FnMut(ty::Region<'tcx>),
|
||||||
{
|
{
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ControlFlow<(), ()> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ControlFlow<()> {
|
||||||
t.as_ref().skip_binder().visit_with(self);
|
t.as_ref().skip_binder().visit_with(self);
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
match *r {
|
match *r {
|
||||||
// ignore bound regions, keep visiting
|
// ignore bound regions, keep visiting
|
||||||
ty::ReLateBound(_, _) => ControlFlow::CONTINUE,
|
ty::ReLateBound(_, _) => ControlFlow::CONTINUE,
|
||||||
@ -709,7 +709,7 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
// We're only interested in types involving regions
|
// We're only interested in types involving regions
|
||||||
if !ty.flags().intersects(ty::TypeFlags::HAS_FREE_REGIONS) {
|
if !ty.flags().intersects(ty::TypeFlags::HAS_FREE_REGIONS) {
|
||||||
return ControlFlow::CONTINUE;
|
return ControlFlow::CONTINUE;
|
||||||
|
@ -571,15 +571,15 @@ pub fn walk_abstract_const<'tcx, F>(
|
|||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
ct: AbstractConst<'tcx>,
|
ct: AbstractConst<'tcx>,
|
||||||
mut f: F,
|
mut f: F,
|
||||||
) -> ControlFlow<(), ()>
|
) -> ControlFlow<()>
|
||||||
where
|
where
|
||||||
F: FnMut(Node<'tcx>) -> ControlFlow<(), ()>,
|
F: FnMut(Node<'tcx>) -> ControlFlow<()>,
|
||||||
{
|
{
|
||||||
fn recurse<'tcx>(
|
fn recurse<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
ct: AbstractConst<'tcx>,
|
ct: AbstractConst<'tcx>,
|
||||||
f: &mut dyn FnMut(Node<'tcx>) -> ControlFlow<(), ()>,
|
f: &mut dyn FnMut(Node<'tcx>) -> ControlFlow<()>,
|
||||||
) -> ControlFlow<(), ()> {
|
) -> ControlFlow<()> {
|
||||||
let root = ct.root();
|
let root = ct.root();
|
||||||
f(root)?;
|
f(root)?;
|
||||||
match root {
|
match root {
|
||||||
|
@ -771,7 +771,7 @@ struct IllegalSelfTypeVisitor<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for IllegalSelfTypeVisitor<'tcx> {
|
impl<'tcx> TypeVisitor<'tcx> for IllegalSelfTypeVisitor<'tcx> {
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
match t.kind() {
|
match t.kind() {
|
||||||
ty::Param(_) => {
|
ty::Param(_) => {
|
||||||
if t == self.tcx.types.self_param {
|
if t == self.tcx.types.self_param {
|
||||||
@ -812,7 +812,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_const(&mut self, ct: &ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, ct: &ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
// First check if the type of this constant references `Self`.
|
// First check if the type of this constant references `Self`.
|
||||||
self.visit_ty(ct.ty)?;
|
self.visit_ty(ct.ty)?;
|
||||||
|
|
||||||
@ -844,7 +844,7 @@ fn visit_const(&mut self, ct: &ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_predicate(&mut self, pred: ty::Predicate<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_predicate(&mut self, pred: ty::Predicate<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::PredicateAtom::ConstEvaluatable(def, substs) = pred.skip_binders() {
|
if let ty::PredicateAtom::ConstEvaluatable(def, substs) = pred.skip_binders() {
|
||||||
// FIXME(const_evaluatable_checked): We should probably deduplicate the logic for
|
// FIXME(const_evaluatable_checked): We should probably deduplicate the logic for
|
||||||
// `AbstractConst`s here, it might make sense to change `ConstEvaluatable` to
|
// `AbstractConst`s here, it might make sense to change `ConstEvaluatable` to
|
||||||
|
@ -135,7 +135,7 @@ fn type_marked_structural(&self, adt_ty: Ty<'tcx>) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
|
impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
debug!("Search visiting ty: {:?}", ty);
|
debug!("Search visiting ty: {:?}", ty);
|
||||||
|
|
||||||
let (adt_def, substs) = match *ty.kind() {
|
let (adt_def, substs) = match *ty.kind() {
|
||||||
|
@ -898,14 +898,14 @@ impl<'tcx> BoundVarsCollector<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
|
impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<(), ()> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<()> {
|
||||||
self.binder_index.shift_in(1);
|
self.binder_index.shift_in(1);
|
||||||
let result = t.super_visit_with(self);
|
let result = t.super_visit_with(self);
|
||||||
self.binder_index.shift_out(1);
|
self.binder_index.shift_out(1);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
match *t.kind() {
|
match *t.kind() {
|
||||||
ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => {
|
ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => {
|
||||||
match self.parameters.entry(bound_ty.var.as_u32()) {
|
match self.parameters.entry(bound_ty.var.as_u32()) {
|
||||||
@ -925,7 +925,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<()> {
|
||||||
match r {
|
match r {
|
||||||
ty::ReLateBound(index, br) if *index == self.binder_index => match br {
|
ty::ReLateBound(index, br) if *index == self.binder_index => match br {
|
||||||
ty::BoundRegion::BrNamed(def_id, _name) => {
|
ty::BoundRegion::BrNamed(def_id, _name) => {
|
||||||
@ -1115,7 +1115,7 @@ impl PlaceholdersCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector {
|
impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector {
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
match t.kind() {
|
match t.kind() {
|
||||||
ty::Placeholder(p) if p.universe == self.universe_index => {
|
ty::Placeholder(p) if p.universe == self.universe_index => {
|
||||||
self.next_ty_placeholder = self.next_ty_placeholder.max(p.name.as_usize() + 1);
|
self.next_ty_placeholder = self.next_ty_placeholder.max(p.name.as_usize() + 1);
|
||||||
@ -1127,7 +1127,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<()> {
|
||||||
match r {
|
match r {
|
||||||
ty::RePlaceholder(p) if p.universe == self.universe_index => {
|
ty::RePlaceholder(p) if p.universe == self.universe_index => {
|
||||||
if let ty::BoundRegion::BrAnon(anon) = p.name {
|
if let ty::BoundRegion::BrAnon(anon) = p.name {
|
||||||
|
@ -450,7 +450,7 @@ struct ProhibitOpaqueVisitor<'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
|
impl<'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
debug!("check_opaque_for_inheriting_lifetimes: (visit_ty) t={:?}", t);
|
debug!("check_opaque_for_inheriting_lifetimes: (visit_ty) t={:?}", t);
|
||||||
if t != self.opaque_identity_ty && t.super_visit_with(self).is_break() {
|
if t != self.opaque_identity_ty && t.super_visit_with(self).is_break() {
|
||||||
self.ty = Some(t);
|
self.ty = Some(t);
|
||||||
@ -459,7 +459,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
debug!("check_opaque_for_inheriting_lifetimes: (visit_region) r={:?}", r);
|
debug!("check_opaque_for_inheriting_lifetimes: (visit_region) r={:?}", r);
|
||||||
if let RegionKind::ReEarlyBound(ty::EarlyBoundRegion { index, .. }) = r {
|
if let RegionKind::ReEarlyBound(ty::EarlyBoundRegion { index, .. }) = r {
|
||||||
if *index < self.generics.parent_count as u32 {
|
if *index < self.generics.parent_count as u32 {
|
||||||
@ -472,7 +472,7 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
r.super_visit_with(self)
|
r.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::ConstKind::Unevaluated(..) = c.val {
|
if let ty::ConstKind::Unevaluated(..) = c.val {
|
||||||
// FIXME(#72219) We currenctly don't detect lifetimes within substs
|
// FIXME(#72219) We currenctly don't detect lifetimes within substs
|
||||||
// which would violate this check. Even though the particular substitution is not used
|
// which would violate this check. Even though the particular substitution is not used
|
||||||
@ -1455,7 +1455,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
|||||||
{
|
{
|
||||||
struct VisitTypes(Vec<DefId>);
|
struct VisitTypes(Vec<DefId>);
|
||||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for VisitTypes {
|
impl<'tcx> ty::fold::TypeVisitor<'tcx> for VisitTypes {
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
match *t.kind() {
|
match *t.kind() {
|
||||||
ty::Opaque(def, _) => {
|
ty::Opaque(def, _) => {
|
||||||
self.0.push(def);
|
self.0.push(def);
|
||||||
|
@ -983,7 +983,7 @@ fn suggest_constraining_param(
|
|||||||
struct TypeParamVisitor<'tcx>(Vec<Ty<'tcx>>);
|
struct TypeParamVisitor<'tcx>(Vec<Ty<'tcx>>);
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for TypeParamVisitor<'tcx> {
|
impl<'tcx> TypeVisitor<'tcx> for TypeParamVisitor<'tcx> {
|
||||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::Param(_) = ty.kind() {
|
if let ty::Param(_) = ty.kind() {
|
||||||
self.0.push(ty);
|
self.0.push(ty);
|
||||||
}
|
}
|
||||||
|
@ -800,18 +800,18 @@ struct CountParams {
|
|||||||
params: FxHashSet<u32>,
|
params: FxHashSet<u32>,
|
||||||
}
|
}
|
||||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams {
|
impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams {
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::Param(param) = t.kind() {
|
if let ty::Param(param) = t.kind() {
|
||||||
self.params.insert(param.index);
|
self.params.insert(param.index);
|
||||||
}
|
}
|
||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, _: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, _: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
ControlFlow::BREAK
|
ControlFlow::BREAK
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::ConstKind::Param(param) = c.val {
|
if let ty::ConstKind::Param(param) = c.val {
|
||||||
self.params.insert(param.index);
|
self.params.insert(param.index);
|
||||||
}
|
}
|
||||||
|
@ -2062,7 +2062,7 @@ struct TyAliasVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeVisitor<'tcx> for TyAliasVisitor<'a, 'tcx> {
|
impl<'a, 'tcx> TypeVisitor<'tcx> for TyAliasVisitor<'a, 'tcx> {
|
||||||
fn visit_const(&mut self, ct: &'tcx Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, ct: &'tcx Const<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::ConstKind::Unevaluated(def, substs, None) = ct.val {
|
if let ty::ConstKind::Unevaluated(def, substs, None) = ct.val {
|
||||||
self.preds.insert((
|
self.preds.insert((
|
||||||
ty::PredicateAtom::ConstEvaluatable(def, substs).to_predicate(self.tcx),
|
ty::PredicateAtom::ConstEvaluatable(def, substs).to_predicate(self.tcx),
|
||||||
|
@ -57,7 +57,7 @@ struct ParameterCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
|
impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
|
||||||
match *t.kind() {
|
match *t.kind() {
|
||||||
ty::Projection(..) | ty::Opaque(..) if !self.include_nonconstraining => {
|
ty::Projection(..) | ty::Opaque(..) if !self.include_nonconstraining => {
|
||||||
// projections are not injective
|
// projections are not injective
|
||||||
@ -72,14 +72,14 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<(), ()> {
|
|||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
|
||||||
if let ty::ReEarlyBound(data) = *r {
|
if let ty::ReEarlyBound(data) = *r {
|
||||||
self.parameters.push(Parameter::from(data));
|
self.parameters.push(Parameter::from(data));
|
||||||
}
|
}
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<(), ()> {
|
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<()> {
|
||||||
match c.val {
|
match c.val {
|
||||||
ty::ConstKind::Unevaluated(..) if !self.include_nonconstraining => {
|
ty::ConstKind::Unevaluated(..) if !self.include_nonconstraining => {
|
||||||
// Constant expressions are not injective
|
// Constant expressions are not injective
|
||||||
|
@ -559,7 +559,7 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Loca
|
|||||||
struct ContainsRegion;
|
struct ContainsRegion;
|
||||||
|
|
||||||
impl TypeVisitor<'_> for ContainsRegion {
|
impl TypeVisitor<'_> for ContainsRegion {
|
||||||
fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<(), ()> {
|
fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<()> {
|
||||||
ControlFlow::BREAK
|
ControlFlow::BREAK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user