diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-11-12 12:30:52 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-11-18 19:22:17 -0500 |
| commit | 6ccd390dbd4288dccf7f5d3e8a2cc3a75e9ef5fb (patch) | |
| tree | caf349c1c8b6e143e6fd90f4ec34e8383c9e3c37 /src | |
| parent | 6913ed0f3c42f37b2b46043305ebae2e81e33548 (diff) | |
| download | rust-6ccd390dbd4288dccf7f5d3e8a2cc3a75e9ef5fb.tar.gz rust-6ccd390dbd4288dccf7f5d3e8a2cc3a75e9ef5fb.zip | |
rename `_lctx` to `lctx` where appropriate
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_front/lowering.rs | 419 |
1 files changed, 210 insertions, 209 deletions
diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index 8ef49d185f7..230fb93fd4d 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -138,17 +138,17 @@ impl<'a, 'hir> LoweringContext<'a> { } } -pub fn lower_view_path(_lctx: &LoweringContext, view_path: &ViewPath) -> P<hir::ViewPath> { +pub fn lower_view_path(lctx: &LoweringContext, view_path: &ViewPath) -> P<hir::ViewPath> { P(Spanned { node: match view_path.node { ViewPathSimple(ident, ref path) => { - hir::ViewPathSimple(ident.name, lower_path(_lctx, path)) + hir::ViewPathSimple(ident.name, lower_path(lctx, path)) } ViewPathGlob(ref path) => { - hir::ViewPathGlob(lower_path(_lctx, path)) + hir::ViewPathGlob(lower_path(lctx, path)) } ViewPathList(ref path, ref path_list_idents) => { - hir::ViewPathList(lower_path(_lctx, path), + hir::ViewPathList(lower_path(lctx, path), path_list_idents.iter() .map(|path_list_ident| { Spanned { @@ -175,79 +175,79 @@ pub fn lower_view_path(_lctx: &LoweringContext, view_path: &ViewPath) -> P<hir:: }) } -pub fn lower_arm(_lctx: &LoweringContext, arm: &Arm) -> hir::Arm { +pub fn lower_arm(lctx: &LoweringContext, arm: &Arm) -> hir::Arm { hir::Arm { attrs: arm.attrs.clone(), - pats: arm.pats.iter().map(|x| lower_pat(_lctx, x)).collect(), - guard: arm.guard.as_ref().map(|ref x| lower_expr(_lctx, x)), - body: lower_expr(_lctx, &arm.body), + pats: arm.pats.iter().map(|x| lower_pat(lctx, x)).collect(), + guard: arm.guard.as_ref().map(|ref x| lower_expr(lctx, x)), + body: lower_expr(lctx, &arm.body), } } -pub fn lower_decl(_lctx: &LoweringContext, d: &Decl) -> P<hir::Decl> { +pub fn lower_decl(lctx: &LoweringContext, d: &Decl) -> P<hir::Decl> { match d.node { DeclLocal(ref l) => P(Spanned { - node: hir::DeclLocal(lower_local(_lctx, l)), + node: hir::DeclLocal(lower_local(lctx, l)), span: d.span, }), DeclItem(ref it) => P(Spanned { - node: hir::DeclItem(lower_item(_lctx, it)), + node: hir::DeclItem(lower_item(lctx, it)), span: d.span, }), } } -pub fn lower_ty_binding(_lctx: &LoweringContext, b: &TypeBinding) -> P<hir::TypeBinding> { +pub fn lower_ty_binding(lctx: &LoweringContext, b: &TypeBinding) -> P<hir::TypeBinding> { P(hir::TypeBinding { id: b.id, name: b.ident.name, - ty: lower_ty(_lctx, &b.ty), + ty: lower_ty(lctx, &b.ty), span: b.span, }) } -pub fn lower_ty(_lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> { +pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> { P(hir::Ty { id: t.id, node: match t.node { TyInfer => hir::TyInfer, - TyVec(ref ty) => hir::TyVec(lower_ty(_lctx, ty)), - TyPtr(ref mt) => hir::TyPtr(lower_mt(_lctx, mt)), + TyVec(ref ty) => hir::TyVec(lower_ty(lctx, ty)), + TyPtr(ref mt) => hir::TyPtr(lower_mt(lctx, mt)), TyRptr(ref region, ref mt) => { - hir::TyRptr(lower_opt_lifetime(_lctx, region), lower_mt(_lctx, mt)) + hir::TyRptr(lower_opt_lifetime(lctx, region), lower_mt(lctx, mt)) } TyBareFn(ref f) => { hir::TyBareFn(P(hir::BareFnTy { - lifetimes: lower_lifetime_defs(_lctx, &f.lifetimes), - unsafety: lower_unsafety(_lctx, f.unsafety), + lifetimes: lower_lifetime_defs(lctx, &f.lifetimes), + unsafety: lower_unsafety(lctx, f.unsafety), abi: f.abi, - decl: lower_fn_decl(_lctx, &f.decl), + decl: lower_fn_decl(lctx, &f.decl), })) } - TyTup(ref tys) => hir::TyTup(tys.iter().map(|ty| lower_ty(_lctx, ty)).collect()), + TyTup(ref tys) => hir::TyTup(tys.iter().map(|ty| lower_ty(lctx, ty)).collect()), TyParen(ref ty) => { - return lower_ty(_lctx, ty); + return lower_ty(lctx, ty); } TyPath(ref qself, ref path) => { let qself = qself.as_ref().map(|&QSelf { ref ty, position }| { hir::QSelf { - ty: lower_ty(_lctx, ty), + ty: lower_ty(lctx, ty), position: position, } }); - hir::TyPath(qself, lower_path(_lctx, path)) + hir::TyPath(qself, lower_path(lctx, path)) } TyObjectSum(ref ty, ref bounds) => { - hir::TyObjectSum(lower_ty(_lctx, ty), lower_bounds(_lctx, bounds)) + hir::TyObjectSum(lower_ty(lctx, ty), lower_bounds(lctx, bounds)) } TyFixedLengthVec(ref ty, ref e) => { - hir::TyFixedLengthVec(lower_ty(_lctx, ty), lower_expr(_lctx, e)) + hir::TyFixedLengthVec(lower_ty(lctx, ty), lower_expr(lctx, e)) } TyTypeof(ref expr) => { - hir::TyTypeof(lower_expr(_lctx, expr)) + hir::TyTypeof(lower_expr(lctx, expr)) } TyPolyTraitRef(ref bounds) => { - hir::TyPolyTraitRef(bounds.iter().map(|b| lower_ty_param_bound(_lctx, b)).collect()) + hir::TyPolyTraitRef(bounds.iter().map(|b| lower_ty_param_bound(lctx, b)).collect()) } TyMac(_) => panic!("TyMac should have been expanded by now."), }, @@ -255,26 +255,26 @@ pub fn lower_ty(_lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> { }) } -pub fn lower_foreign_mod(_lctx: &LoweringContext, fm: &ForeignMod) -> hir::ForeignMod { +pub fn lower_foreign_mod(lctx: &LoweringContext, fm: &ForeignMod) -> hir::ForeignMod { hir::ForeignMod { abi: fm.abi, - items: fm.items.iter().map(|x| lower_foreign_item(_lctx, x)).collect(), + items: fm.items.iter().map(|x| lower_foreign_item(lctx, x)).collect(), } } -pub fn lower_variant(_lctx: &LoweringContext, v: &Variant) -> P<hir::Variant> { +pub fn lower_variant(lctx: &LoweringContext, v: &Variant) -> P<hir::Variant> { P(Spanned { node: hir::Variant_ { name: v.node.name.name, attrs: v.node.attrs.clone(), - data: lower_variant_data(_lctx, &v.node.data), - disr_expr: v.node.disr_expr.as_ref().map(|e| lower_expr(_lctx, e)), + data: lower_variant_data(lctx, &v.node.data), + disr_expr: v.node.disr_expr.as_ref().map(|e| lower_expr(lctx, e)), }, span: v.span, }) } -pub fn lower_path(_lctx: &LoweringContext, p: &Path) -> hir::Path { +pub fn lower_path(lctx: &LoweringContext, p: &Path) -> hir::Path { hir::Path { global: p.global, segments: p.segments @@ -282,7 +282,7 @@ pub fn lower_path(_lctx: &LoweringContext, p: &Path) -> hir::Path { .map(|&PathSegment { identifier, ref parameters }| { hir::PathSegment { identifier: identifier, - parameters: lower_path_parameters(_lctx, parameters), + parameters: lower_path_parameters(lctx, parameters), } }) .collect(), @@ -290,62 +290,62 @@ pub fn lower_path(_lctx: &LoweringContext, p: &Path) -> hir::Path { } } -pub fn lower_path_parameters(_lctx: &LoweringContext, +pub fn lower_path_parameters(lctx: &LoweringContext, path_parameters: &PathParameters) -> hir::PathParameters { match *path_parameters { AngleBracketedParameters(ref data) => - hir::AngleBracketedParameters(lower_angle_bracketed_parameter_data(_lctx, data)), + hir::AngleBracketedParameters(lower_angle_bracketed_parameter_data(lctx, data)), ParenthesizedParameters(ref data) => - hir::ParenthesizedParameters(lower_parenthesized_parameter_data(_lctx, data)), + hir::ParenthesizedParameters(lower_parenthesized_parameter_data(lctx, data)), } } -pub fn lower_angle_bracketed_parameter_data(_lctx: &LoweringContext, +pub fn lower_angle_bracketed_parameter_data(lctx: &LoweringContext, data: &AngleBracketedParameterData) -> hir::AngleBracketedParameterData { let &AngleBracketedParameterData { ref lifetimes, ref types, ref bindings } = data; hir::AngleBracketedParameterData { - lifetimes: lower_lifetimes(_lctx, lifetimes), - types: types.iter().map(|ty| lower_ty(_lctx, ty)).collect(), - bindings: bindings.iter().map(|b| lower_ty_binding(_lctx, b)).collect(), + lifetimes: lower_lifetimes(lctx, lifetimes), + types: types.iter().map(|ty| lower_ty(lctx, ty)).collect(), + bindings: bindings.iter().map(|b| lower_ty_binding(lctx, b)).collect(), } } -pub fn lower_parenthesized_parameter_data(_lctx: &LoweringContext, +pub fn lower_parenthesized_parameter_data(lctx: &LoweringContext, data: &ParenthesizedParameterData) -> hir::ParenthesizedParameterData { let &ParenthesizedParameterData { ref inputs, ref output, span } = data; hir::ParenthesizedParameterData { - inputs: inputs.iter().map(|ty| lower_ty(_lctx, ty)).collect(), - output: output.as_ref().map(|ty| lower_ty(_lctx, ty)), + inputs: inputs.iter().map(|ty| lower_ty(lctx, ty)).collect(), + output: output.as_ref().map(|ty| lower_ty(lctx, ty)), span: span, } } -pub fn lower_local(_lctx: &LoweringContext, l: &Local) -> P<hir::Local> { +pub fn lower_local(lctx: &LoweringContext, l: &Local) -> P<hir::Local> { P(hir::Local { id: l.id, - ty: l.ty.as_ref().map(|t| lower_ty(_lctx, t)), - pat: lower_pat(_lctx, &l.pat), - init: l.init.as_ref().map(|e| lower_expr(_lctx, e)), + ty: l.ty.as_ref().map(|t| lower_ty(lctx, t)), + pat: lower_pat(lctx, &l.pat), + init: l.init.as_ref().map(|e| lower_expr(lctx, e)), span: l.span, }) } -pub fn lower_explicit_self_underscore(_lctx: &LoweringContext, +pub fn lower_explicit_self_underscore(lctx: &LoweringContext, es: &ExplicitSelf_) -> hir::ExplicitSelf_ { match *es { SelfStatic => hir::SelfStatic, SelfValue(v) => hir::SelfValue(v.name), SelfRegion(ref lifetime, m, ident) => { - hir::SelfRegion(lower_opt_lifetime(_lctx, lifetime), - lower_mutability(_lctx, m), + hir::SelfRegion(lower_opt_lifetime(lctx, lifetime), + lower_mutability(lctx, m), ident.name) } SelfExplicit(ref typ, ident) => { - hir::SelfExplicit(lower_ty(_lctx, typ), ident.name) + hir::SelfExplicit(lower_ty(lctx, typ), ident.name) } } } @@ -357,26 +357,26 @@ pub fn lower_mutability(_lctx: &LoweringContext, m: Mutability) -> hir::Mutabili } } -pub fn lower_explicit_self(_lctx: &LoweringContext, s: &ExplicitSelf) -> hir::ExplicitSelf { +pub fn lower_explicit_self(lctx: &LoweringContext, s: &ExplicitSelf) -> hir::ExplicitSelf { Spanned { - node: lower_explicit_self_underscore(_lctx, &s.node), + node: lower_explicit_self_underscore(lctx, &s.node), span: s.span, } } -pub fn lower_arg(_lctx: &LoweringContext, arg: &Arg) -> hir::Arg { +pub fn lower_arg(lctx: &LoweringContext, arg: &Arg) -> hir::Arg { hir::Arg { id: arg.id, - pat: lower_pat(_lctx, &arg.pat), - ty: lower_ty(_lctx, &arg.ty), + pat: lower_pat(lctx, &arg.pat), + ty: lower_ty(lctx, &arg.ty), } } -pub fn lower_fn_decl(_lctx: &LoweringContext, decl: &FnDecl) -> P<hir::FnDecl> { +pub fn lower_fn_decl(lctx: &LoweringContext, decl: &FnDecl) -> P<hir::FnDecl> { P(hir::FnDecl { - inputs: decl.inputs.iter().map(|x| lower_arg(_lctx, x)).collect(), + inputs: decl.inputs.iter().map(|x| lower_arg(lctx, x)).collect(), output: match decl.output { - Return(ref ty) => hir::Return(lower_ty(_lctx, ty)), + Return(ref ty) => hir::Return(lower_ty(lctx, ty)), DefaultReturn(span) => hir::DefaultReturn(span), NoReturn(span) => hir::NoReturn(span), }, @@ -384,32 +384,32 @@ pub fn lower_fn_decl(_lctx: &LoweringContext, decl: &FnDecl) -> P<hir::FnDecl> { }) } -pub fn lower_ty_param_bound(_lctx: &LoweringContext, tpb: &TyParamBound) -> hir::TyParamBound { +pub fn lower_ty_param_bound(lctx: &LoweringContext, tpb: &TyParamBound) -> hir::TyParamBound { match *tpb { TraitTyParamBound(ref ty, modifier) => { - hir::TraitTyParamBound(lower_poly_trait_ref(_lctx, ty), - lower_trait_bound_modifier(_lctx, modifier)) + hir::TraitTyParamBound(lower_poly_trait_ref(lctx, ty), + lower_trait_bound_modifier(lctx, modifier)) } RegionTyParamBound(ref lifetime) => { - hir::RegionTyParamBound(lower_lifetime(_lctx, lifetime)) + hir::RegionTyParamBound(lower_lifetime(lctx, lifetime)) } } } -pub fn lower_ty_param(_lctx: &LoweringContext, tp: &TyParam) -> hir::TyParam { +pub fn lower_ty_param(lctx: &LoweringContext, tp: &TyParam) -> hir::TyParam { hir::TyParam { id: tp.id, name: tp.ident.name, - bounds: lower_bounds(_lctx, &tp.bounds), - default: tp.default.as_ref().map(|x| lower_ty(_lctx, x)), + bounds: lower_bounds(lctx, &tp.bounds), + default: tp.default.as_ref().map(|x| lower_ty(lctx, x)), span: tp.span, } } -pub fn lower_ty_params(_lctx: &LoweringContext, +pub fn lower_ty_params(lctx: &LoweringContext, tps: &OwnedSlice<TyParam>) -> OwnedSlice<hir::TyParam> { - tps.iter().map(|tp| lower_ty_param(_lctx, tp)).collect() + tps.iter().map(|tp| lower_ty_param(lctx, tp)).collect() } pub fn lower_lifetime(_lctx: &LoweringContext, l: &Lifetime) -> hir::Lifetime { @@ -420,48 +420,48 @@ pub fn lower_lifetime(_lctx: &LoweringContext, l: &Lifetime) -> hir::Lifetime { } } -pub fn lower_lifetime_def(_lctx: &LoweringContext, l: &LifetimeDef) -> hir::LifetimeDef { +pub fn lower_lifetime_def(lctx: &LoweringContext, l: &LifetimeDef) -> hir::LifetimeDef { hir::LifetimeDef { - lifetime: lower_lifetime(_lctx, &l.lifetime), - bounds: lower_lifetimes(_lctx, &l.bounds), + lifetime: lower_lifetime(lctx, &l.lifetime), + bounds: lower_lifetimes(lctx, &l.bounds), } } -pub fn lower_lifetimes(_lctx: &LoweringContext, lts: &Vec<Lifetime>) -> Vec<hir::Lifetime> { - lts.iter().map(|l| lower_lifetime(_lctx, l)).collect() +pub fn lower_lifetimes(lctx: &LoweringContext, lts: &Vec<Lifetime>) -> Vec<hir::Lifetime> { + lts.iter().map(|l| lower_lifetime(lctx, l)).collect() } -pub fn lower_lifetime_defs(_lctx: &LoweringContext, +pub fn lower_lifetime_defs(lctx: &LoweringContext, lts: &Vec<LifetimeDef>) -> Vec<hir::LifetimeDef> { - lts.iter().map(|l| lower_lifetime_def(_lctx, l)).collect() + lts.iter().map(|l| lower_lifetime_def(lctx, l)).collect() } -pub fn lower_opt_lifetime(_lctx: &LoweringContext, +pub fn lower_opt_lifetime(lctx: &LoweringContext, o_lt: &Option<Lifetime>) -> Option<hir::Lifetime> { - o_lt.as_ref().map(|lt| lower_lifetime(_lctx, lt)) + o_lt.as_ref().map(|lt| lower_lifetime(lctx, lt)) } -pub fn lower_generics(_lctx: &LoweringContext, g: &Generics) -> hir::Generics { +pub fn lower_generics(lctx: &LoweringContext, g: &Generics) -> hir::Generics { hir::Generics { - ty_params: lower_ty_params(_lctx, &g.ty_params), - lifetimes: lower_lifetime_defs(_lctx, &g.lifetimes), - where_clause: lower_where_clause(_lctx, &g.where_clause), + ty_params: lower_ty_params(lctx, &g.ty_params), + lifetimes: lower_lifetime_defs(lctx, &g.lifetimes), + where_clause: lower_where_clause(lctx, &g.where_clause), } } -pub fn lower_where_clause(_lctx: &LoweringContext, wc: &WhereClause) -> hir::WhereClause { +pub fn lower_where_clause(lctx: &LoweringContext, wc: &WhereClause) -> hir::WhereClause { hir::WhereClause { id: wc.id, predicates: wc.predicates .iter() - .map(|predicate| lower_where_predicate(_lctx, predicate)) + .map(|predicate| lower_where_predicate(lctx, predicate)) .collect(), } } -pub fn lower_where_predicate(_lctx: &LoweringContext, +pub fn lower_where_predicate(lctx: &LoweringContext, pred: &WherePredicate) -> hir::WherePredicate { match *pred { @@ -470,9 +470,9 @@ pub fn lower_where_predicate(_lctx: &LoweringContext, ref bounds, span}) => { hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate { - bound_lifetimes: lower_lifetime_defs(_lctx, bound_lifetimes), - bounded_ty: lower_ty(_lctx, bounded_ty), - bounds: bounds.iter().map(|x| lower_ty_param_bound(_lctx, x)).collect(), + bound_lifetimes: lower_lifetime_defs(lctx, bound_lifetimes), + bounded_ty: lower_ty(lctx, bounded_ty), + bounds: bounds.iter().map(|x| lower_ty_param_bound(lctx, x)).collect(), span: span, }) } @@ -481,8 +481,8 @@ pub fn lower_where_predicate(_lctx: &LoweringContext, span}) => { hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate { span: span, - lifetime: lower_lifetime(_lctx, lifetime), - bounds: bounds.iter().map(|bound| lower_lifetime(_lctx, bound)).collect(), + lifetime: lower_lifetime(lctx, lifetime), + bounds: bounds.iter().map(|bound| lower_lifetime(lctx, bound)).collect(), }) } WherePredicate::EqPredicate(WhereEqPredicate{ id, @@ -491,25 +491,25 @@ pub fn lower_where_predicate(_lctx: &LoweringContext, span}) => { hir::WherePredicate::EqPredicate(hir::WhereEqPredicate { id: id, - path: lower_path(_lctx, path), - ty: lower_ty(_lctx, ty), + path: lower_path(lctx, path), + ty: lower_ty(lctx, ty), span: span, }) } } } -pub fn lower_variant_data(_lctx: &LoweringContext, vdata: &VariantData) -> hir::VariantData { +pub fn lower_variant_data(lctx: &LoweringContext, vdata: &VariantData) -> hir::VariantData { match *vdata { VariantData::Struct(ref fields, id) => { hir::VariantData::Struct(fields.iter() - .map(|f| lower_struct_field(_lctx, f)) + .map(|f| lower_struct_field(lctx, f)) .collect(), id) } VariantData::Tuple(ref fields, id) => { hir::VariantData::Tuple(fields.iter() - .map(|f| lower_struct_field(_lctx, f)) + .map(|f| lower_struct_field(lctx, f)) .collect(), id) } @@ -517,129 +517,129 @@ pub fn lower_variant_data(_lctx: &LoweringContext, vdata: &VariantData) -> hir:: } } -pub fn lower_trait_ref(_lctx: &LoweringContext, p: &TraitRef) -> hir::TraitRef { +pub fn lower_trait_ref(lctx: &LoweringContext, p: &TraitRef) -> hir::TraitRef { hir::TraitRef { - path: lower_path(_lctx, &p.path), + path: lower_path(lctx, &p.path), ref_id: p.ref_id, } } -pub fn lower_poly_trait_ref(_lctx: &LoweringContext, p: &PolyTraitRef) -> hir::PolyTraitRef { +pub fn lower_poly_trait_ref(lctx: &LoweringContext, p: &PolyTraitRef) -> hir::PolyTraitRef { hir::PolyTraitRef { - bound_lifetimes: lower_lifetime_defs(_lctx, &p.bound_lifetimes), - trait_ref: lower_trait_ref(_lctx, &p.trait_ref), + bound_lifetimes: lower_lifetime_defs(lctx, &p.bound_lifetimes), + trait_ref: lower_trait_ref(lctx, &p.trait_ref), span: p.span, } } -pub fn lower_struct_field(_lctx: &LoweringContext, f: &StructField) -> hir::StructField { +pub fn lower_struct_field(lctx: &LoweringContext, f: &StructField) -> hir::StructField { Spanned { node: hir::StructField_ { id: f.node.id, - kind: lower_struct_field_kind(_lctx, &f.node.kind), - ty: lower_ty(_lctx, &f.node.ty), + kind: lower_struct_field_kind(lctx, &f.node.kind), + ty: lower_ty(lctx, &f.node.ty), attrs: f.node.attrs.clone(), }, span: f.span, } } -pub fn lower_field(_lctx: &LoweringContext, f: &Field) -> hir::Field { +pub fn lower_field(lctx: &LoweringContext, f: &Field) -> hir::Field { hir::Field { name: respan(f.ident.span, f.ident.node.name), - expr: lower_expr(_lctx, &f.expr), + expr: lower_expr(lctx, &f.expr), span: f.span, } } -pub fn lower_mt(_lctx: &LoweringContext, mt: &MutTy) -> hir::MutTy { +pub fn lower_mt(lctx: &LoweringContext, mt: &MutTy) -> hir::MutTy { hir::MutTy { - ty: lower_ty(_lctx, &mt.ty), - mutbl: lower_mutability(_lctx, mt.mutbl), + ty: lower_ty(lctx, &mt.ty), + mutbl: lower_mutability(lctx, mt.mutbl), } } -pub fn lower_opt_bounds(_lctx: &LoweringContext, +pub fn lower_opt_bounds(lctx: &LoweringContext, b: &Option<OwnedSlice<TyParamBound>>) -> Option<OwnedSlice<hir::TyParamBound>> { - b.as_ref().map(|ref bounds| lower_bounds(_lctx, bounds)) + b.as_ref().map(|ref bounds| lower_bounds(lctx, bounds)) } -fn lower_bounds(_lctx: &LoweringContext, bounds: &TyParamBounds) -> hir::TyParamBounds { - bounds.iter().map(|bound| lower_ty_param_bound(_lctx, bound)).collect() +fn lower_bounds(lctx: &LoweringContext, bounds: &TyParamBounds) -> hir::TyParamBounds { + bounds.iter().map(|bound| lower_ty_param_bound(lctx, bound)).collect() } -pub fn lower_block(_lctx: &LoweringContext, b: &Block) -> P<hir::Block> { +pub fn lower_block(lctx: &LoweringContext, b: &Block) -> P<hir::Block> { P(hir::Block { id: b.id, - stmts: b.stmts.iter().map(|s| lower_stmt(_lctx, s)).collect(), - expr: b.expr.as_ref().map(|ref x| lower_expr(_lctx, x)), - rules: lower_block_check_mode(_lctx, &b.rules), + stmts: b.stmts.iter().map(|s| lower_stmt(lctx, s)).collect(), + expr: b.expr.as_ref().map(|ref x| lower_expr(lctx, x)), + rules: lower_block_check_mode(lctx, &b.rules), span: b.span, }) } -pub fn lower_item_underscore(_lctx: &LoweringContext, i: &Item_) -> hir::Item_ { +pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ { match *i { ItemExternCrate(string) => hir::ItemExternCrate(string), ItemUse(ref view_path) => { - hir::ItemUse(lower_view_path(_lctx, view_path)) + hir::ItemUse(lower_view_path(lctx, view_path)) } ItemStatic(ref t, m, ref e) => { - hir::ItemStatic(lower_ty(_lctx, t), - lower_mutability(_lctx, m), - lower_expr(_lctx, e)) + hir::ItemStatic(lower_ty(lctx, t), + lower_mutability(lctx, m), + lower_expr(lctx, e)) } ItemConst(ref t, ref e) => { - hir::ItemConst(lower_ty(_lctx, t), lower_expr(_lctx, e)) + hir::ItemConst(lower_ty(lctx, t), lower_expr(lctx, e)) } ItemFn(ref decl, unsafety, constness, abi, ref generics, ref body) => { - hir::ItemFn(lower_fn_decl(_lctx, decl), - lower_unsafety(_lctx, unsafety), - lower_constness(_lctx, constness), + hir::ItemFn(lower_fn_decl(lctx, decl), + lower_unsafety(lctx, unsafety), + lower_constness(lctx, constness), abi, - lower_generics(_lctx, generics), - lower_block(_lctx, body)) + lower_generics(lctx, generics), + lower_block(lctx, body)) } - ItemMod(ref m) => hir::ItemMod(lower_mod(_lctx, m)), - ItemForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(_lctx, nm)), + ItemMod(ref m) => hir::ItemMod(lower_mod(lctx, m)), + ItemForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(lctx, nm)), ItemTy(ref t, ref generics) => { - hir::ItemTy(lower_ty(_lctx, t), lower_generics(_lctx, generics)) + hir::ItemTy(lower_ty(lctx, t), lower_generics(lctx, generics)) } ItemEnum(ref enum_definition, ref generics) => { hir::ItemEnum(hir::EnumDef { variants: enum_definition.variants .iter() - .map(|x| lower_variant(_lctx, x)) + .map(|x| lower_variant(lctx, x)) .collect(), }, - lower_generics(_lctx, generics)) + lower_generics(lctx, generics)) } ItemStruct(ref struct_def, ref generics) => { - let struct_def = lower_variant_data(_lctx, struct_def); - hir::ItemStruct(struct_def, lower_generics(_lctx, generics)) + let struct_def = lower_variant_data(lctx, struct_def); + hir::ItemStruct(struct_def, lower_generics(lctx, generics)) } ItemDefaultImpl(unsafety, ref trait_ref) => { - hir::ItemDefaultImpl(lower_unsafety(_lctx, unsafety), - lower_trait_ref(_lctx, trait_ref)) + hir::ItemDefaultImpl(lower_unsafety(lctx, unsafety), + lower_trait_ref(lctx, trait_ref)) } ItemImpl(unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => { let new_impl_items = impl_items.iter() - .map(|item| lower_impl_item(_lctx, item)) + .map(|item| lower_impl_item(lctx, item)) .collect(); - let ifce = ifce.as_ref().map(|trait_ref| lower_trait_ref(_lctx, trait_ref)); - hir::ItemImpl(lower_unsafety(_lctx, unsafety), - lower_impl_polarity(_lctx, polarity), - lower_generics(_lctx, generics), + let ifce = ifce.as_ref().map(|trait_ref| lower_trait_ref(lctx, trait_ref)); + hir::ItemImpl(lower_unsafety(lctx, unsafety), + lower_impl_polarity(lctx, polarity), + lower_generics(lctx, generics), ifce, - lower_ty(_lctx, ty), + lower_ty(lctx, ty), new_impl_items) } ItemTrait(unsafety, ref generics, ref bounds, ref items) => { - let bounds = lower_bounds(_lctx, bounds); - let items = items.iter().map(|item| lower_trait_item(_lctx, item)).collect(); - hir::ItemTrait(lower_unsafety(_lctx, unsafety), - lower_generics(_lctx, generics), + let bounds = lower_bounds(lctx, bounds); + let items = items.iter().map(|item| lower_trait_item(lctx, item)).collect(); + hir::ItemTrait(lower_unsafety(lctx, unsafety), + lower_generics(lctx, generics), bounds, items) } @@ -647,63 +647,63 @@ pub fn lower_item_underscore(_lctx: &LoweringContext, i: &Item_) -> hir::Item_ { } } -pub fn lower_trait_item(_lctx: &LoweringContext, i: &TraitItem) -> P<hir::TraitItem> { +pub fn lower_trait_item(lctx: &LoweringContext, i: &TraitItem) -> P<hir::TraitItem> { P(hir::TraitItem { id: i.id, name: i.ident.name, attrs: i.attrs.clone(), node: match i.node { ConstTraitItem(ref ty, ref default) => { - hir::ConstTraitItem(lower_ty(_lctx, ty), - default.as_ref().map(|x| lower_expr(_lctx, x))) + hir::ConstTraitItem(lower_ty(lctx, ty), + default.as_ref().map(|x| lower_expr(lctx, x))) } MethodTraitItem(ref sig, ref body) => { - hir::MethodTraitItem(lower_method_sig(_lctx, sig), - body.as_ref().map(|x| lower_block(_lctx, x))) + hir::MethodTraitItem(lower_method_sig(lctx, sig), + body.as_ref().map(|x| lower_block(lctx, x))) } TypeTraitItem(ref bounds, ref default) => { - hir::TypeTraitItem(lower_bounds(_lctx, bounds), - default.as_ref().map(|x| lower_ty(_lctx, x))) + hir::TypeTraitItem(lower_bounds(lctx, bounds), + default.as_ref().map(|x| lower_ty(lctx, x))) } }, span: i.span, }) } -pub fn lower_impl_item(_lctx: &LoweringContext, i: &ImplItem) -> P<hir::ImplItem> { +pub fn lower_impl_item(lctx: &LoweringContext, i: &ImplItem) -> P<hir::ImplItem> { P(hir::ImplItem { id: i.id, name: i.ident.name, attrs: i.attrs.clone(), - vis: lower_visibility(_lctx, i.vis), + vis: lower_visibility(lctx, i.vis), node: match i.node { ImplItemKind::Const(ref ty, ref expr) => { - hir::ImplItemKind::Const(lower_ty(_lctx, ty), lower_expr(_lctx, expr)) + hir::ImplItemKind::Const(lower_ty(lctx, ty), lower_expr(lctx, expr)) } ImplItemKind::Method(ref sig, ref body) => { - hir::ImplItemKind::Method(lower_method_sig(_lctx, sig), lower_block(_lctx, body)) + hir::ImplItemKind::Method(lower_method_sig(lctx, sig), lower_block(lctx, body)) } - ImplItemKind::Type(ref ty) => hir::ImplItemKind::Type(lower_ty(_lctx, ty)), + ImplItemKind::Type(ref ty) => hir::ImplItemKind::Type(lower_ty(lctx, ty)), ImplItemKind::Macro(..) => panic!("Shouldn't exist any more"), }, span: i.span, }) } -pub fn lower_mod(_lctx: &LoweringContext, m: &Mod) -> hir::Mod { +pub fn lower_mod(lctx: &LoweringContext, m: &Mod) -> hir::Mod { hir::Mod { inner: m.inner, - items: m.items.iter().map(|x| lower_item(_lctx, x)).collect(), + items: m.items.iter().map(|x| lower_item(lctx, x)).collect(), } } -pub fn lower_crate(_lctx: &LoweringContext, c: &Crate) -> hir::Crate { +pub fn lower_crate(lctx: &LoweringContext, c: &Crate) -> hir::Crate { hir::Crate { - module: lower_mod(_lctx, &c.module), + module: lower_mod(lctx, &c.module), attrs: c.attrs.clone(), config: c.config.clone(), span: c.span, - exported_macros: c.exported_macros.iter().map(|m| lower_macro_def(_lctx, m)).collect(), + exported_macros: c.exported_macros.iter().map(|m| lower_macro_def(lctx, m)).collect(), } } @@ -722,50 +722,50 @@ pub fn lower_macro_def(_lctx: &LoweringContext, m: &MacroDef) -> hir::MacroDef { } // fold one item into possibly many items -pub fn lower_item(_lctx: &LoweringContext, i: &Item) -> P<hir::Item> { - P(lower_item_simple(_lctx, i)) +pub fn lower_item(lctx: &LoweringContext, i: &Item) -> P<hir::Item> { + P(lower_item_simple(lctx, i)) } // fold one item into exactly one item -pub fn lower_item_simple(_lctx: &LoweringContext, i: &Item) -> hir::Item { - let node = lower_item_underscore(_lctx, &i.node); +pub fn lower_item_simple(lctx: &LoweringContext, i: &Item) -> hir::Item { + let node = lower_item_underscore(lctx, &i.node); hir::Item { id: i.id, name: i.ident.name, attrs: i.attrs.clone(), node: node, - vis: lower_visibility(_lctx, i.vis), + vis: lower_visibility(lctx, i.vis), span: i.span, } } -pub fn lower_foreign_item(_lctx: &LoweringContext, i: &ForeignItem) -> P<hir::ForeignItem> { +pub fn lower_foreign_item(lctx: &LoweringContext, i: &ForeignItem) -> P<hir::ForeignItem> { P(hir::ForeignItem { id: i.id, name: i.ident.name, attrs: i.attrs.clone(), node: match i.node { ForeignItemFn(ref fdec, ref generics) => { - hir::ForeignItemFn(lower_fn_decl(_lctx, fdec), lower_generics(_lctx, generics)) + hir::ForeignItemFn(lower_fn_decl(lctx, fdec), lower_generics(lctx, generics)) } ForeignItemStatic(ref t, m) => { - hir::ForeignItemStatic(lower_ty(_lctx, t), m) + hir::ForeignItemStatic(lower_ty(lctx, t), m) } }, - vis: lower_visibility(_lctx, i.vis), + vis: lower_visibility(lctx, i.vis), span: i.span, }) } -pub fn lower_method_sig(_lctx: &LoweringContext, sig: &MethodSig) -> hir::MethodSig { +pub fn lower_method_sig(lctx: &LoweringContext, sig: &MethodSig) -> hir::MethodSig { hir::MethodSig { - generics: lower_generics(_lctx, &sig.generics), + generics: lower_generics(lctx, &sig.generics), abi: sig.abi, - explicit_self: lower_explicit_self(_lctx, &sig.explicit_self), - unsafety: lower_unsafety(_lctx, sig.unsafety), - constness: lower_constness(_lctx, sig.constness), - decl: lower_fn_decl(_lctx, &sig.decl), + explicit_self: lower_explicit_self(lctx, &sig.explicit_self), + unsafety: lower_unsafety(lctx, sig.unsafety), + constness: lower_constness(lctx, sig.constness), + decl: lower_fn_decl(lctx, &sig.decl), } } @@ -817,38 +817,38 @@ pub fn lower_binop(_lctx: &LoweringContext, b: BinOp) -> hir::BinOp { } } -pub fn lower_pat(_lctx: &LoweringContext, p: &Pat) -> P<hir::Pat> { +pub fn lower_pat(lctx: &LoweringContext, p: &Pat) -> P<hir::Pat> { P(hir::Pat { id: p.id, node: match p.node { PatWild => hir::PatWild, PatIdent(ref binding_mode, pth1, ref sub) => { - hir::PatIdent(lower_binding_mode(_lctx, binding_mode), + hir::PatIdent(lower_binding_mode(lctx, binding_mode), pth1, - sub.as_ref().map(|x| lower_pat(_lctx, x))) + sub.as_ref().map(|x| lower_pat(lctx, x))) } - PatLit(ref e) => hir::PatLit(lower_expr(_lctx, e)), + PatLit(ref e) => hir::PatLit(lower_expr(lctx, e)), PatEnum(ref pth, ref pats) => { - hir::PatEnum(lower_path(_lctx, pth), + hir::PatEnum(lower_path(lctx, pth), pats.as_ref() - .map(|pats| pats.iter().map(|x| lower_pat(_lctx, x)).collect())) + .map(|pats| pats.iter().map(|x| lower_pat(lctx, x)).collect())) } PatQPath(ref qself, ref pth) => { let qself = hir::QSelf { - ty: lower_ty(_lctx, &qself.ty), + ty: lower_ty(lctx, &qself.ty), position: qself.position, }; - hir::PatQPath(qself, lower_path(_lctx, pth)) + hir::PatQPath(qself, lower_path(lctx, pth)) } PatStruct(ref pth, ref fields, etc) => { - let pth = lower_path(_lctx, pth); + let pth = lower_path(lctx, pth); let fs = fields.iter() .map(|f| { Spanned { span: f.span, node: hir::FieldPat { name: f.node.ident.name, - pat: lower_pat(_lctx, &f.node.pat), + pat: lower_pat(lctx, &f.node.pat), is_shorthand: f.node.is_shorthand, }, } @@ -856,18 +856,18 @@ pub fn lower_pat(_lctx: &LoweringContext, p: &Pat) -> P<hir::Pat> { .collect(); hir::PatStruct(pth, fs, etc) } - PatTup(ref elts) => hir::PatTup(elts.iter().map(|x| lower_pat(_lctx, x)).collect()), - PatBox(ref inner) => hir::PatBox(lower_pat(_lctx, inner)), + PatTup(ref elts) => hir::PatTup(elts.iter().map(|x| lower_pat(lctx, x)).collect()), + PatBox(ref inner) => hir::PatBox(lower_pat(lctx, inner)), PatRegion(ref inner, mutbl) => { - hir::PatRegion(lower_pat(_lctx, inner), lower_mutability(_lctx, mutbl)) + hir::PatRegion(lower_pat(lctx, inner), lower_mutability(lctx, mutbl)) } PatRange(ref e1, ref e2) => { - hir::PatRange(lower_expr(_lctx, e1), lower_expr(_lctx, e2)) + hir::PatRange(lower_expr(lctx, e1), lower_expr(lctx, e2)) } PatVec(ref before, ref slice, ref after) => { - hir::PatVec(before.iter().map(|x| lower_pat(_lctx, x)).collect(), - slice.as_ref().map(|x| lower_pat(_lctx, x)), - after.iter().map(|x| lower_pat(_lctx, x)).collect()) + hir::PatVec(before.iter().map(|x| lower_pat(lctx, x)).collect(), + slice.as_ref().map(|x| lower_pat(lctx, x)), + after.iter().map(|x| lower_pat(lctx, x)).collect()) } PatMac(_) => panic!("Shouldn't exist here"), }, @@ -1434,23 +1434,23 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> { }) } -pub fn lower_stmt(_lctx: &LoweringContext, s: &Stmt) -> P<hir::Stmt> { +pub fn lower_stmt(lctx: &LoweringContext, s: &Stmt) -> P<hir::Stmt> { match s.node { StmtDecl(ref d, id) => { P(Spanned { - node: hir::StmtDecl(lower_decl(_lctx, d), id), + node: hir::StmtDecl(lower_decl(lctx, d), id), span: s.span, }) } StmtExpr(ref e, id) => { P(Spanned { - node: hir::StmtExpr(lower_expr(_lctx, e), id), + node: hir::StmtExpr(lower_expr(lctx, e), id), span: s.span, }) } StmtSemi(ref e, id) => { P(Spanned { - node: hir::StmtSemi(lower_expr(_lctx, e), id), + node: hir::StmtSemi(lower_expr(lctx, e), id), span: s.span, }) } @@ -1472,26 +1472,26 @@ pub fn lower_visibility(_lctx: &LoweringContext, v: Visibility) -> hir::Visibili } } -pub fn lower_block_check_mode(_lctx: &LoweringContext, b: &BlockCheckMode) -> hir::BlockCheckMode { +pub fn lower_block_check_mode(lctx: &LoweringContext, b: &BlockCheckMode) -> hir::BlockCheckMode { match *b { DefaultBlock => hir::DefaultBlock, - UnsafeBlock(u) => hir::UnsafeBlock(lower_unsafe_source(_lctx, u)), + UnsafeBlock(u) => hir::UnsafeBlock(lower_unsafe_source(lctx, u)), } } -pub fn lower_binding_mode(_lctx: &LoweringContext, b: &BindingMode) -> hir::BindingMode { +pub fn lower_binding_mode(lctx: &LoweringContext, b: &BindingMode) -> hir::BindingMode { match *b { - BindByRef(m) => hir::BindByRef(lower_mutability(_lctx, m)), - BindByValue(m) => hir::BindByValue(lower_mutability(_lctx, m)), + BindByRef(m) => hir::BindByRef(lower_mutability(lctx, m)), + BindByValue(m) => hir::BindByValue(lower_mutability(lctx, m)), } } -pub fn lower_struct_field_kind(_lctx: &LoweringContext, +pub fn lower_struct_field_kind(lctx: &LoweringContext, s: &StructFieldKind) -> hir::StructFieldKind { match *s { - NamedField(ident, vis) => hir::NamedField(ident.name, lower_visibility(_lctx, vis)), - UnnamedField(vis) => hir::UnnamedField(lower_visibility(_lctx, vis)), + NamedField(ident, vis) => hir::NamedField(ident.name, lower_visibility(lctx, vis)), + UnnamedField(vis) => hir::UnnamedField(lower_visibility(lctx, vis)), } } @@ -1734,11 +1734,12 @@ fn signal_block_expr(lctx: &LoweringContext, span: Span, rule: hir::BlockCheckMode) -> P<hir::Expr> { + let id = lctx.next_id(); expr_block(lctx, P(hir::Block { rules: rule, span: span, - id: lctx.next_id(), + id: id, stmts: stmts, expr: Some(expr), })) |
