Skip to content

Commit 6b87d5c

Browse files
committed
Syntax for hir::Ty.
1 parent 66f9198 commit 6b87d5c

25 files changed

+429
-386
lines changed

src/librustc/arena.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,21 @@ macro_rules! arena_types {
132132
[] expr: rustc::hir::Expr<$tcx>,
133133
[] field: rustc::hir::Field<$tcx>,
134134
[] field_pat: rustc::hir::FieldPat<$tcx>,
135-
[] fn_decl: rustc::hir::FnDecl,
135+
[] fn_decl: rustc::hir::FnDecl<$tcx>,
136136
[] foreign_item: rustc::hir::ForeignItem<$tcx>,
137-
[] impl_item_ref: rustc::hir::ImplItemRef,
137+
[] impl_item_ref: rustc::hir::ImplItemRef<$tcx>,
138138
[] inline_asm: rustc::hir::InlineAsm<$tcx>,
139139
[] local: rustc::hir::Local<$tcx>,
140140
[few] macro_def: rustc::hir::MacroDef<$tcx>,
141141
[] param: rustc::hir::Param<$tcx>,
142142
[] pat: rustc::hir::Pat<$tcx>,
143-
[] path: rustc::hir::Path,
144-
[] path_segment: rustc::hir::PathSegment,
145-
[] qpath: rustc::hir::QPath,
143+
[] path: rustc::hir::Path<$tcx>,
144+
[] path_segment: rustc::hir::PathSegment<$tcx>,
145+
[] qpath: rustc::hir::QPath<$tcx>,
146146
[] stmt: rustc::hir::Stmt<$tcx>,
147147
[] struct_field: rustc::hir::StructField<$tcx>,
148148
[] trait_item_ref: rustc::hir::TraitItemRef,
149-
[] ty: rustc::hir::Ty,
149+
[] ty: rustc::hir::Ty<$tcx>,
150150
[] variant: rustc::hir::Variant<$tcx>,
151151
], $tcx);
152152
)

