pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v GenericParam) {
visitor.visit_id(param.id);
match param.kind {
- GenericParamKind::Lifetime { ref bounds, ref lifetime, .. } => {
- match lifetime.name {
+ GenericParamKind::Lifetime { ref lt_name, .. } => {
+ match lt_name {
LifetimeName::Name(name) => {
- visitor.visit_name(param.span, name);
+ visitor.visit_name(param.span, *name);
}
LifetimeName::Fresh(_) |
LifetimeName::Static |
LifetimeName::Implicit |
LifetimeName::Underscore => {}
}
- walk_list!(visitor, visit_lifetime, bounds);
}
- GenericParamKind::Type { name, ref bounds, ref default, ref attrs, .. } => {
- visitor.visit_name(param.span, name);
+ GenericParamKind::Type { ref default, ref attrs, .. } => {
+ visitor.visit_name(param.span, param.name);
walk_list!(visitor, visit_ty, default);
walk_list!(visitor, visit_attribute, attrs.iter());
}
fn lower_parenthesized_parameter_data(
&mut self,
- data: &ParenthesizedParameterData,
- ) -> (hir::PathParameters, bool) {
+ data: &ParenthesizedArgData,
+ ) -> (hir::GenericArgs, bool) {
// Switch to `PassThrough` mode for anonymous lifetimes: this
// means that we permit things like `&Ref<T>`, where `Ref` has
// a hidden lifetime parameter. This is needed for backwards
AnonymousLifetimeMode::PassThrough,
|this| {
const DISALLOWED: ImplTraitContext = ImplTraitContext::Disallowed;
- let &ParenthesizedParameterData { ref inputs, ref output, span } = data;
+ let &ParenthesizedArgData { ref inputs, ref output, span } = data;
let inputs = inputs.iter().map(|ty| this.lower_ty(ty, DISALLOWED)).collect();
let mk_tup = |this: &mut Self, tys, span| {
let LoweredNodeId { node_id, hir_id } = this.next_id();
(
hir::GenericArgs {
- parameters: hir_vec![GenericArg::Type(mk_tup(this, inputs, span))],
+ args: hir_vec![GenericArg::Type(mk_tup(this, inputs, span))],
bindings: hir_vec![
hir::TypeBinding {
id: this.next_id().node_id,
}
fn visit_generic_param(&mut self, param: &'hir GenericParam) {
- match param.kind {
- GenericParamKind::Lifetime { ref lifetime_deprecated, .. } => {
- self.insert(param.id, NodeLifetime(lifetime_deprecated));
- }
- GenericParamKind::Type { .. } => {
- self.insert(param.id, NodeGenericParam(param));
- }
- }
+ self.insert(param.id, NodeGenericParam(param));
intravisit::walk_generic_param(self, param);
}
let depth = ty::INNERMOST;
let (name, def_id, origin) = new_region(hir_map, param);
debug!(
- "Region::late: def={:?} depth={:?} def_id={:?} origin={:?}",
- def,
+ "Region::late: param={:?} depth={:?} def_id={:?} origin={:?}",
+ param,
depth,
def_id,
origin,
for (i, (lifetime_i, lifetime_i_name)) in lifetimes.iter().enumerate() {
match lifetime_i_name {
hir::LifetimeName::Static | hir::LifetimeName::Underscore => {
- let lifetime = lifetime_i.lifetime;
- let name = lifetime_i.name();
+ let name = lifetime_i.name;
let mut err = struct_span_err!(
self.tcx.sess,
lifetime_i.span,
for param in &generics.params {
match param.kind {
- hir::GenericParamKind::Lifetime { .. } => {
+ hir::GenericParamKind::Lifetime { lt_name, .. } => {
if !param.bounds.is_empty() {
// `'a: 'b` means both `'a` and `'b` are referenced
- appears_in_where_clause.regions.insert(lifetime_def.lifetime.name);
+ appears_in_where_clause.regions.insert(lt_name);
}
}
hir::GenericParamKind::Type { .. } => {}
}
fn visit_generic_param(&mut self, param: &'a GenericParam) {
- if let GenericParam::Lifetime(ref ld) = *param {
- self.check_lifetime(ld.lifetime.ident);
+ if let GenericParamKind::Lifetime { .. } = param.kind {
+ self.check_lifetime(param.ident);
}
visit::walk_generic_param(self, param);
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct GenericParam {
- pub ident: Ident,
pub id: NodeId,
+ pub ident: Ident,
pub attrs: ThinVec<Attribute>,
pub bounds: ParamBounds,
noop_fold_ty(t, self)
}
+ fn fold_lifetime(&mut self, l: Lifetime) -> Lifetime {
+ noop_fold_lifetime(l, self)
+ }
+
fn fold_ty_binding(&mut self, t: TypeBinding) -> TypeBinding {
noop_fold_ty_binding(t, self)
}
noop_fold_variant_data(vdata, self)
}
- fn fold_ty_param(&mut self, tp: TyParam) -> TyParam {
- noop_fold_ty_param(tp, self)
- }
-
fn fold_generic_param(&mut self, param: GenericParam) -> GenericParam {
noop_fold_generic_param(param, self)
}
noop_fold_interpolated(nt, self)
}
- fn fold_opt_bounds(&mut self, b: Option<TyParamBounds>) -> Option<TyParamBounds> {
+ fn fold_opt_bounds(&mut self, b: Option<ParamBounds>) -> Option<ParamBounds> {
noop_fold_opt_bounds(b, self)
}
- fn fold_bounds(&mut self, b: ParamBounds)
- -> ParamBounds {
+ fn fold_bounds(&mut self, b: ParamBounds) -> ParamBounds {
noop_fold_bounds(b, self)
}
- fn fold_ty_param_bound(&mut self, tpb: ParamBound) -> ParamBound {
- noop_fold_ty_param_bound(tpb, self)
+ fn fold_param_bound(&mut self, tpb: ParamBound) -> ParamBound {
+ noop_fold_param_bound(tpb, self)
}
fn fold_mt(&mut self, mt: MutTy) -> MutTy {
TyKind::Typeof(fld.fold_anon_const(expr))
}
TyKind::TraitObject(bounds, syntax) => {
- TyKind::TraitObject(bounds.move_map(|b| fld.fold_ty_param_bound(b)), syntax)
+ TyKind::TraitObject(bounds.move_map(|b| fld.fold_param_bound(b)), syntax)
}
TyKind::ImplTrait(bounds) => {
- TyKind::ImplTrait(bounds.move_map(|b| fld.fold_ty_param_bound(b)))
+ TyKind::ImplTrait(bounds.move_map(|b| fld.fold_param_bound(b)))
}
TyKind::Mac(mac) => {
TyKind::Mac(fld.fold_mac(mac))
})
}
-pub fn noop_fold_ty_param_bound<T>(tpb: ParamBound, fld: &mut T)
- -> ParamBound
- where T: Folder {
- match tpb {
- TraitTyParamBound(ty, modifier) => TraitTyParamBound(fld.fold_poly_trait_ref(ty), modifier),
+pub fn noop_fold_param_bound<T>(pb: ParamBound, fld: &mut T) -> ParamBound where T: Folder {
+ match pb {
+ TraitTyParamBound(ty, modifier) => {
+ TraitTyParamBound(fld.fold_poly_trait_ref(ty), modifier)
+ }
Outlives(lifetime) => Outlives(noop_fold_lifetime(lifetime, fld)),
}
}
pub fn noop_fold_generic_param<T: Folder>(param: GenericParam, fld: &mut T) -> GenericParam {
- match param.kind {
- GenericParamKind::Lifetime { bounds, lifetime } => {
- let attrs: Vec<_> = param.attrs.into();
- GenericParamKind::Lifetime(LifetimeDef {
- attrs: attrs.into_iter()
+ let attrs: Vec<_> = param.attrs.into();
+ GenericParam {
+ ident: fld.fold_ident(param.ident),
+ id: fld.new_id(param.id),
+ attrs: attrs.into_iter()
.flat_map(|x| fld.fold_attribute(x).into_iter())
.collect::<Vec<_>>()
.into(),
- lifetime: Lifetime {
- id: fld.new_id(param.id),
- ident: fld.fold_ident(param.ident),
- },
- bounds: bounds.move_map(|l| noop_fold_lifetime(l, fld)),
- })
+ bounds: param.bounds.move_map(|l| noop_fold_param_bound(l, fld)),
+ kind: match param.kind {
+ GenericParamKind::Lifetime => GenericParamKind::Lifetime,
+ GenericParamKind::Type { default } => GenericParamKind::Type {
+ default: default.map(|ty| fld.fold_ty(ty))
+ }
}
- GenericParamKind::Type { .. } => GenericParamKind::Type(fld.fold_ty_param(param)),
}
}
ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate {
bound_generic_params: fld.fold_generic_params(bound_generic_params),
bounded_ty: fld.fold_ty(bounded_ty),
- bounds: bounds.move_map(|x| fld.fold_ty_param_bound(x)),
+ bounds: bounds.move_map(|x| fld.fold_param_bound(x)),
span: fld.new_span(span)
})
}
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
span: fld.new_span(span),
lifetime: noop_fold_lifetime(lifetime, fld),
- bounds: bounds.move_map(|bound| noop_fold_lifetime(bound, fld))
+ bounds: bounds.move_map(|bound| noop_fold_param_bound(bound, fld))
})
}
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{id,
fn noop_fold_bounds<T: Folder>(bounds: ParamBounds, folder: &mut T)
-> ParamBounds {
- bounds.move_map(|bound| folder.fold_ty_param_bound(bound))
+ bounds.move_map(|bound| folder.fold_param_bound(bound))
}
pub fn noop_fold_block<T: Folder>(b: P<Block>, folder: &mut T) -> P<Block> {
pub fn walk_generic_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a GenericParam) {
visitor.visit_ident(param.ident);
+ walk_list!(visitor, visit_param_bound, ¶m.bounds);
match param.kind {
- GenericParamKind::Lifetime { ref bounds, ref lifetime } => {
- walk_list!(visitor, visit_lifetime, bounds);
- }
- GenericParamKind::Type { ref bounds, ref default } => {
- visitor.visit_ident(t.ident);
- walk_list!(visitor, visit_ty_param_bound, bounds);
- walk_list!(visitor, visit_ty, default);
- }
+ GenericParamKind::Lifetime => {}
+ GenericParamKind::Type { ref default } => walk_list!(visitor, visit_ty, default),
}
walk_list!(visitor, visit_attribute, param.attrs.iter());
}