Skip to content

Commit 5865d56

Browse files
committed
Visit for hir::Ty.
1 parent 6b87d5c commit 5865d56

File tree

5 files changed

+55
-60
lines changed

5 files changed

+55
-60
lines changed

src/librustc/hir/intravisit.rs

+20-22
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ pub fn walk_poly_trait_ref<'v, V>(
450450
) where
451451
V: Visitor<'v>,
452452
{
453-
walk_list!(visitor, visit_generic_param, &trait_ref.bound_generic_params);
453+
walk_list!(visitor, visit_generic_param, trait_ref.bound_generic_params);
454454
visitor.visit_trait_ref(&trait_ref.trait_ref);
455455
}
456456

@@ -509,7 +509,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
509509
visitor.visit_ty(ty);
510510
visitor.visit_generics(generics)
511511
}
512-
ItemKind::OpaqueTy(OpaqueTy { ref generics, ref bounds, .. }) => {
512+
ItemKind::OpaqueTy(OpaqueTy { ref generics, bounds, .. }) => {
513513
visitor.visit_id(item.hir_id);
514514
walk_generics(visitor, generics);
515515
walk_list!(visitor, visit_param_bound, bounds);
@@ -538,13 +538,13 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
538538
item.span,
539539
);
540540
}
541-
ItemKind::Trait(.., ref generics, ref bounds, trait_item_refs) => {
541+
ItemKind::Trait(.., ref generics, bounds, trait_item_refs) => {
542542
visitor.visit_id(item.hir_id);
543543
visitor.visit_generics(generics);
544544
walk_list!(visitor, visit_param_bound, bounds);
545545
walk_list!(visitor, visit_trait_item_ref, trait_item_refs);
546546
}
547-
ItemKind::TraitAlias(ref generics, ref bounds) => {
547+
ItemKind::TraitAlias(ref generics, bounds) => {
548548
visitor.visit_id(item.hir_id);
549549
visitor.visit_generics(generics);
550550
walk_list!(visitor, visit_param_bound, bounds);
@@ -598,25 +598,25 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) {
598598
visitor.visit_ty(&mutable_type.ty)
599599
}
600600
TyKind::Never => {}
601-
TyKind::Tup(ref tuple_element_types) => {
601+
TyKind::Tup(tuple_element_types) => {
602602
walk_list!(visitor, visit_ty, tuple_element_types);
603603
}
604604
TyKind::BareFn(ref function_declaration) => {
605-
walk_list!(visitor, visit_generic_param, &function_declaration.generic_params);
605+
walk_list!(visitor, visit_generic_param, function_declaration.generic_params);
606606
visitor.visit_fn_decl(&function_declaration.decl);
607607
}
608608
TyKind::Path(ref qpath) => {
609609
visitor.visit_qpath(qpath, typ.hir_id, typ.span);
610610
}
611-
TyKind::Def(item_id, ref lifetimes) => {
611+
TyKind::Def(item_id, lifetimes) => {
612612
visitor.visit_nested_item(item_id);
613613
walk_list!(visitor, visit_generic_arg, lifetimes);
614614
}
615615
TyKind::Array(ref ty, ref length) => {
616616
visitor.visit_ty(ty);
617617
visitor.visit_anon_const(length)
618618
}
619-
TyKind::TraitObject(ref bounds, ref lifetime) => {
619+
TyKind::TraitObject(bounds, ref lifetime) => {
620620
for bound in bounds {
621621
visitor.visit_poly_trait_ref(bound, TraitBoundModifier::None);
622622
}
@@ -648,7 +648,7 @@ pub fn walk_qpath<'v, V: Visitor<'v>>(
648648
}
649649

650650
pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>) {
651-
for segment in &path.segments {
651+
for segment in path.segments {
652652
visitor.visit_path_segment(path.span, segment);
653653
}
654654
}
@@ -673,7 +673,7 @@ pub fn walk_generic_args<'v, V: Visitor<'v>>(
673673
generic_args: &'v GenericArgs<'v>,
674674
) {
675675
walk_list!(visitor, visit_generic_arg, &generic_args.args);
676-
walk_list!(visitor, visit_assoc_type_binding, &generic_args.bindings);
676+
walk_list!(visitor, visit_assoc_type_binding, generic_args.bindings);
677677
}
678678

679679
pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(
@@ -686,7 +686,7 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(
686686
TypeBindingKind::Equality { ref ty } => {
687687
visitor.visit_ty(ty);
688688
}
689-
TypeBindingKind::Constraint { ref bounds } => {
689+
TypeBindingKind::Constraint { bounds } => {
690690
walk_list!(visitor, visit_param_bound, bounds);
691691
}
692692
}
@@ -766,7 +766,7 @@ pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericB
766766

767767
pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v GenericParam<'v>) {
768768
visitor.visit_id(param.hir_id);
769-
walk_list!(visitor, visit_attribute, &param.attrs);
769+
walk_list!(visitor, visit_attribute, param.attrs);
770770
match param.name {
771771
ParamName::Plain(ident) => visitor.visit_ident(ident),
772772
ParamName::Error | ParamName::Fresh(_) => {}
@@ -776,12 +776,12 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Generi
776776
GenericParamKind::Type { ref default, .. } => walk_list!(visitor, visit_ty, default),
777777
GenericParamKind::Const { ref ty } => visitor.visit_ty(ty),
778778
}
779-
walk_list!(visitor, visit_param_bound, &param.bounds);
779+
walk_list!(visitor, visit_param_bound, param.bounds);
780780
}
781781

782782
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics<'v>) {
783783
walk_list!(visitor, visit_generic_param, &generics.params);
784-
walk_list!(visitor, visit_where_predicate, &generics.where_clause.predicates);
784+
walk_list!(visitor, visit_where_predicate, generics.where_clause.predicates);
785785
}
786786

787787
pub fn walk_where_predicate<'v, V: Visitor<'v>>(
@@ -791,17 +791,15 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
791791
match predicate {
792792
&WherePredicate::BoundPredicate(WhereBoundPredicate {
793793
ref bounded_ty,
794-
ref bounds,
795-
ref bound_generic_params,
794+
bounds,
795+
bound_generic_params,
796796
..
797797
}) => {
798798
visitor.visit_ty(bounded_ty);
799799
walk_list!(visitor, visit_param_bound, bounds);
800800
walk_list!(visitor, visit_generic_param, bound_generic_params);
801801
}
802-
&WherePredicate::RegionPredicate(WhereRegionPredicate {
803-
ref lifetime, ref bounds, ..
804-
}) => {
802+
&WherePredicate::RegionPredicate(WhereRegionPredicate { ref lifetime, bounds, .. }) => {
805803
visitor.visit_lifetime(lifetime);
806804
walk_list!(visitor, visit_param_bound, bounds);
807805
}
@@ -822,7 +820,7 @@ pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionR
822820
}
823821

824822
pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl<'v>) {
825-
for ty in &function_declaration.inputs {
823+
for ty in function_declaration.inputs {
826824
visitor.visit_ty(ty)
827825
}
828826
walk_fn_ret_ty(visitor, &function_declaration.output)
@@ -877,7 +875,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
877875
trait_item.hir_id,
878876
);
879877
}
880-
TraitItemKind::Type(ref bounds, ref default) => {
878+
TraitItemKind::Type(bounds, ref default) => {
881879
visitor.visit_id(trait_item.hir_id);
882880
walk_list!(visitor, visit_param_bound, bounds);
883881
walk_list!(visitor, visit_ty, default);
@@ -931,7 +929,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
931929
visitor.visit_id(impl_item.hir_id);
932930
visitor.visit_ty(ty);
933931
}
934-
ImplItemKind::OpaqueTy(ref bounds) => {
932+
ImplItemKind::OpaqueTy(bounds) => {
935933
visitor.visit_id(impl_item.hir_id);
936934
walk_list!(visitor, visit_param_bound, bounds);
937935
}

src/librustc/hir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ pub struct GenericArgs<'hir> {
443443

444444
impl GenericArgs<'_> {
445445
pub const fn none() -> Self {
446-
Self { args: HirVec::new(), bindings: HirVec::new(), parenthesized: false }
446+
Self { args: HirVec::new(), bindings: &[], parenthesized: false }
447447
}
448448

449449
pub fn is_empty(&self) -> bool {
@@ -580,7 +580,7 @@ impl Generics<'hir> {
580580
pub const fn empty() -> Generics<'hir> {
581581
Generics {
582582
params: HirVec::new(),
583-
where_clause: WhereClause { predicates: HirVec::new(), span: DUMMY_SP },
583+
where_clause: WhereClause { predicates: &[], span: DUMMY_SP },
584584
span: DUMMY_SP,
585585
}
586586
}

src/librustc/hir/print.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use syntax::util::parser::{self, AssocOp, Fixity};
1010
use syntax_pos::{self, BytePos, FileName};
1111

1212
use crate::hir;
13+
use crate::hir::HirVec;
1314
use crate::hir::{GenericArg, GenericParam, GenericParamKind};
1415
use crate::hir::{GenericBound, PatKind, RangeEnd, TraitBoundModifier};
1516

@@ -307,7 +308,7 @@ impl<'a> State<'a> {
307308
}
308309
hir::TyKind::Def(..) => {}
309310
hir::TyKind::Path(ref qpath) => self.print_qpath(qpath, false),
310-
hir::TyKind::TraitObject(ref bounds, ref lifetime) => {
311+
hir::TyKind::TraitObject(bounds, ref lifetime) => {
311312
let mut first = true;
312313
for bound in bounds {
313314
if first {
@@ -418,7 +419,7 @@ impl<'a> State<'a> {
418419
fn print_associated_type(
419420
&mut self,
420421
ident: ast::Ident,
421-
bounds: Option<&hir::GenericBounds<'_>>,
422+
bounds: Option<hir::GenericBounds<'_>>,
422423
ty: Option<&hir::Ty<'_>>,
423424
) {
424425
self.word_space("type");
@@ -891,7 +892,7 @@ impl<'a> State<'a> {
891892
hir::ImplItemKind::TyAlias(ref ty) => {
892893
self.print_associated_type(ii.ident, None, Some(ty));
893894
}
894-
hir::ImplItemKind::OpaqueTy(ref bounds) => {
895+
hir::ImplItemKind::OpaqueTy(bounds) => {
895896
self.word_space("type");
896897
self.print_ident(ii.ident);
897898
self.print_bounds("= impl", bounds);
@@ -1586,7 +1587,7 @@ impl<'a> State<'a> {
15861587
self.word_space("=");
15871588
self.print_type(ty);
15881589
}
1589-
hir::TypeBindingKind::Constraint { ref bounds } => {
1590+
hir::TypeBindingKind::Constraint { bounds } => {
15901591
self.print_bounds(":", bounds);
15911592
}
15921593
}
@@ -1953,9 +1954,9 @@ impl<'a> State<'a> {
19531954
match param.kind {
19541955
GenericParamKind::Lifetime { .. } => {
19551956
let mut sep = ":";
1956-
for bound in &param.bounds {
1957+
for bound in param.bounds {
19571958
match bound {
1958-
GenericBound::Outlives(lt) => {
1959+
GenericBound::Outlives(ref lt) => {
19591960
self.s.word(sep);
19601961
self.print_lifetime(lt);
19611962
sep = "+";
@@ -1965,7 +1966,7 @@ impl<'a> State<'a> {
19651966
}
19661967
}
19671968
GenericParamKind::Type { ref default, .. } => {
1968-
self.print_bounds(":", &param.bounds);
1969+
self.print_bounds(":", param.bounds);
19691970
match default {
19701971
Some(default) => {
19711972
self.s.space();
@@ -2003,7 +2004,7 @@ impl<'a> State<'a> {
20032004
&hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate {
20042005
ref bound_generic_params,
20052006
ref bounded_ty,
2006-
ref bounds,
2007+
bounds,
20072008
..
20082009
}) => {
20092010
self.print_formal_generic_params(bound_generic_params);
@@ -2096,11 +2097,8 @@ impl<'a> State<'a> {
20962097
self.print_generic_params(generic_params);
20972098
}
20982099
let generics = hir::Generics {
2099-
params: hir::HirVec::new(),
2100-
where_clause: hir::WhereClause {
2101-
predicates: hir::HirVec::new(),
2102-
span: syntax_pos::DUMMY_SP,
2103-
},
2100+
params: HirVec::new(),
2101+
where_clause: hir::WhereClause { predicates: &[], span: syntax_pos::DUMMY_SP },
21042102
span: syntax_pos::DUMMY_SP,
21052103
};
21062104
self.print_fn(

src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
103103
return;
104104
}
105105

106-
hir::TyKind::TraitObject(ref bounds, _) => {
106+
hir::TyKind::TraitObject(bounds, _) => {
107107
for bound in bounds {
108108
self.current_index.shift_in(1);
109109
self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None);

0 commit comments

Comments
 (0)