src/librustc/hir/intravisit.rs

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ use syntax_pos::Span;
4242
#[derive(Copy, Clone)]
4343
pub enum FnKind<'a> {
4444
/// `#[xxx] pub async/const/extern "Abi" fn foo()`
45-
ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
45+
ItemFn(Ident, &'a Generics<'a>, FnHeader, &'a Visibility<'a>, &'a [Attribute]),
4646

4747
/// `fn foo(&self)`
48-
Method(Ident, &'a FnSig<'a>, Option<&'a Visibility>, &'a [Attribute]),
48+
Method(Ident, &'a FnSig<'a>, Option<&'a Visibility<'a>>, &'a [Attribute]),
4949

5050
/// `|x, y| {}`
5151
Closure(&'a [Attribute]),
@@ -274,25 +274,25 @@ pub trait Visitor<'v>: Sized {
274274
fn visit_expr(&mut self, ex: &'v Expr<'v>) {
275275
walk_expr(self, ex)
276276
}
277-
fn visit_ty(&mut self, t: &'v Ty) {
277+
fn visit_ty(&mut self, t: &'v Ty<'v>) {
278278
walk_ty(self, t)
279279
}
280-
fn visit_generic_param(&mut self, p: &'v GenericParam) {
280+
fn visit_generic_param(&mut self, p: &'v GenericParam<'v>) {
281281
walk_generic_param(self, p)
282282
}
283-
fn visit_generics(&mut self, g: &'v Generics) {
283+
fn visit_generics(&mut self, g: &'v Generics<'v>) {
284284
walk_generics(self, g)
285285
}
286-
fn visit_where_predicate(&mut self, predicate: &'v WherePredicate) {
286+
fn visit_where_predicate(&mut self, predicate: &'v WherePredicate<'v>) {
287287
walk_where_predicate(self, predicate)
288288
}
289-
fn visit_fn_decl(&mut self, fd: &'v FnDecl) {
289+
fn visit_fn_decl(&mut self, fd: &'v FnDecl<'v>) {
290290
walk_fn_decl(self, fd)
291291
}
292-
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: BodyId, s: Span, id: HirId) {
292+
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl<'v>, b: BodyId, s: Span, id: HirId) {
293293
walk_fn(self, fk, fd, b, s, id)
294294
}
295-
fn visit_use(&mut self, path: &'v Path, hir_id: HirId) {
295+
fn visit_use(&mut self, path: &'v Path<'v>, hir_id: HirId) {
296296
walk_use(self, path, hir_id)
297297
}
298298
fn visit_trait_item(&mut self, ti: &'v TraitItem<'v>) {
@@ -304,23 +304,23 @@ pub trait Visitor<'v>: Sized {
304304
fn visit_impl_item(&mut self, ii: &'v ImplItem<'v>) {
305305
walk_impl_item(self, ii)
306306
}
307-
fn visit_impl_item_ref(&mut self, ii: &'v ImplItemRef) {
307+
fn visit_impl_item_ref(&mut self, ii: &'v ImplItemRef<'v>) {
308308
walk_impl_item_ref(self, ii)
309309
}
310-
fn visit_trait_ref(&mut self, t: &'v TraitRef) {
310+
fn visit_trait_ref(&mut self, t: &'v TraitRef<'v>) {
311311
walk_trait_ref(self, t)
312312
}
313-
fn visit_param_bound(&mut self, bounds: &'v GenericBound) {
313+
fn visit_param_bound(&mut self, bounds: &'v GenericBound<'v>) {
314314
walk_param_bound(self, bounds)
315315
}
316-
fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: TraitBoundModifier) {
316+
fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef<'v>, m: TraitBoundModifier) {
317317
walk_poly_trait_ref(self, t, m)
318318
}
319319
fn visit_variant_data(
320320
&mut self,
321321
s: &'v VariantData<'v>,
322322
_: Name,
323-
_: &'v Generics,
323+
_: &'v Generics<'v>,
324324
_parent_id: HirId,
325325
_: Span,
326326
) {
@@ -332,19 +332,19 @@ pub trait Visitor<'v>: Sized {
332332
fn visit_enum_def(
333333
&mut self,
334334
enum_definition: &'v EnumDef<'v>,
335-
generics: &'v Generics,
335+
generics: &'v Generics<'v>,
336336
item_id: HirId,
337337
_: Span,
338338
) {
339339
walk_enum_def(self, enum_definition, generics, item_id)
340340
}
341-
fn visit_variant(&mut self, v: &'v Variant<'v>, g: &'v Generics, item_id: HirId) {
341+
fn visit_variant(&mut self, v: &'v Variant<'v>, g: &'v Generics<'v>, item_id: HirId) {
342342
walk_variant(self, v, g, item_id)
343343
}
344344
fn visit_label(&mut self, label: &'v Label) {
345345
walk_label(self, label)
346346
}
347-
fn visit_generic_arg(&mut self, generic_arg: &'v GenericArg) {
347+
fn visit_generic_arg(&mut self, generic_arg: &'v GenericArg<'v>) {
348348
match generic_arg {
349349
GenericArg::Lifetime(lt) => self.visit_lifetime(lt),
350350
GenericArg::Type(ty) => self.visit_ty(ty),
@@ -354,26 +354,26 @@ pub trait Visitor<'v>: Sized {
354354
fn visit_lifetime(&mut self, lifetime: &'v Lifetime) {
355355
walk_lifetime(self, lifetime)
356356
}
357-
fn visit_qpath(&mut self, qpath: &'v QPath, id: HirId, span: Span) {
357+
fn visit_qpath(&mut self, qpath: &'v QPath<'v>, id: HirId, span: Span) {
358358
walk_qpath(self, qpath, id, span)
359359
}
360-
fn visit_path(&mut self, path: &'v Path, _id: HirId) {
360+
fn visit_path(&mut self, path: &'v Path<'v>, _id: HirId) {
361361
walk_path(self, path)
362362
}
363-
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) {
363+
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment<'v>) {
364364
walk_path_segment(self, path_span, path_segment)
365365
}
366-
fn visit_generic_args(&mut self, path_span: Span, generic_args: &'v GenericArgs) {
366+
fn visit_generic_args(&mut self, path_span: Span, generic_args: &'v GenericArgs<'v>) {
367367
walk_generic_args(self, path_span, generic_args)
368368
}
369-
fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding) {
369+
fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding<'v>) {
370370
walk_assoc_type_binding(self, type_binding)
371371
}
372372
fn visit_attribute(&mut self, _attr: &'v Attribute) {}
373373
fn visit_macro_def(&mut self, macro_def: &'v MacroDef<'v>) {
374374
walk_macro_def(self, macro_def)
375375
}
376-
fn visit_vis(&mut self, vis: &'v Visibility) {
376+
fn visit_vis(&mut self, vis: &'v Visibility<'v>) {
377377
walk_vis(self, vis)
378378
}
379379
fn visit_associated_item_kind(&mut self, kind: &'v AssocItemKind) {
@@ -445,7 +445,7 @@ pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime
445445

446446
pub fn walk_poly_trait_ref<'v, V>(
447447
visitor: &mut V,
448-
trait_ref: &'v PolyTraitRef,
448+
trait_ref: &'v PolyTraitRef<'v>,
449449
_modifier: TraitBoundModifier,
450450
) where
451451
V: Visitor<'v>,
@@ -454,7 +454,7 @@ pub fn walk_poly_trait_ref<'v, V>(
454454
visitor.visit_trait_ref(&trait_ref.trait_ref);
455455
}
456456

457-
pub fn walk_trait_ref<'v, V>(visitor: &mut V, trait_ref: &'v TraitRef)
457+
pub fn walk_trait_ref<'v, V>(visitor: &mut V, trait_ref: &'v TraitRef<'v>)
458458
where
459459
V: Visitor<'v>,
460460
{
@@ -553,15 +553,15 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
553553
walk_list!(visitor, visit_attribute, item.attrs);
554554
}
555555

556-
pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path, hir_id: HirId) {
556+
pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>, hir_id: HirId) {
557557
visitor.visit_id(hir_id);
558558
visitor.visit_path(path, hir_id);
559559
}
560560

561561
pub fn walk_enum_def<'v, V: Visitor<'v>>(
562562
visitor: &mut V,
563563
enum_definition: &'v EnumDef<'v>,
564-
generics: &'v Generics,
564+
generics: &'v Generics<'v>,
565565
item_id: HirId,
566566
) {
567567
visitor.visit_id(item_id);
@@ -571,7 +571,7 @@ pub fn walk_enum_def<'v, V: Visitor<'v>>(
571571
pub fn walk_variant<'v, V: Visitor<'v>>(
572572
visitor: &mut V,
573573
variant: &'v Variant<'v>,
574-
generics: &'v Generics,
574+
generics: &'v Generics<'v>,
575575
parent_item_id: HirId,
576576
) {
577577
visitor.visit_ident(variant.ident);
@@ -587,7 +587,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(
587587
walk_list!(visitor, visit_attribute, variant.attrs);
588588
}
589589

590-
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
590+
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) {
591591
visitor.visit_id(typ.hir_id);
592592

593593
match typ.kind {
@@ -627,7 +627,12 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
627627
}
628628
}
629629

630-
pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath, id: HirId, span: Span) {
630+
pub fn walk_qpath<'v, V: Visitor<'v>>(
631+
visitor: &mut V,
632+
qpath: &'v QPath<'v>,
633+
id: HirId,
634+
span: Span,
635+
) {
631636
match *qpath {
632637
QPath::Resolved(ref maybe_qself, ref path) => {
633638
if let Some(ref qself) = *maybe_qself {
@@ -642,7 +647,7 @@ pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath, id: Hir
642647
}
643648
}
644649

645-
pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) {
650+
pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>) {
646651
for segment in &path.segments {
647652
visitor.visit_path_segment(path.span, segment);
648653
}
@@ -651,7 +656,7 @@ pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) {
651656
pub fn walk_path_segment<'v, V: Visitor<'v>>(
652657
visitor: &mut V,
653658
path_span: Span,
654-
segment: &'v PathSegment,
659+
segment: &'v PathSegment<'v>,
655660
) {
656661
visitor.visit_ident(segment.ident);
657662
if let Some(id) = segment.hir_id {
@@ -665,13 +670,16 @@ pub fn walk_path_segment<'v, V: Visitor<'v>>(
665670
pub fn walk_generic_args<'v, V: Visitor<'v>>(
666671
visitor: &mut V,
667672
_path_span: Span,
668-
generic_args: &'v GenericArgs,
673+
generic_args: &'v GenericArgs<'v>,
669674
) {
670675
walk_list!(visitor, visit_generic_arg, &generic_args.args);
671676
walk_list!(visitor, visit_assoc_type_binding, &generic_args.bindings);
672677
}
673678

674-
pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V, type_binding: &'v TypeBinding) {
679+
pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(
680+
visitor: &mut V,
681+
type_binding: &'v TypeBinding<'v>,
682+
) {
675683
visitor.visit_id(type_binding.hir_id);
676684
visitor.visit_ident(type_binding.ident);
677685
match type_binding.kind {
@@ -747,7 +755,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v
747755
walk_list!(visitor, visit_attribute, foreign_item.attrs);
748756
}
749757

750-
pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericBound) {
758+
pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericBound<'v>) {
751759
match *bound {
752760
GenericBound::Trait(ref typ, modifier) => {
753761
visitor.visit_poly_trait_ref(typ, modifier);
@@ -756,7 +764,7 @@ pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericB
756764
}
757765
}
758766

759-
pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v GenericParam) {
767+
pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v GenericParam<'v>) {
760768
visitor.visit_id(param.hir_id);
761769
walk_list!(visitor, visit_attribute, &param.attrs);
762770
match param.name {
@@ -771,12 +779,15 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Generi
771779
walk_list!(visitor, visit_param_bound, &param.bounds);
772780
}
773781

774-
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) {
782+
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics<'v>) {
775783
walk_list!(visitor, visit_generic_param, &generics.params);
776784
walk_list!(visitor, visit_where_predicate, &generics.where_clause.predicates);
777785
}
778786

779-
pub fn walk_where_predicate<'v, V: Visitor<'v>>(visitor: &mut V, predicate: &'v WherePredicate) {
787+
pub fn walk_where_predicate<'v, V: Visitor<'v>>(
788+
visitor: &mut V,
789+
predicate: &'v WherePredicate<'v>,
790+
) {
780791
match predicate {
781792
&WherePredicate::BoundPredicate(WhereBoundPredicate {
782793
ref bounded_ty,
@@ -804,13 +815,13 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(visitor: &mut V, predicate: &'v
804815
}
805816
}
806817

807-
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionRetTy) {
818+
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionRetTy<'v>) {
808819
if let Return(ref output_ty) = *ret_ty {
809820
visitor.visit_ty(output_ty)
810821
}
811822
}
812823

813-
pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl) {
824+
pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl<'v>) {
814825
for ty in &function_declaration.inputs {
815826
visitor.visit_ty(ty)
816827
}
@@ -829,7 +840,7 @@ pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V, function_kind: FnKind<'
829840
pub fn walk_fn<'v, V: Visitor<'v>>(
830841
visitor: &mut V,
831842
function_kind: FnKind<'v>,
832-
function_declaration: &'v FnDecl,
843+
function_declaration: &'v FnDecl<'v>,
833844
body_id: BodyId,
834845
_span: Span,
835846
id: HirId,
@@ -927,7 +938,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
927938
}
928939
}
929940

930-
pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef) {
941+
pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef<'v>) {
931942
// N.B., deliberately force a compilation error if/when new fields are added.
932943
let ImplItemRef { id, ident, ref kind, span: _, ref vis, ref defaultness } = *impl_item_ref;
933944
visitor.visit_nested_impl_item(id);
@@ -1099,7 +1110,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
10991110
walk_list!(visitor, visit_attribute, arm.attrs);
11001111
}
11011112

1102-
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
1113+
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility<'v>) {
11031114
if let VisibilityKind::Restricted { ref path, hir_id } = vis.node {
11041115
visitor.visit_id(hir_id);
11051116
visitor.visit_path(path, hir_id)

0 commit comments

Comments
 (0)