visit_x_unambig
This commit is contained in:
parent
6833c27090
commit
2bdeff2fb8
27 changed files with 92 additions and 92 deletions
|
@ -987,7 +987,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
||||||
for found_did in found_dids {
|
for found_did in found_dids {
|
||||||
let mut traits = vec![];
|
let mut traits = vec![];
|
||||||
let mut hir_v = HirTraitObjectVisitor(&mut traits, *found_did);
|
let mut hir_v = HirTraitObjectVisitor(&mut traits, *found_did);
|
||||||
hir_v.visit_unambig_ty(self_ty);
|
hir_v.visit_ty_unambig(self_ty);
|
||||||
debug!("trait spans found: {:?}", traits);
|
debug!("trait spans found: {:?}", traits);
|
||||||
for span in &traits {
|
for span in &traits {
|
||||||
let mut multi_span: MultiSpan = vec![*span].into();
|
let mut multi_span: MultiSpan = vec![*span].into();
|
||||||
|
|
|
@ -3067,7 +3067,7 @@ impl<'hir> Ty<'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut my_visitor = MyVisitor(vec![]);
|
let mut my_visitor = MyVisitor(vec![]);
|
||||||
my_visitor.visit_unambig_ty(self);
|
my_visitor.visit_ty_unambig(self);
|
||||||
my_visitor.0
|
my_visitor.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -504,12 +504,12 @@ pub trait Visitor<'v>: Sized {
|
||||||
pub trait VisitorExt<'v>: Visitor<'v> {
|
pub trait VisitorExt<'v>: Visitor<'v> {
|
||||||
/// Extension trait method to visit types in unambiguous positions, this is not
|
/// Extension trait method to visit types in unambiguous positions, this is not
|
||||||
/// directly on the [`Visitor`] trait as this method should never be overridden.
|
/// directly on the [`Visitor`] trait as this method should never be overridden.
|
||||||
fn visit_unambig_ty(&mut self, t: &'v Ty<'v>) -> Self::Result {
|
fn visit_ty_unambig(&mut self, t: &'v Ty<'v>) -> Self::Result {
|
||||||
walk_unambig_ty(self, t)
|
walk_unambig_ty(self, t)
|
||||||
}
|
}
|
||||||
/// Extension trait method to visit consts in unambiguous positions, this is not
|
/// Extension trait method to visit consts in unambiguous positions, this is not
|
||||||
/// directly on the [`Visitor`] trait as this method should never be overridden.
|
/// directly on the [`Visitor`] trait as this method should never be overridden.
|
||||||
fn visit_unambig_const_arg(&mut self, c: &'v ConstArg<'v>) -> Self::Result {
|
fn visit_const_arg_unambig(&mut self, c: &'v ConstArg<'v>) -> Self::Result {
|
||||||
walk_const_arg(self, c)
|
walk_const_arg(self, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,12 +532,12 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
|
||||||
}
|
}
|
||||||
ItemKind::Static(ref typ, _, body) => {
|
ItemKind::Static(ref typ, _, body) => {
|
||||||
try_visit!(visitor.visit_id(item.hir_id()));
|
try_visit!(visitor.visit_id(item.hir_id()));
|
||||||
try_visit!(visitor.visit_unambig_ty(typ));
|
try_visit!(visitor.visit_ty_unambig(typ));
|
||||||
try_visit!(visitor.visit_nested_body(body));
|
try_visit!(visitor.visit_nested_body(body));
|
||||||
}
|
}
|
||||||
ItemKind::Const(ref typ, ref generics, body) => {
|
ItemKind::Const(ref typ, ref generics, body) => {
|
||||||
try_visit!(visitor.visit_id(item.hir_id()));
|
try_visit!(visitor.visit_id(item.hir_id()));
|
||||||
try_visit!(visitor.visit_unambig_ty(typ));
|
try_visit!(visitor.visit_ty_unambig(typ));
|
||||||
try_visit!(visitor.visit_generics(generics));
|
try_visit!(visitor.visit_generics(generics));
|
||||||
try_visit!(visitor.visit_nested_body(body));
|
try_visit!(visitor.visit_nested_body(body));
|
||||||
}
|
}
|
||||||
|
@ -568,7 +568,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
|
||||||
}
|
}
|
||||||
ItemKind::TyAlias(ref ty, ref generics) => {
|
ItemKind::TyAlias(ref ty, ref generics) => {
|
||||||
try_visit!(visitor.visit_id(item.hir_id()));
|
try_visit!(visitor.visit_id(item.hir_id()));
|
||||||
try_visit!(visitor.visit_unambig_ty(ty));
|
try_visit!(visitor.visit_ty_unambig(ty));
|
||||||
try_visit!(visitor.visit_generics(generics));
|
try_visit!(visitor.visit_generics(generics));
|
||||||
}
|
}
|
||||||
ItemKind::Enum(ref enum_definition, ref generics) => {
|
ItemKind::Enum(ref enum_definition, ref generics) => {
|
||||||
|
@ -590,7 +590,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
|
||||||
try_visit!(visitor.visit_id(item.hir_id()));
|
try_visit!(visitor.visit_id(item.hir_id()));
|
||||||
try_visit!(visitor.visit_generics(generics));
|
try_visit!(visitor.visit_generics(generics));
|
||||||
visit_opt!(visitor, visit_trait_ref, of_trait);
|
visit_opt!(visitor, visit_trait_ref, of_trait);
|
||||||
try_visit!(visitor.visit_unambig_ty(self_ty));
|
try_visit!(visitor.visit_ty_unambig(self_ty));
|
||||||
walk_list!(visitor, visit_impl_item_ref, *items);
|
walk_list!(visitor, visit_impl_item_ref, *items);
|
||||||
}
|
}
|
||||||
ItemKind::Struct(ref struct_definition, ref generics)
|
ItemKind::Struct(ref struct_definition, ref generics)
|
||||||
|
@ -647,7 +647,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(
|
||||||
walk_list!(visitor, visit_ident, param_names.iter().copied());
|
walk_list!(visitor, visit_ident, param_names.iter().copied());
|
||||||
}
|
}
|
||||||
ForeignItemKind::Static(ref typ, _, _) => {
|
ForeignItemKind::Static(ref typ, _, _) => {
|
||||||
try_visit!(visitor.visit_unambig_ty(typ));
|
try_visit!(visitor.visit_ty_unambig(typ));
|
||||||
}
|
}
|
||||||
ForeignItemKind::Type => (),
|
ForeignItemKind::Type => (),
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v LetStmt<'v>) -
|
||||||
try_visit!(visitor.visit_id(local.hir_id));
|
try_visit!(visitor.visit_id(local.hir_id));
|
||||||
try_visit!(visitor.visit_pat(local.pat));
|
try_visit!(visitor.visit_pat(local.pat));
|
||||||
visit_opt!(visitor, visit_block, local.els);
|
visit_opt!(visitor, visit_block, local.els);
|
||||||
visit_opt!(visitor, visit_unambig_ty, local.ty);
|
visit_opt!(visitor, visit_ty_unambig, local.ty);
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,7 +775,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
||||||
}
|
}
|
||||||
ExprKind::Repeat(ref element, ref count) => {
|
ExprKind::Repeat(ref element, ref count) => {
|
||||||
try_visit!(visitor.visit_expr(element));
|
try_visit!(visitor.visit_expr(element));
|
||||||
try_visit!(visitor.visit_unambig_const_arg(count));
|
try_visit!(visitor.visit_const_arg_unambig(count));
|
||||||
}
|
}
|
||||||
ExprKind::Struct(ref qpath, fields, ref optional_base) => {
|
ExprKind::Struct(ref qpath, fields, ref optional_base) => {
|
||||||
try_visit!(visitor.visit_qpath(qpath, expression.hir_id, expression.span));
|
try_visit!(visitor.visit_qpath(qpath, expression.hir_id, expression.span));
|
||||||
|
@ -806,7 +806,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
||||||
}
|
}
|
||||||
ExprKind::Cast(ref subexpression, ref typ) | ExprKind::Type(ref subexpression, ref typ) => {
|
ExprKind::Cast(ref subexpression, ref typ) | ExprKind::Type(ref subexpression, ref typ) => {
|
||||||
try_visit!(visitor.visit_expr(subexpression));
|
try_visit!(visitor.visit_expr(subexpression));
|
||||||
try_visit!(visitor.visit_unambig_ty(typ));
|
try_visit!(visitor.visit_ty_unambig(typ));
|
||||||
}
|
}
|
||||||
ExprKind::DropTemps(ref subexpression) => {
|
ExprKind::DropTemps(ref subexpression) => {
|
||||||
try_visit!(visitor.visit_expr(subexpression));
|
try_visit!(visitor.visit_expr(subexpression));
|
||||||
|
@ -815,7 +815,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
||||||
// match the visit order in walk_local
|
// match the visit order in walk_local
|
||||||
try_visit!(visitor.visit_expr(init));
|
try_visit!(visitor.visit_expr(init));
|
||||||
try_visit!(visitor.visit_pat(pat));
|
try_visit!(visitor.visit_pat(pat));
|
||||||
visit_opt!(visitor, visit_unambig_ty, ty);
|
visit_opt!(visitor, visit_ty_unambig, ty);
|
||||||
}
|
}
|
||||||
ExprKind::If(ref cond, ref then, ref else_opt) => {
|
ExprKind::If(ref cond, ref then, ref else_opt) => {
|
||||||
try_visit!(visitor.visit_expr(cond));
|
try_visit!(visitor.visit_expr(cond));
|
||||||
|
@ -883,7 +883,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
||||||
try_visit!(visitor.visit_inline_asm(asm, expression.hir_id));
|
try_visit!(visitor.visit_inline_asm(asm, expression.hir_id));
|
||||||
}
|
}
|
||||||
ExprKind::OffsetOf(ref container, ref fields) => {
|
ExprKind::OffsetOf(ref container, ref fields) => {
|
||||||
try_visit!(visitor.visit_unambig_ty(container));
|
try_visit!(visitor.visit_ty_unambig(container));
|
||||||
walk_list!(visitor, visit_ident, fields.iter().copied());
|
walk_list!(visitor, visit_ident, fields.iter().copied());
|
||||||
}
|
}
|
||||||
ExprKind::Yield(ref subexpression, _) => {
|
ExprKind::Yield(ref subexpression, _) => {
|
||||||
|
@ -891,7 +891,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
||||||
}
|
}
|
||||||
ExprKind::UnsafeBinderCast(_kind, expr, ty) => {
|
ExprKind::UnsafeBinderCast(_kind, expr, ty) => {
|
||||||
try_visit!(visitor.visit_expr(expr));
|
try_visit!(visitor.visit_expr(expr));
|
||||||
visit_opt!(visitor, visit_unambig_ty, ty);
|
visit_opt!(visitor, visit_ty_unambig, ty);
|
||||||
}
|
}
|
||||||
ExprKind::Lit(_) | ExprKind::Err(_) => {}
|
ExprKind::Lit(_) | ExprKind::Err(_) => {}
|
||||||
}
|
}
|
||||||
|
@ -936,15 +936,15 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) -
|
||||||
try_visit!(visitor.visit_id(typ.hir_id));
|
try_visit!(visitor.visit_id(typ.hir_id));
|
||||||
|
|
||||||
match typ.kind {
|
match typ.kind {
|
||||||
TyKind::Slice(ref ty) => try_visit!(visitor.visit_unambig_ty(ty)),
|
TyKind::Slice(ref ty) => try_visit!(visitor.visit_ty_unambig(ty)),
|
||||||
TyKind::Ptr(ref mutable_type) => try_visit!(visitor.visit_unambig_ty(mutable_type.ty)),
|
TyKind::Ptr(ref mutable_type) => try_visit!(visitor.visit_ty_unambig(mutable_type.ty)),
|
||||||
TyKind::Ref(ref lifetime, ref mutable_type) => {
|
TyKind::Ref(ref lifetime, ref mutable_type) => {
|
||||||
try_visit!(visitor.visit_lifetime(lifetime));
|
try_visit!(visitor.visit_lifetime(lifetime));
|
||||||
try_visit!(visitor.visit_unambig_ty(mutable_type.ty));
|
try_visit!(visitor.visit_ty_unambig(mutable_type.ty));
|
||||||
}
|
}
|
||||||
TyKind::Never => {}
|
TyKind::Never => {}
|
||||||
TyKind::Tup(tuple_element_types) => {
|
TyKind::Tup(tuple_element_types) => {
|
||||||
walk_list!(visitor, visit_unambig_ty, tuple_element_types);
|
walk_list!(visitor, visit_ty_unambig, tuple_element_types);
|
||||||
}
|
}
|
||||||
TyKind::BareFn(ref function_declaration) => {
|
TyKind::BareFn(ref function_declaration) => {
|
||||||
walk_list!(visitor, visit_generic_param, function_declaration.generic_params);
|
walk_list!(visitor, visit_generic_param, function_declaration.generic_params);
|
||||||
|
@ -952,7 +952,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) -
|
||||||
}
|
}
|
||||||
TyKind::UnsafeBinder(ref unsafe_binder) => {
|
TyKind::UnsafeBinder(ref unsafe_binder) => {
|
||||||
walk_list!(visitor, visit_generic_param, unsafe_binder.generic_params);
|
walk_list!(visitor, visit_generic_param, unsafe_binder.generic_params);
|
||||||
try_visit!(visitor.visit_unambig_ty(unsafe_binder.inner_ty));
|
try_visit!(visitor.visit_ty_unambig(unsafe_binder.inner_ty));
|
||||||
}
|
}
|
||||||
TyKind::Path(ref qpath) => {
|
TyKind::Path(ref qpath) => {
|
||||||
try_visit!(visitor.visit_qpath(qpath, typ.hir_id, typ.span));
|
try_visit!(visitor.visit_qpath(qpath, typ.hir_id, typ.span));
|
||||||
|
@ -964,8 +964,8 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) -
|
||||||
walk_list!(visitor, visit_param_bound, bounds);
|
walk_list!(visitor, visit_param_bound, bounds);
|
||||||
}
|
}
|
||||||
TyKind::Array(ref ty, ref length) => {
|
TyKind::Array(ref ty, ref length) => {
|
||||||
try_visit!(visitor.visit_unambig_ty(ty));
|
try_visit!(visitor.visit_ty_unambig(ty));
|
||||||
try_visit!(visitor.visit_unambig_const_arg(length));
|
try_visit!(visitor.visit_const_arg_unambig(length));
|
||||||
}
|
}
|
||||||
TyKind::TraitObject(bounds, ref lifetime) => {
|
TyKind::TraitObject(bounds, ref lifetime) => {
|
||||||
for bound in bounds {
|
for bound in bounds {
|
||||||
|
@ -976,7 +976,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) -
|
||||||
TyKind::Typeof(ref expression) => try_visit!(visitor.visit_anon_const(expression)),
|
TyKind::Typeof(ref expression) => try_visit!(visitor.visit_anon_const(expression)),
|
||||||
TyKind::InferDelegation(..) | TyKind::Err(_) => {}
|
TyKind::InferDelegation(..) | TyKind::Err(_) => {}
|
||||||
TyKind::Pat(ty, pat) => {
|
TyKind::Pat(ty, pat) => {
|
||||||
try_visit!(visitor.visit_unambig_ty(ty));
|
try_visit!(visitor.visit_ty_unambig(ty));
|
||||||
try_visit!(visitor.visit_pattern_type_pattern(pat));
|
try_visit!(visitor.visit_pattern_type_pattern(pat));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1019,10 +1019,10 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(
|
||||||
match param.kind {
|
match param.kind {
|
||||||
GenericParamKind::Lifetime { .. } => {}
|
GenericParamKind::Lifetime { .. } => {}
|
||||||
GenericParamKind::Type { ref default, .. } => {
|
GenericParamKind::Type { ref default, .. } => {
|
||||||
visit_opt!(visitor, visit_unambig_ty, default)
|
visit_opt!(visitor, visit_ty_unambig, default)
|
||||||
}
|
}
|
||||||
GenericParamKind::Const { ref ty, ref default, synthetic: _ } => {
|
GenericParamKind::Const { ref ty, ref default, synthetic: _ } => {
|
||||||
try_visit!(visitor.visit_unambig_ty(ty));
|
try_visit!(visitor.visit_ty_unambig(ty));
|
||||||
if let Some(ref default) = default {
|
if let Some(ref default) = default {
|
||||||
try_visit!(visitor.visit_const_param_default(param.hir_id, default));
|
try_visit!(visitor.visit_const_param_default(param.hir_id, default));
|
||||||
}
|
}
|
||||||
|
@ -1035,7 +1035,7 @@ pub fn walk_const_param_default<'v, V: Visitor<'v>>(
|
||||||
visitor: &mut V,
|
visitor: &mut V,
|
||||||
ct: &'v ConstArg<'v>,
|
ct: &'v ConstArg<'v>,
|
||||||
) -> V::Result {
|
) -> V::Result {
|
||||||
visitor.visit_unambig_const_arg(ct)
|
visitor.visit_const_arg_unambig(ct)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics<'v>) -> V::Result {
|
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics<'v>) -> V::Result {
|
||||||
|
@ -1057,7 +1057,7 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
|
||||||
bound_generic_params,
|
bound_generic_params,
|
||||||
origin: _,
|
origin: _,
|
||||||
}) => {
|
}) => {
|
||||||
try_visit!(visitor.visit_unambig_ty(bounded_ty));
|
try_visit!(visitor.visit_ty_unambig(bounded_ty));
|
||||||
walk_list!(visitor, visit_param_bound, bounds);
|
walk_list!(visitor, visit_param_bound, bounds);
|
||||||
walk_list!(visitor, visit_generic_param, bound_generic_params);
|
walk_list!(visitor, visit_generic_param, bound_generic_params);
|
||||||
}
|
}
|
||||||
|
@ -1070,8 +1070,8 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
|
||||||
walk_list!(visitor, visit_param_bound, bounds);
|
walk_list!(visitor, visit_param_bound, bounds);
|
||||||
}
|
}
|
||||||
WherePredicateKind::EqPredicate(WhereEqPredicate { ref lhs_ty, ref rhs_ty }) => {
|
WherePredicateKind::EqPredicate(WhereEqPredicate { ref lhs_ty, ref rhs_ty }) => {
|
||||||
try_visit!(visitor.visit_unambig_ty(lhs_ty));
|
try_visit!(visitor.visit_ty_unambig(lhs_ty));
|
||||||
try_visit!(visitor.visit_unambig_ty(rhs_ty));
|
try_visit!(visitor.visit_ty_unambig(rhs_ty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
|
@ -1081,13 +1081,13 @@ pub fn walk_fn_decl<'v, V: Visitor<'v>>(
|
||||||
visitor: &mut V,
|
visitor: &mut V,
|
||||||
function_declaration: &'v FnDecl<'v>,
|
function_declaration: &'v FnDecl<'v>,
|
||||||
) -> V::Result {
|
) -> V::Result {
|
||||||
walk_list!(visitor, visit_unambig_ty, function_declaration.inputs);
|
walk_list!(visitor, visit_ty_unambig, function_declaration.inputs);
|
||||||
visitor.visit_fn_ret_ty(&function_declaration.output)
|
visitor.visit_fn_ret_ty(&function_declaration.output)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FnRetTy<'v>) -> V::Result {
|
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FnRetTy<'v>) -> V::Result {
|
||||||
if let FnRetTy::Return(output_ty) = *ret_ty {
|
if let FnRetTy::Return(output_ty) = *ret_ty {
|
||||||
try_visit!(visitor.visit_unambig_ty(output_ty));
|
try_visit!(visitor.visit_ty_unambig(output_ty));
|
||||||
}
|
}
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
|
@ -1140,7 +1140,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(
|
||||||
try_visit!(visitor.visit_id(hir_id));
|
try_visit!(visitor.visit_id(hir_id));
|
||||||
match *kind {
|
match *kind {
|
||||||
TraitItemKind::Const(ref ty, default) => {
|
TraitItemKind::Const(ref ty, default) => {
|
||||||
try_visit!(visitor.visit_unambig_ty(ty));
|
try_visit!(visitor.visit_ty_unambig(ty));
|
||||||
visit_opt!(visitor, visit_nested_body, default);
|
visit_opt!(visitor, visit_nested_body, default);
|
||||||
}
|
}
|
||||||
TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => {
|
TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => {
|
||||||
|
@ -1158,7 +1158,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(
|
||||||
}
|
}
|
||||||
TraitItemKind::Type(bounds, ref default) => {
|
TraitItemKind::Type(bounds, ref default) => {
|
||||||
walk_list!(visitor, visit_param_bound, bounds);
|
walk_list!(visitor, visit_param_bound, bounds);
|
||||||
visit_opt!(visitor, visit_unambig_ty, default);
|
visit_opt!(visitor, visit_ty_unambig, default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
|
@ -1196,7 +1196,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(
|
||||||
try_visit!(visitor.visit_id(impl_item.hir_id()));
|
try_visit!(visitor.visit_id(impl_item.hir_id()));
|
||||||
match *kind {
|
match *kind {
|
||||||
ImplItemKind::Const(ref ty, body) => {
|
ImplItemKind::Const(ref ty, body) => {
|
||||||
try_visit!(visitor.visit_unambig_ty(ty));
|
try_visit!(visitor.visit_ty_unambig(ty));
|
||||||
visitor.visit_nested_body(body)
|
visitor.visit_nested_body(body)
|
||||||
}
|
}
|
||||||
ImplItemKind::Fn(ref sig, body_id) => visitor.visit_fn(
|
ImplItemKind::Fn(ref sig, body_id) => visitor.visit_fn(
|
||||||
|
@ -1206,7 +1206,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(
|
||||||
impl_item.span,
|
impl_item.span,
|
||||||
impl_item.owner_id.def_id,
|
impl_item.owner_id.def_id,
|
||||||
),
|
),
|
||||||
ImplItemKind::Type(ref ty) => visitor.visit_unambig_ty(ty),
|
ImplItemKind::Type(ref ty) => visitor.visit_ty_unambig(ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1294,7 +1294,7 @@ pub fn walk_field_def<'v, V: Visitor<'v>>(
|
||||||
try_visit!(visitor.visit_id(*hir_id));
|
try_visit!(visitor.visit_id(*hir_id));
|
||||||
try_visit!(visitor.visit_ident(*ident));
|
try_visit!(visitor.visit_ident(*ident));
|
||||||
visit_opt!(visitor, visit_anon_const, default);
|
visit_opt!(visitor, visit_anon_const, default);
|
||||||
visitor.visit_unambig_ty(*ty)
|
visitor.visit_ty_unambig(*ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_enum_def<'v, V: Visitor<'v>>(
|
pub fn walk_enum_def<'v, V: Visitor<'v>>(
|
||||||
|
@ -1335,11 +1335,11 @@ pub fn walk_qpath<'v, V: Visitor<'v>>(
|
||||||
) -> V::Result {
|
) -> V::Result {
|
||||||
match *qpath {
|
match *qpath {
|
||||||
QPath::Resolved(ref maybe_qself, ref path) => {
|
QPath::Resolved(ref maybe_qself, ref path) => {
|
||||||
visit_opt!(visitor, visit_unambig_ty, maybe_qself);
|
visit_opt!(visitor, visit_ty_unambig, maybe_qself);
|
||||||
visitor.visit_path(path, id)
|
visitor.visit_path(path, id)
|
||||||
}
|
}
|
||||||
QPath::TypeRelative(ref qself, ref segment) => {
|
QPath::TypeRelative(ref qself, ref segment) => {
|
||||||
try_visit!(visitor.visit_unambig_ty(qself));
|
try_visit!(visitor.visit_ty_unambig(qself));
|
||||||
visitor.visit_path_segment(segment)
|
visitor.visit_path_segment(segment)
|
||||||
}
|
}
|
||||||
QPath::LangItem(..) => V::Result::output(),
|
QPath::LangItem(..) => V::Result::output(),
|
||||||
|
@ -1379,8 +1379,8 @@ pub fn walk_assoc_item_constraint<'v, V: Visitor<'v>>(
|
||||||
try_visit!(visitor.visit_generic_args(constraint.gen_args));
|
try_visit!(visitor.visit_generic_args(constraint.gen_args));
|
||||||
match constraint.kind {
|
match constraint.kind {
|
||||||
AssocItemConstraintKind::Equality { ref term } => match term {
|
AssocItemConstraintKind::Equality { ref term } => match term {
|
||||||
Term::Ty(ref ty) => try_visit!(visitor.visit_unambig_ty(ty)),
|
Term::Ty(ref ty) => try_visit!(visitor.visit_ty_unambig(ty)),
|
||||||
Term::Const(ref c) => try_visit!(visitor.visit_unambig_const_arg(c)),
|
Term::Const(ref c) => try_visit!(visitor.visit_const_arg_unambig(c)),
|
||||||
},
|
},
|
||||||
AssocItemConstraintKind::Bound { bounds } => {
|
AssocItemConstraintKind::Bound { bounds } => {
|
||||||
walk_list!(visitor, visit_param_bound, bounds)
|
walk_list!(visitor, visit_param_bound, bounds)
|
||||||
|
|
|
@ -1624,7 +1624,7 @@ fn compare_synthetic_generics<'tcx>(
|
||||||
|
|
||||||
let span = input_tys
|
let span = input_tys
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|ty| Visitor(impl_def_id).visit_unambig_ty(ty).break_value())?;
|
.find_map(|ty| Visitor(impl_def_id).visit_ty_unambig(ty).break_value())?;
|
||||||
|
|
||||||
let bounds = impl_m.generics.bounds_for_param(impl_def_id).next()?.bounds;
|
let bounds = impl_m.generics.bounds_for_param(impl_def_id).next()?.bounds;
|
||||||
let bounds = bounds.first()?.span().to(bounds.last()?.span());
|
let bounds = bounds.first()?.span().to(bounds.last()?.span());
|
||||||
|
|
|
@ -576,7 +576,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only visit the type looking for `_` if we didn't fix the type above
|
// Only visit the type looking for `_` if we didn't fix the type above
|
||||||
visitor.visit_unambig_ty(a);
|
visitor.visit_ty_unambig(a);
|
||||||
self.lowerer().lower_arg_ty(a, None)
|
self.lowerer().lower_arg_ty(a, None)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -590,7 +590,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
|
||||||
infer_replacements.push((output.span, suggested_ty.to_string()));
|
infer_replacements.push((output.span, suggested_ty.to_string()));
|
||||||
Ty::new_error_with_message(tcx, output.span, suggested_ty.to_string())
|
Ty::new_error_with_message(tcx, output.span, suggested_ty.to_string())
|
||||||
} else {
|
} else {
|
||||||
visitor.visit_unambig_ty(output);
|
visitor.visit_ty_unambig(output);
|
||||||
self.lower_ty(output)
|
self.lower_ty(output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1436,7 +1436,7 @@ fn recover_infer_ret_ty<'tcx>(
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut visitor = HirPlaceholderCollector::default();
|
let mut visitor = HirPlaceholderCollector::default();
|
||||||
visitor.visit_unambig_ty(infer_ret_ty);
|
visitor.visit_ty_unambig(infer_ret_ty);
|
||||||
|
|
||||||
let mut diag = bad_placeholder(icx.lowerer(), visitor.spans, "return type");
|
let mut diag = bad_placeholder(icx.lowerer(), visitor.spans, "return type");
|
||||||
let ret_ty = fn_sig.output();
|
let ret_ty = fn_sig.output();
|
||||||
|
|
|
@ -540,7 +540,7 @@ impl<'v> Visitor<'v> for AnonConstInParamTyDetector {
|
||||||
if let GenericParamKind::Const { ty, default: _, synthetic: _ } = p.kind {
|
if let GenericParamKind::Const { ty, default: _, synthetic: _ } = p.kind {
|
||||||
let prev = self.in_param_ty;
|
let prev = self.in_param_ty;
|
||||||
self.in_param_ty = true;
|
self.in_param_ty = true;
|
||||||
let res = self.visit_unambig_ty(ty);
|
let res = self.visit_ty_unambig(ty);
|
||||||
self.in_param_ty = prev;
|
self.in_param_ty = prev;
|
||||||
res
|
res
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -499,7 +499,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||||
ControlFlow::Break(inf_span)
|
ControlFlow::Break(inf_span)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FindInferInClosureWithBinder.visit_unambig_ty(ty).break_value()
|
FindInferInClosureWithBinder.visit_ty_unambig(ty).break_value()
|
||||||
}
|
}
|
||||||
|
|
||||||
let infer_in_rt_sp = match fn_decl.output {
|
let infer_in_rt_sp = match fn_decl.output {
|
||||||
|
@ -853,7 +853,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||||
lifetime: self.map.defs.get(&lifetime_ref.hir_id.local_id).cloned(),
|
lifetime: self.map.defs.get(&lifetime_ref.hir_id.local_id).cloned(),
|
||||||
s: self.scope,
|
s: self.scope,
|
||||||
};
|
};
|
||||||
self.with(scope, |this| this.visit_unambig_ty(mt.ty));
|
self.with(scope, |this| this.visit_ty_unambig(mt.ty));
|
||||||
}
|
}
|
||||||
hir::TyKind::TraitAscription(bounds) => {
|
hir::TyKind::TraitAscription(bounds) => {
|
||||||
let scope = Scope::TraitRefBoundary { s: self.scope };
|
let scope = Scope::TraitRefBoundary { s: self.scope };
|
||||||
|
@ -895,7 +895,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||||
this.visit_param_bound(bound);
|
this.visit_param_bound(bound);
|
||||||
}
|
}
|
||||||
if let Some(ty) = ty {
|
if let Some(ty) = ty {
|
||||||
this.visit_unambig_ty(ty);
|
this.visit_ty_unambig(ty);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -914,7 +914,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||||
}),
|
}),
|
||||||
Type(ty) => self.visit_early(impl_item.hir_id(), impl_item.generics, |this| {
|
Type(ty) => self.visit_early(impl_item.hir_id(), impl_item.generics, |this| {
|
||||||
this.visit_generics(impl_item.generics);
|
this.visit_generics(impl_item.generics);
|
||||||
this.visit_unambig_ty(ty);
|
this.visit_ty_unambig(ty);
|
||||||
}),
|
}),
|
||||||
Const(_, _) => self.visit_early(impl_item.hir_id(), impl_item.generics, |this| {
|
Const(_, _) => self.visit_early(impl_item.hir_id(), impl_item.generics, |this| {
|
||||||
intravisit::walk_impl_item(this, impl_item)
|
intravisit::walk_impl_item(this, impl_item)
|
||||||
|
@ -1023,7 +1023,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
self.with(scope, |this| {
|
self.with(scope, |this| {
|
||||||
walk_list!(this, visit_generic_param, bound_generic_params);
|
walk_list!(this, visit_generic_param, bound_generic_params);
|
||||||
this.visit_unambig_ty(bounded_ty);
|
this.visit_ty_unambig(bounded_ty);
|
||||||
walk_list!(this, visit_param_bound, bounds);
|
walk_list!(this, visit_param_bound, bounds);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1038,8 +1038,8 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||||
&hir::WherePredicateKind::EqPredicate(hir::WhereEqPredicate {
|
&hir::WherePredicateKind::EqPredicate(hir::WhereEqPredicate {
|
||||||
lhs_ty, rhs_ty, ..
|
lhs_ty, rhs_ty, ..
|
||||||
}) => {
|
}) => {
|
||||||
self.visit_unambig_ty(lhs_ty);
|
self.visit_ty_unambig(lhs_ty);
|
||||||
self.visit_unambig_ty(rhs_ty);
|
self.visit_ty_unambig(rhs_ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1072,13 +1072,13 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||||
GenericParamKind::Lifetime { .. } => {}
|
GenericParamKind::Lifetime { .. } => {}
|
||||||
GenericParamKind::Type { default, .. } => {
|
GenericParamKind::Type { default, .. } => {
|
||||||
if let Some(ty) = default {
|
if let Some(ty) = default {
|
||||||
self.visit_unambig_ty(ty);
|
self.visit_ty_unambig(ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GenericParamKind::Const { ty, default, .. } => {
|
GenericParamKind::Const { ty, default, .. } => {
|
||||||
self.visit_unambig_ty(ty);
|
self.visit_ty_unambig(ty);
|
||||||
if let Some(default) = default {
|
if let Some(default) = default {
|
||||||
self.visit_unambig_const_arg(default);
|
self.visit_const_arg_unambig(default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1987,15 +1987,15 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||||
},
|
},
|
||||||
|this| {
|
|this| {
|
||||||
for input in inputs {
|
for input in inputs {
|
||||||
this.visit_unambig_ty(input);
|
this.visit_ty_unambig(input);
|
||||||
}
|
}
|
||||||
if !in_closure && let Some(output) = output {
|
if !in_closure && let Some(output) = output {
|
||||||
this.visit_unambig_ty(output);
|
this.visit_ty_unambig(output);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if in_closure && let Some(output) = output {
|
if in_closure && let Some(output) = output {
|
||||||
self.visit_unambig_ty(output);
|
self.visit_ty_unambig(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2313,7 +2313,7 @@ fn is_late_bound_map(
|
||||||
|
|
||||||
let mut constrained_by_input = ConstrainedCollector { regions: Default::default(), tcx };
|
let mut constrained_by_input = ConstrainedCollector { regions: Default::default(), tcx };
|
||||||
for arg_ty in sig.decl.inputs {
|
for arg_ty in sig.decl.inputs {
|
||||||
constrained_by_input.visit_unambig_ty(arg_ty);
|
constrained_by_input.visit_ty_unambig(arg_ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut appears_in_output =
|
let mut appears_in_output =
|
||||||
|
|
|
@ -450,7 +450,7 @@ fn infer_placeholder_type<'tcx>(
|
||||||
let mut visitor = HirPlaceholderCollector::default();
|
let mut visitor = HirPlaceholderCollector::default();
|
||||||
let node = tcx.hir_node_by_def_id(def_id);
|
let node = tcx.hir_node_by_def_id(def_id);
|
||||||
if let Some(ty) = node.ty() {
|
if let Some(ty) = node.ty() {
|
||||||
visitor.visit_unambig_ty(ty);
|
visitor.visit_ty_unambig(ty);
|
||||||
}
|
}
|
||||||
// If we have just one span, let's try to steal a const `_` feature error.
|
// If we have just one span, let's try to steal a const `_` feature error.
|
||||||
let try_steal_span = if !tcx.features().generic_arg_infer() && visitor.spans.len() == 1
|
let try_steal_span = if !tcx.features().generic_arg_infer() && visitor.spans.len() == 1
|
||||||
|
@ -532,5 +532,5 @@ pub(crate) fn type_alias_is_lazy<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HasTait.visit_unambig_ty(tcx.hir().expect_item(def_id).expect_ty_alias().0).is_break()
|
HasTait.visit_ty_unambig(tcx.hir().expect_item(def_id).expect_ty_alias().0).is_break()
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ fn diagnostic_hir_wf_check<'tcx>(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for ty in tys {
|
for ty in tys {
|
||||||
visitor.visit_unambig_ty(ty);
|
visitor.visit_ty_unambig(ty);
|
||||||
}
|
}
|
||||||
visitor.cause
|
visitor.cause
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,7 +480,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut clauses = CollectClauses { clauses: vec![], fcx: self };
|
let mut clauses = CollectClauses { clauses: vec![], fcx: self };
|
||||||
clauses.visit_unambig_ty(hir_ty);
|
clauses.visit_ty_unambig(hir_ty);
|
||||||
self.tcx.mk_clauses(&clauses.clauses)
|
self.tcx.mk_clauses(&clauses.clauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ impl<'a> LintDiagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> {
|
||||||
// avoid doing throwaway work in case the lint ends up getting suppressed.
|
// avoid doing throwaway work in case the lint ends up getting suppressed.
|
||||||
let mut collector = ShorthandAssocTyCollector { qselves: Vec::new() };
|
let mut collector = ShorthandAssocTyCollector { qselves: Vec::new() };
|
||||||
if let Some(ty) = self.ty {
|
if let Some(ty) = self.ty {
|
||||||
collector.visit_unambig_ty(ty);
|
collector.visit_ty_unambig(ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
let affect_object_lifetime_defaults = self
|
let affect_object_lifetime_defaults = self
|
||||||
|
|
|
@ -126,7 +126,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
|
||||||
// 1. We collect all the `hir::Path` from the `Self` type and `Trait` ref
|
// 1. We collect all the `hir::Path` from the `Self` type and `Trait` ref
|
||||||
// of the `impl` definition
|
// of the `impl` definition
|
||||||
let mut collector = PathCollector { paths: Vec::new() };
|
let mut collector = PathCollector { paths: Vec::new() };
|
||||||
collector.visit_unambig_ty(&impl_.self_ty);
|
collector.visit_ty_unambig(&impl_.self_ty);
|
||||||
if let Some(of_trait) = &impl_.of_trait {
|
if let Some(of_trait) = &impl_.of_trait {
|
||||||
collector.visit_trait_ref(of_trait);
|
collector.visit_trait_ref(of_trait);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1501,7 +1501,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||||
|
|
||||||
let mut visitor = FnPtrFinder { visitor: self, spans: Vec::new(), tys: Vec::new() };
|
let mut visitor = FnPtrFinder { visitor: self, spans: Vec::new(), tys: Vec::new() };
|
||||||
ty.visit_with(&mut visitor);
|
ty.visit_with(&mut visitor);
|
||||||
visitor.visit_unambig_ty(hir_ty);
|
visitor.visit_ty_unambig(hir_ty);
|
||||||
|
|
||||||
iter::zip(visitor.tys.drain(..), visitor.spans.drain(..)).collect()
|
iter::zip(visitor.tys.drain(..), visitor.spans.drain(..)).collect()
|
||||||
}
|
}
|
||||||
|
|
|
@ -2028,7 +2028,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut v = TraitObjectVisitor(vec![], self.hir());
|
let mut v = TraitObjectVisitor(vec![], self.hir());
|
||||||
v.visit_unambig_ty(hir_output);
|
v.visit_ty_unambig(hir_output);
|
||||||
v.0
|
v.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2050,7 +2050,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
&& let Some(alias_ty) = self.hir_node_by_def_id(local_id).alias_ty() // it is type alias
|
&& let Some(alias_ty) = self.hir_node_by_def_id(local_id).alias_ty() // it is type alias
|
||||||
&& let Some(alias_generics) = self.hir_node_by_def_id(local_id).generics()
|
&& let Some(alias_generics) = self.hir_node_by_def_id(local_id).generics()
|
||||||
{
|
{
|
||||||
v.visit_unambig_ty(alias_ty);
|
v.visit_ty_unambig(alias_ty);
|
||||||
if !v.0.is_empty() {
|
if !v.0.is_empty() {
|
||||||
return Some((
|
return Some((
|
||||||
v.0,
|
v.0,
|
||||||
|
|
|
@ -801,7 +801,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
|
||||||
)) = stab
|
)) = stab
|
||||||
{
|
{
|
||||||
let mut c = CheckTraitImplStable { tcx: self.tcx, fully_stable: true };
|
let mut c = CheckTraitImplStable { tcx: self.tcx, fully_stable: true };
|
||||||
c.visit_unambig_ty(self_ty);
|
c.visit_ty_unambig(self_ty);
|
||||||
c.visit_trait_ref(t);
|
c.visit_trait_ref(t);
|
||||||
|
|
||||||
// do not lint when the trait isn't resolved, since resolution error should
|
// do not lint when the trait isn't resolved, since resolution error should
|
||||||
|
@ -1041,12 +1041,12 @@ impl<'tcx> Visitor<'tcx> for CheckTraitImplStable<'tcx> {
|
||||||
|
|
||||||
fn visit_fn_decl(&mut self, fd: &'tcx hir::FnDecl<'tcx>) {
|
fn visit_fn_decl(&mut self, fd: &'tcx hir::FnDecl<'tcx>) {
|
||||||
for ty in fd.inputs {
|
for ty in fd.inputs {
|
||||||
self.visit_unambig_ty(ty)
|
self.visit_ty_unambig(ty)
|
||||||
}
|
}
|
||||||
if let hir::FnRetTy::Return(output_ty) = fd.output {
|
if let hir::FnRetTy::Return(output_ty) = fd.output {
|
||||||
match output_ty.kind {
|
match output_ty.kind {
|
||||||
TyKind::Never => {} // `-> !` is stable
|
TyKind::Never => {} // `-> !` is stable
|
||||||
_ => self.visit_unambig_ty(output_ty),
|
_ => self.visit_ty_unambig(output_ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ fn find_component_for_bound_region<'tcx>(
|
||||||
region_def_id: DefId,
|
region_def_id: DefId,
|
||||||
) -> Option<&'tcx hir::Ty<'tcx>> {
|
) -> Option<&'tcx hir::Ty<'tcx>> {
|
||||||
FindNestedTypeVisitor { tcx, region_def_id, current_index: ty::INNERMOST }
|
FindNestedTypeVisitor { tcx, region_def_id, current_index: ty::INNERMOST }
|
||||||
.visit_unambig_ty(arg)
|
.visit_ty_unambig(arg)
|
||||||
.break_value()
|
.break_value()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
for matching_def_id in v.0 {
|
for matching_def_id in v.0 {
|
||||||
let mut hir_v =
|
let mut hir_v =
|
||||||
super::static_impl_trait::HirTraitObjectVisitor(&mut traits, matching_def_id);
|
super::static_impl_trait::HirTraitObjectVisitor(&mut traits, matching_def_id);
|
||||||
hir_v.visit_unambig_ty(impl_self_ty);
|
hir_v.visit_ty_unambig(impl_self_ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
if traits.is_empty() {
|
if traits.is_empty() {
|
||||||
|
|
|
@ -153,7 +153,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
let mut add_label = true;
|
let mut add_label = true;
|
||||||
if let hir::FnRetTy::Return(ty) = fn_decl.output {
|
if let hir::FnRetTy::Return(ty) = fn_decl.output {
|
||||||
let mut v = StaticLifetimeVisitor(vec![], tcx.hir());
|
let mut v = StaticLifetimeVisitor(vec![], tcx.hir());
|
||||||
v.visit_unambig_ty(ty);
|
v.visit_ty_unambig(ty);
|
||||||
if !v.0.is_empty() {
|
if !v.0.is_empty() {
|
||||||
span = v.0.clone().into();
|
span = v.0.clone().into();
|
||||||
spans = v.0;
|
spans = v.0;
|
||||||
|
@ -500,7 +500,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
// In that case, only the first one will get suggestions.
|
// In that case, only the first one will get suggestions.
|
||||||
let mut traits = vec![];
|
let mut traits = vec![];
|
||||||
let mut hir_v = HirTraitObjectVisitor(&mut traits, *did);
|
let mut hir_v = HirTraitObjectVisitor(&mut traits, *did);
|
||||||
hir_v.visit_unambig_ty(self_ty);
|
hir_v.visit_ty_unambig(self_ty);
|
||||||
!traits.is_empty()
|
!traits.is_empty()
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
@ -560,7 +560,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
for found_did in found_dids {
|
for found_did in found_dids {
|
||||||
let mut traits = vec![];
|
let mut traits = vec![];
|
||||||
let mut hir_v = HirTraitObjectVisitor(&mut traits, *found_did);
|
let mut hir_v = HirTraitObjectVisitor(&mut traits, *found_did);
|
||||||
hir_v.visit_unambig_ty(self_ty);
|
hir_v.visit_ty_unambig(self_ty);
|
||||||
for &span in &traits {
|
for &span in &traits {
|
||||||
let subdiag = DynTraitConstraintSuggestion { span, ident };
|
let subdiag = DynTraitConstraintSuggestion { span, ident };
|
||||||
subdiag.add_to_diag(err);
|
subdiag.add_to_diag(err);
|
||||||
|
|
|
@ -178,7 +178,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
|
||||||
let mut ty_spans = vec![];
|
let mut ty_spans = vec![];
|
||||||
for input in fn_sig.decl.inputs {
|
for input in fn_sig.decl.inputs {
|
||||||
ReplaceImplTraitVisitor { ty_spans: &mut ty_spans, param_did: param.def_id }
|
ReplaceImplTraitVisitor { ty_spans: &mut ty_spans, param_did: param.def_id }
|
||||||
.visit_unambig_ty(input);
|
.visit_ty_unambig(input);
|
||||||
}
|
}
|
||||||
// The type param `T: Trait` we will suggest to introduce.
|
// The type param `T: Trait` we will suggest to introduce.
|
||||||
let type_param = format!("{type_param_name}: {bound_str}");
|
let type_param = format!("{type_param_name}: {bound_str}");
|
||||||
|
|
|
@ -641,16 +641,16 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> {
|
||||||
if let Some(fn_decl) = node.fn_decl()
|
if let Some(fn_decl) = node.fn_decl()
|
||||||
&& let hir::FnRetTy::Return(ty) = fn_decl.output
|
&& let hir::FnRetTy::Return(ty) = fn_decl.output
|
||||||
{
|
{
|
||||||
visitor.visit_unambig_ty(ty);
|
visitor.visit_ty_unambig(ty);
|
||||||
}
|
}
|
||||||
if visitor.suggestions.is_empty() {
|
if visitor.suggestions.is_empty() {
|
||||||
// Do not suggest constraining the `&self` param, but rather the return type.
|
// Do not suggest constraining the `&self` param, but rather the return type.
|
||||||
// If that is wrong (because it is not sufficient), a follow up error will tell the
|
// If that is wrong (because it is not sufficient), a follow up error will tell the
|
||||||
// user to fix it. This way we lower the chances of *over* constraining, but still
|
// user to fix it. This way we lower the chances of *over* constraining, but still
|
||||||
// get the cake of "correctly" contrained in two steps.
|
// get the cake of "correctly" contrained in two steps.
|
||||||
visitor.visit_unambig_ty(self.ty_sup);
|
visitor.visit_ty_unambig(self.ty_sup);
|
||||||
}
|
}
|
||||||
visitor.visit_unambig_ty(self.ty_sub);
|
visitor.visit_ty_unambig(self.ty_sub);
|
||||||
if visitor.suggestions.is_empty() {
|
if visitor.suggestions.is_empty() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||||
match cx.tcx.parent_hir_node(expr.hir_id) {
|
match cx.tcx.parent_hir_node(expr.hir_id) {
|
||||||
Node::LetStmt(LetStmt { ty: Some(ty), .. }) => {
|
Node::LetStmt(LetStmt { ty: Some(ty), .. }) => {
|
||||||
let mut v = InferVisitor::default();
|
let mut v = InferVisitor::default();
|
||||||
v.visit_unambig_ty(ty);
|
v.visit_ty_unambig(ty);
|
||||||
!v.0
|
!v.0
|
||||||
},
|
},
|
||||||
Node::Expr(Expr {
|
Node::Expr(Expr {
|
||||||
|
|
|
@ -905,7 +905,7 @@ fn ty_contains_infer(ty: &hir::Ty<'_>) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut v = V(false);
|
let mut v = V(false);
|
||||||
v.visit_unambig_ty(ty);
|
v.visit_ty_unambig(ty);
|
||||||
v.0
|
v.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::borrow::Cow;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use rustc_errors::{Applicability, Diag};
|
use rustc_errors::{Applicability, Diag};
|
||||||
use rustc_hir::intravisit::{Visitor, VisitorExt, walk_ty, walk_body, walk_expr};
|
use rustc_hir::intravisit::{Visitor, VisitorExt, walk_body, walk_expr, walk_ty};
|
||||||
use rustc_hir::{self as hir, AmbigArg, Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind};
|
use rustc_hir::{self as hir, AmbigArg, Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind};
|
||||||
use rustc_hir_analysis::lower_ty;
|
use rustc_hir_analysis::lower_ty;
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
@ -111,7 +111,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ItemKind::Impl(impl_) => {
|
ItemKind::Impl(impl_) => {
|
||||||
let mut vis = ImplicitHasherTypeVisitor::new(cx);
|
let mut vis = ImplicitHasherTypeVisitor::new(cx);
|
||||||
vis.visit_unambig_ty(impl_.self_ty);
|
vis.visit_ty_unambig(impl_.self_ty);
|
||||||
|
|
||||||
for target in &vis.found {
|
for target in &vis.found {
|
||||||
if !item.span.eq_ctxt(target.span()) {
|
if !item.span.eq_ctxt(target.span()) {
|
||||||
|
@ -158,7 +158,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
|
||||||
|
|
||||||
for ty in sig.decl.inputs {
|
for ty in sig.decl.inputs {
|
||||||
let mut vis = ImplicitHasherTypeVisitor::new(cx);
|
let mut vis = ImplicitHasherTypeVisitor::new(cx);
|
||||||
vis.visit_unambig_ty(ty);
|
vis.visit_ty_unambig(ty);
|
||||||
|
|
||||||
for target in &vis.found {
|
for target in &vis.found {
|
||||||
if generics.span.from_expansion() {
|
if generics.span.from_expansion() {
|
||||||
|
|
|
@ -232,11 +232,11 @@ fn could_use_elision<'tcx>(
|
||||||
|
|
||||||
// extract lifetimes in input argument types
|
// extract lifetimes in input argument types
|
||||||
for arg in func.inputs {
|
for arg in func.inputs {
|
||||||
input_visitor.visit_unambig_ty(arg);
|
input_visitor.visit_ty_unambig(arg);
|
||||||
}
|
}
|
||||||
// extract lifetimes in output type
|
// extract lifetimes in output type
|
||||||
if let Return(ty) = func.output {
|
if let Return(ty) = func.output {
|
||||||
output_visitor.visit_unambig_ty(ty);
|
output_visitor.visit_ty_unambig(ty);
|
||||||
}
|
}
|
||||||
for lt in named_generics {
|
for lt in named_generics {
|
||||||
input_visitor.visit_generic_param(lt);
|
input_visitor.visit_generic_param(lt);
|
||||||
|
@ -340,7 +340,7 @@ fn explicit_self_type<'tcx>(cx: &LateContext<'tcx>, func: &FnDecl<'tcx>, ident:
|
||||||
&& let Some(self_ty) = func.inputs.first()
|
&& let Some(self_ty) = func.inputs.first()
|
||||||
{
|
{
|
||||||
let mut visitor = RefVisitor::new(cx);
|
let mut visitor = RefVisitor::new(cx);
|
||||||
visitor.visit_unambig_ty(self_ty);
|
visitor.visit_ty_unambig(self_ty);
|
||||||
|
|
||||||
!visitor.all_lts().is_empty()
|
!visitor.all_lts().is_empty()
|
||||||
} else {
|
} else {
|
||||||
|
@ -541,7 +541,7 @@ where
|
||||||
try_visit!(self.visit_id(hir_id));
|
try_visit!(self.visit_id(hir_id));
|
||||||
|
|
||||||
self.bounded_ty_depth += 1;
|
self.bounded_ty_depth += 1;
|
||||||
try_visit!(self.visit_unambig_ty(bounded_ty));
|
try_visit!(self.visit_ty_unambig(bounded_ty));
|
||||||
self.bounded_ty_depth -= 1;
|
self.bounded_ty_depth -= 1;
|
||||||
|
|
||||||
walk_list!(self, visit_param_bound, bounds);
|
walk_list!(self, visit_param_bound, bounds);
|
||||||
|
|
|
@ -10,7 +10,7 @@ use super::TYPE_COMPLEXITY;
|
||||||
pub(super) fn check(cx: &LateContext<'_>, ty: &hir::Ty<'_>, type_complexity_threshold: u64) -> bool {
|
pub(super) fn check(cx: &LateContext<'_>, ty: &hir::Ty<'_>, type_complexity_threshold: u64) -> bool {
|
||||||
let score = {
|
let score = {
|
||||||
let mut visitor = TypeComplexityVisitor { score: 0, nest: 1 };
|
let mut visitor = TypeComplexityVisitor { score: 0, nest: 1 };
|
||||||
visitor.visit_unambig_ty(ty);
|
visitor.visit_ty_unambig(ty);
|
||||||
visitor.score
|
visitor.score
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
|
||||||
for (impl_hir_ty, trait_sem_ty) in impl_inputs_outputs.zip(trait_method_sig.inputs_and_output) {
|
for (impl_hir_ty, trait_sem_ty) in impl_inputs_outputs.zip(trait_method_sig.inputs_and_output) {
|
||||||
if trait_sem_ty.walk().any(|inner| inner == self_ty.into()) {
|
if trait_sem_ty.walk().any(|inner| inner == self_ty.into()) {
|
||||||
let mut visitor = SkipTyCollector::default();
|
let mut visitor = SkipTyCollector::default();
|
||||||
visitor.visit_unambig_ty(impl_hir_ty);
|
visitor.visit_ty_unambig(impl_hir_ty);
|
||||||
types_to_skip.extend(visitor.types_to_skip);
|
types_to_skip.extend(visitor.types_to_skip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ fn type_certainty(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Certainty {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut visitor = CertaintyVisitor::new(cx);
|
let mut visitor = CertaintyVisitor::new(cx);
|
||||||
visitor.visit_unambig_ty(ty);
|
visitor.visit_ty_unambig(ty);
|
||||||
visitor.certainty
|
visitor.certainty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue