提交 ca88e9c5 编写于 作者: V Vadim Petrochenkov

Remove some unnecessary indirection from HIR structures

上级 ac0e8452
......@@ -140,7 +140,7 @@ fn visit_item(&mut self, i: &'ast Item) {
for v in &enum_definition.variants {
let variant_def_index =
self.insert_def(v.node.data.id(),
NodeVariant(&**v),
NodeVariant(v),
DefPathData::EnumVariant(v.node.name));
for field in v.node.data.fields() {
......
......@@ -852,13 +852,13 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>,
II::Item(i) => II::Item(i.map(|i| fld.fold_item(i))),
II::TraitItem(d, ti) => {
II::TraitItem(fld.fold_ops.new_def_id(d),
fld.fold_trait_item(ti))
ti.map(|ti| fld.fold_trait_item(ti)))
}
II::ImplItem(d, ii) => {
II::ImplItem(fld.fold_ops.new_def_id(d),
fld.fold_impl_item(ii))
ii.map(|ii| fld.fold_impl_item(ii)))
}
II::Foreign(i) => II::Foreign(fld.fold_foreign_item(i))
II::Foreign(i) => II::Foreign(i.map(|i| fld.fold_foreign_item(i)))
};
let ii_parent = map.forest.inlined_items.alloc(InlinedParent {
......
......@@ -62,7 +62,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
fn block(&mut self, blk: &hir::Block, pred: CFGIndex) -> CFGIndex {
let mut stmts_exit = pred;
for stmt in &blk.stmts {
stmts_exit = self.stmt(&**stmt, stmts_exit);
stmts_exit = self.stmt(stmt, stmts_exit);
}
let expr_exit = self.opt_expr(&blk.expr, stmts_exit);
......
......@@ -61,7 +61,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
enum_def: DefId,
variant_def: DefId)
-> Option<&'a Expr> {
fn variant_expr<'a>(variants: &'a [P<hir::Variant>], id: ast::NodeId)
fn variant_expr<'a>(variants: &'a [hir::Variant], id: ast::NodeId)
-> Option<&'a Expr> {
for variant in variants {
if variant.node.data.id() == id {
......@@ -77,7 +77,7 @@ fn variant_expr<'a>(variants: &'a [P<hir::Variant>], id: ast::NodeId)
None => None,
Some(ast_map::NodeItem(it)) => match it.node {
hir::ItemEnum(hir::EnumDef { ref variants }, _) => {
variant_expr(&variants[..], variant_node_id)
variant_expr(variants, variant_node_id)
}
_ => None
},
......
......@@ -637,7 +637,7 @@ fn walk_block(&mut self, blk: &hir::Block) {
debug!("walk_block(blk.id={})", blk.id);
for stmt in &blk.stmts {
self.walk_stmt(&**stmt);
self.walk_stmt(stmt);
}
if let Some(ref tail_expr) = blk.expr {
......
......@@ -1501,7 +1501,7 @@ fn rebuild_path(&self,
self.rebuild_arg_ty_or_output(&**t, lifetime, anon_nums, region_names)
});
let new_bindings = data.bindings.map(|b| {
P(hir::TypeBinding {
hir::TypeBinding {
id: b.id,
name: b.name,
ty: self.rebuild_arg_ty_or_output(&*b.ty,
......@@ -1509,7 +1509,7 @@ fn rebuild_path(&self,
anon_nums,
region_names),
span: b.span
})
}
});
hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
lifetimes: new_lts,
......
......@@ -866,7 +866,7 @@ fn propagate_through_block(&mut self, blk: &hir::Block, succ: LiveNode)
-> LiveNode {
let succ = self.propagate_through_opt_expr(blk.expr.as_ref().map(|e| &**e), succ);
blk.stmts.iter().rev().fold(succ, |succ, stmt| {
self.propagate_through_stmt(&**stmt, succ)
self.propagate_through_stmt(stmt, succ)
})
}
......
......@@ -720,7 +720,7 @@ fn resolve_block(visitor: &mut RegionResolutionVisitor, blk: &hir::Block) {
parent: stmt_extent,
};
}
visitor.visit_stmt(&**statement)
visitor.visit_stmt(statement)
}
walk_list!(visitor, visit_expr, &blk.expr);
}
......
......@@ -47,7 +47,7 @@ fn fold_view_path(&mut self, view_path: P<ViewPath>) -> P<ViewPath> {
noop_fold_view_path(view_path, self)
}
fn fold_foreign_item(&mut self, ni: P<ForeignItem>) -> P<ForeignItem> {
fn fold_foreign_item(&mut self, ni: ForeignItem) -> ForeignItem {
noop_fold_foreign_item(ni, self)
}
......@@ -67,11 +67,11 @@ fn fold_item_underscore(&mut self, i: Item_) -> Item_ {
noop_fold_item_underscore(i, self)
}
fn fold_trait_item(&mut self, i: P<TraitItem>) -> P<TraitItem> {
fn fold_trait_item(&mut self, i: TraitItem) -> TraitItem {
noop_fold_trait_item(i, self)
}
fn fold_impl_item(&mut self, i: P<ImplItem>) -> P<ImplItem> {
fn fold_impl_item(&mut self, i: ImplItem) -> ImplItem {
noop_fold_impl_item(i, self)
}
......@@ -83,7 +83,7 @@ fn fold_block(&mut self, b: P<Block>) -> P<Block> {
noop_fold_block(b, self)
}
fn fold_stmt(&mut self, s: P<Stmt>) -> P<Stmt> {
fn fold_stmt(&mut self, s: Stmt) -> Stmt {
noop_fold_stmt(s, self)
}
......@@ -107,7 +107,7 @@ fn fold_ty(&mut self, t: P<Ty>) -> P<Ty> {
noop_fold_ty(t, self)
}
fn fold_ty_binding(&mut self, t: P<TypeBinding>) -> P<TypeBinding> {
fn fold_ty_binding(&mut self, t: TypeBinding) -> TypeBinding {
noop_fold_ty_binding(t, self)
}
......@@ -119,7 +119,7 @@ fn fold_foreign_mod(&mut self, nm: ForeignMod) -> ForeignMod {
noop_fold_foreign_mod(nm, self)
}
fn fold_variant(&mut self, v: P<Variant>) -> P<Variant> {
fn fold_variant(&mut self, v: Variant) -> Variant {
noop_fold_variant(v, self)
}
......@@ -333,15 +333,13 @@ pub fn noop_fold_decl<T: Folder>(d: P<Decl>, fld: &mut T) -> P<Decl> {
})
}
pub fn noop_fold_ty_binding<T: Folder>(b: P<TypeBinding>, fld: &mut T) -> P<TypeBinding> {
b.map(|TypeBinding { id, name, ty, span }| {
TypeBinding {
id: fld.new_id(id),
name: name,
ty: fld.fold_ty(ty),
span: fld.new_span(span),
}
})
pub fn noop_fold_ty_binding<T: Folder>(b: TypeBinding, fld: &mut T) -> TypeBinding {
TypeBinding {
id: fld.new_id(b.id),
name: b.name,
ty: fld.fold_ty(b.ty),
span: fld.new_span(b.span),
}
}
pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
......@@ -402,18 +400,16 @@ pub fn noop_fold_foreign_mod<T: Folder>(ForeignMod { abi, items }: ForeignMod,
}
}
pub fn noop_fold_variant<T: Folder>(v: P<Variant>, fld: &mut T) -> P<Variant> {
v.map(|Spanned { node: Variant_ { name, attrs, data, disr_expr }, span }| {
Spanned {
node: Variant_ {
name: name,
attrs: fold_attrs(attrs, fld),
data: fld.fold_variant_data(data),
disr_expr: disr_expr.map(|e| fld.fold_expr(e)),
},
span: fld.new_span(span),
}
})
pub fn noop_fold_variant<T: Folder>(v: Variant, fld: &mut T) -> Variant {
Spanned {
node: Variant_ {
name: v.node.name,
attrs: fold_attrs(v.node.attrs, fld),
data: fld.fold_variant_data(v.node.data),
disr_expr: v.node.disr_expr.map(|e| fld.fold_expr(e)),
},
span: fld.new_span(v.span),
}
}
pub fn noop_fold_name<T: Folder>(n: Name, _: &mut T) -> Name {
......@@ -814,51 +810,47 @@ pub fn noop_fold_item_underscore<T: Folder>(i: Item_, folder: &mut T) -> Item_ {
}
}
pub fn noop_fold_trait_item<T: Folder>(i: P<TraitItem>,
pub fn noop_fold_trait_item<T: Folder>(i: TraitItem,
folder: &mut T)
-> P<TraitItem> {
i.map(|TraitItem { id, name, attrs, node, span }| {
TraitItem {
id: folder.new_id(id),
name: folder.fold_name(name),
attrs: fold_attrs(attrs, folder),
node: match node {
ConstTraitItem(ty, default) => {
ConstTraitItem(folder.fold_ty(ty), default.map(|x| folder.fold_expr(x)))
}
MethodTraitItem(sig, body) => {
MethodTraitItem(noop_fold_method_sig(sig, folder),
body.map(|x| folder.fold_block(x)))
}
TypeTraitItem(bounds, default) => {
TypeTraitItem(folder.fold_bounds(bounds),
default.map(|x| folder.fold_ty(x)))
}
},
span: folder.new_span(span),
}
})
-> TraitItem {
TraitItem {
id: folder.new_id(i.id),
name: folder.fold_name(i.name),
attrs: fold_attrs(i.attrs, folder),
node: match i.node {
ConstTraitItem(ty, default) => {
ConstTraitItem(folder.fold_ty(ty), default.map(|x| folder.fold_expr(x)))
}
MethodTraitItem(sig, body) => {
MethodTraitItem(noop_fold_method_sig(sig, folder),
body.map(|x| folder.fold_block(x)))
}
TypeTraitItem(bounds, default) => {
TypeTraitItem(folder.fold_bounds(bounds),
default.map(|x| folder.fold_ty(x)))
}
},
span: folder.new_span(i.span),
}
}
pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T) -> P<ImplItem> {
i.map(|ImplItem { id, name, attrs, node, vis, span }| {
ImplItem {
id: folder.new_id(id),
name: folder.fold_name(name),
attrs: fold_attrs(attrs, folder),
vis: vis,
node: match node {
ImplItemKind::Const(ty, expr) => {
ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr))
}
ImplItemKind::Method(sig, body) => {
ImplItemKind::Method(noop_fold_method_sig(sig, folder), folder.fold_block(body))
}
ImplItemKind::Type(ty) => ImplItemKind::Type(folder.fold_ty(ty)),
},
span: folder.new_span(span),
}
})
pub fn noop_fold_impl_item<T: Folder>(i: ImplItem, folder: &mut T) -> ImplItem {
ImplItem {
id: folder.new_id(i.id),
name: folder.fold_name(i.name),
attrs: fold_attrs(i.attrs, folder),
vis: i.vis,
node: match i.node {
ImplItemKind::Const(ty, expr) => {
ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr))
}
ImplItemKind::Method(sig, body) => {
ImplItemKind::Method(noop_fold_method_sig(sig, folder), folder.fold_block(body))
}
ImplItemKind::Type(ty) => ImplItemKind::Type(folder.fold_ty(ty)),
},
span: folder.new_span(i.span),
}
}
pub fn noop_fold_mod<T: Folder>(Mod { inner, item_ids }: Mod, folder: &mut T) -> Mod {
......@@ -935,24 +927,22 @@ pub fn noop_fold_item<T: Folder>(item: Item, folder: &mut T) -> Item {
}
}
pub fn noop_fold_foreign_item<T: Folder>(ni: P<ForeignItem>, folder: &mut T) -> P<ForeignItem> {
ni.map(|ForeignItem { id, name, attrs, node, span, vis }| {
ForeignItem {
id: folder.new_id(id),
name: folder.fold_name(name),
attrs: fold_attrs(attrs, folder),
node: match node {
ForeignItemFn(fdec, generics) => {
ForeignItemFn(folder.fold_fn_decl(fdec), folder.fold_generics(generics))
}
ForeignItemStatic(t, m) => {
ForeignItemStatic(folder.fold_ty(t), m)
}
},
vis: vis,
span: folder.new_span(span),
}
})
pub fn noop_fold_foreign_item<T: Folder>(ni: ForeignItem, folder: &mut T) -> ForeignItem {
ForeignItem {
id: folder.new_id(ni.id),
name: folder.fold_name(ni.name),
attrs: fold_attrs(ni.attrs, folder),
node: match ni.node {
ForeignItemFn(fdec, generics) => {
ForeignItemFn(folder.fold_fn_decl(fdec), folder.fold_generics(generics))
}
ForeignItemStatic(t, m) => {
ForeignItemStatic(folder.fold_ty(t), m)
}
},
vis: ni.vis,
span: folder.new_span(ni.span),
}
}
pub fn noop_fold_method_sig<T: Folder>(sig: MethodSig, folder: &mut T) -> MethodSig {
......@@ -1147,32 +1137,29 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
}
}
pub fn noop_fold_stmt<T: Folder>(stmt: P<Stmt>, folder: &mut T)
-> P<Stmt> {
stmt.map(|Spanned { node, span }| {
let span = folder.new_span(span);
match node {
StmtDecl(d, id) => {
let id = folder.new_id(id);
Spanned {
node: StmtDecl(folder.fold_decl(d), id),
span: span
}
pub fn noop_fold_stmt<T: Folder>(stmt: Stmt, folder: &mut T) -> Stmt {
let span = folder.new_span(stmt.span);
match stmt.node {
StmtDecl(d, id) => {
let id = folder.new_id(id);
Spanned {
node: StmtDecl(folder.fold_decl(d), id),
span: span
}
StmtExpr(e, id) => {
let id = folder.new_id(id);
Spanned {
node: StmtExpr(folder.fold_expr(e), id),
span: span,
}
}
StmtExpr(e, id) => {
let id = folder.new_id(id);
Spanned {
node: StmtExpr(folder.fold_expr(e), id),
span: span,
}
StmtSemi(e, id) => {
let id = folder.new_id(id);
Spanned {
node: StmtSemi(folder.fold_expr(e), id),
span: span,
}
}
StmtSemi(e, id) => {
let id = folder.new_id(id);
Spanned {
node: StmtSemi(folder.fold_expr(e), id),
span: span,
}
}
})
}
}
......@@ -183,7 +183,7 @@ pub fn lifetimes(&self) -> Vec<&Lifetime> {
}
}
pub fn bindings(&self) -> Vec<&P<TypeBinding>> {
pub fn bindings(&self) -> Vec<&TypeBinding> {
match *self {
AngleBracketedParameters(ref data) => {
data.bindings.iter().collect()
......@@ -204,7 +204,7 @@ pub struct AngleBracketedParameterData {
pub types: OwnedSlice<P<Ty>>,
/// Bindings (equality constraints) on associated types, if present.
/// E.g., `Foo<A=Bar>`.
pub bindings: OwnedSlice<P<TypeBinding>>,
pub bindings: OwnedSlice<TypeBinding>,
}
impl AngleBracketedParameterData {
......@@ -379,7 +379,7 @@ pub struct MacroDef {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct Block {
/// Statements in a block
pub stmts: Vec<P<Stmt>>,
pub stmts: Vec<Stmt>,
/// An expression at the end of the block
/// without a semicolon, if any
pub expr: Option<P<Expr>>,
......@@ -1031,12 +1031,12 @@ pub struct Mod {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct ForeignMod {
pub abi: Abi,
pub items: Vec<P<ForeignItem>>,
pub items: Vec<ForeignItem>,
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct EnumDef {
pub variants: Vec<P<Variant>>,
pub variants: Vec<Variant>,
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
......@@ -1287,7 +1287,7 @@ pub enum Item_ {
/// A struct definition, e.g. `struct Foo<A> {x: A}`
ItemStruct(VariantData, Generics),
/// Represents a Trait Declaration
ItemTrait(Unsafety, Generics, TyParamBounds, Vec<P<TraitItem>>),
ItemTrait(Unsafety, Generics, TyParamBounds, Vec<TraitItem>),
// Default trait implementations
///
......@@ -1299,7 +1299,7 @@ pub enum Item_ {
Generics,
Option<TraitRef>, // (optional) trait this impl implements
P<Ty>, // self
Vec<P<ImplItem>>),
Vec<ImplItem>),
}
impl Item_ {
......
......@@ -199,13 +199,13 @@ pub fn lower_decl(lctx: &LoweringContext, d: &Decl) -> P<hir::Decl> {
}
}
pub fn lower_ty_binding(lctx: &LoweringContext, b: &TypeBinding) -> P<hir::TypeBinding> {
P(hir::TypeBinding {
pub fn lower_ty_binding(lctx: &LoweringContext, b: &TypeBinding) -> hir::TypeBinding {
hir::TypeBinding {
id: b.id,
name: b.ident.name,
ty: lower_ty(lctx, &b.ty),
span: b.span,
})
}
}
pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
......@@ -264,8 +264,8 @@ pub fn lower_foreign_mod(lctx: &LoweringContext, fm: &ForeignMod) -> hir::Foreig
}
}
pub fn lower_variant(lctx: &LoweringContext, v: &Variant) -> P<hir::Variant> {
P(Spanned {
pub fn lower_variant(lctx: &LoweringContext, v: &Variant) -> hir::Variant {
Spanned {
node: hir::Variant_ {
name: v.node.name.name,
attrs: v.node.attrs.clone(),
......@@ -273,7 +273,7 @@ pub fn lower_variant(lctx: &LoweringContext, v: &Variant) -> P<hir::Variant> {
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 {
......@@ -650,8 +650,8 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
}
}
pub fn lower_trait_item(lctx: &LoweringContext, i: &TraitItem) -> P<hir::TraitItem> {
P(hir::TraitItem {
pub fn lower_trait_item(lctx: &LoweringContext, i: &TraitItem) -> hir::TraitItem {
hir::TraitItem {
id: i.id,
name: i.ident.name,
attrs: i.attrs.clone(),
......@@ -670,11 +670,11 @@ pub fn lower_trait_item(lctx: &LoweringContext, i: &TraitItem) -> P<hir::TraitIt
}
},
span: i.span,
})
}
}
pub fn lower_impl_item(lctx: &LoweringContext, i: &ImplItem) -> P<hir::ImplItem> {
P(hir::ImplItem {
pub fn lower_impl_item(lctx: &LoweringContext, i: &ImplItem) -> hir::ImplItem {
hir::ImplItem {
id: i.id,
name: i.ident.name,
attrs: i.attrs.clone(),
......@@ -690,7 +690,7 @@ pub fn lower_impl_item(lctx: &LoweringContext, i: &ImplItem) -> P<hir::ImplItem>
ImplItemKind::Macro(..) => panic!("Shouldn't exist any more"),
},
span: i.span,
})
}
}
pub fn lower_mod(lctx: &LoweringContext, m: &Mod) -> hir::Mod {
......@@ -760,8 +760,8 @@ pub fn lower_item(lctx: &LoweringContext, i: &Item) -> hir::Item {
}
}
pub fn lower_foreign_item(lctx: &LoweringContext, i: &ForeignItem) -> P<hir::ForeignItem> {
P(hir::ForeignItem {
pub fn lower_foreign_item(lctx: &LoweringContext, i: &ForeignItem) -> hir::ForeignItem {
hir::ForeignItem {
id: i.id,
name: i.ident.name,
attrs: i.attrs.clone(),
......@@ -775,7 +775,7 @@ pub fn lower_foreign_item(lctx: &LoweringContext, i: &ForeignItem) -> P<hir::For
},
vis: lower_visibility(lctx, i.vis),
span: i.span,
})
}
}
pub fn lower_method_sig(lctx: &LoweringContext, sig: &MethodSig) -> hir::MethodSig {
......@@ -1054,7 +1054,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
let place = expr_ident(lctx, e.span, place_ident, None);
let call = make_call(lctx, &inplace_finalize, vec![place]);
signal_block_expr(lctx,
vec![P(call_move_val_init)],
vec![call_move_val_init],
call,
e.span,
hir::PushUnsafeBlock(hir::CompilerGenerated), None)
......@@ -1484,25 +1484,25 @@ 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) -> hir::Stmt {
match s.node {
StmtDecl(ref d, id) => {
P(Spanned {
Spanned {
node: hir::StmtDecl(lower_decl(lctx, d), id),
span: s.span,
})
}
}
StmtExpr(ref e, id) => {
P(Spanned {
Spanned {
node: hir::StmtExpr(lower_expr(lctx, e), id),
span: s.span,
})
}
}
StmtSemi(ref e, id) => {
P(Spanned {
Spanned {
node: hir::StmtSemi(lower_expr(lctx, e), id),
span: s.span,
})
}
}
StmtMac(..) => panic!("Shouldn't exist here"),
}
......@@ -1644,7 +1644,7 @@ fn stmt_let(lctx: &LoweringContext,
ident: Ident,
ex: P<hir::Expr>,
attrs: ThinAttributes)
-> P<hir::Stmt> {
-> hir::Stmt {
let pat = if mutbl {
pat_ident_binding_mode(lctx, sp, ident, hir::BindByValue(hir::MutMutable))
} else {
......@@ -1659,7 +1659,7 @@ fn stmt_let(lctx: &LoweringContext,
attrs: attrs,
});
let decl = respan(sp, hir::DeclLocal(local));
P(respan(sp, hir::StmtDecl(P(decl), lctx.next_id())))
respan(sp, hir::StmtDecl(P(decl), lctx.next_id()))
}
fn block_expr(lctx: &LoweringContext, expr: P<hir::Expr>) -> P<hir::Block> {
......@@ -1668,7 +1668,7 @@ fn block_expr(lctx: &LoweringContext, expr: P<hir::Expr>) -> P<hir::Block> {
fn block_all(lctx: &LoweringContext,
span: Span,
stmts: Vec<P<hir::Stmt>>,
stmts: Vec<hir::Stmt>,
expr: Option<P<hir::Expr>>)
-> P<hir::Block> {
P(hir::Block {
......@@ -1748,7 +1748,7 @@ fn path_all(sp: Span,
mut idents: Vec<Ident>,
lifetimes: Vec<hir::Lifetime>,
types: Vec<P<hir::Ty>>,
bindings: Vec<P<hir::TypeBinding>>)
bindings: Vec<hir::TypeBinding>)
-> hir::Path {
let last_identifier = idents.pop().unwrap();
let mut segments: Vec<hir::PathSegment> = idents.into_iter()
......@@ -1791,7 +1791,7 @@ fn core_path(lctx: &LoweringContext, span: Span, components: &[&str]) -> hir::Pa
}
fn signal_block_expr(lctx: &LoweringContext,
stmts: Vec<P<hir::Stmt>>,
stmts: Vec<hir::Stmt>,
expr: P<hir::Expr>,
span: Span,
rule: hir::BlockCheckMode,
......
......@@ -473,7 +473,7 @@ pub fn print_foreign_mod(&mut self,
-> io::Result<()> {
try!(self.print_inner_attributes(attrs));
for item in &nmod.items {
try!(self.print_foreign_item(&**item));
try!(self.print_foreign_item(item));
}
Ok(())
}
......@@ -878,7 +878,7 @@ pub fn print_enum_def(&mut self,
}
pub fn print_variants(&mut self,
variants: &[P<hir::Variant>],
variants: &[hir::Variant],
span: codemap::Span)
-> io::Result<()> {
try!(self.bopen());
......@@ -887,7 +887,7 @@ pub fn print_variants(&mut self,
try!(self.maybe_print_comment(v.span.lo));
try!(self.print_outer_attributes(&v.node.attrs));
try!(self.ibox(indent_unit));
try!(self.print_variant(&**v));
try!(self.print_variant(v));
try!(word(&mut self.s, ","));
try!(self.end());
try!(self.maybe_print_trailing_comment(v.span, None));
......@@ -1107,7 +1107,7 @@ pub fn print_block_maybe_unclosed(&mut self,
try!(self.print_inner_attributes(attrs));
for st in &blk.stmts {
try!(self.print_stmt(&**st));
try!(self.print_stmt(st));
}
match blk.expr {
Some(ref expr) => {
......
......@@ -394,13 +394,13 @@ fn simplify_ast(ii: InlinedItemRef) -> InlinedItem {
InlinedItem::Item(P(fold::noop_fold_item(i.clone(), &mut fld)))
}
InlinedItemRef::TraitItem(d, ti) => {
InlinedItem::TraitItem(d, fold::noop_fold_trait_item(P(ti.clone()), &mut fld))
InlinedItem::TraitItem(d, P(fold::noop_fold_trait_item(ti.clone(), &mut fld)))
}
InlinedItemRef::ImplItem(d, ii) => {
InlinedItem::ImplItem(d, fold::noop_fold_impl_item(P(ii.clone()), &mut fld))
InlinedItem::ImplItem(d, P(fold::noop_fold_impl_item(ii.clone(), &mut fld)))
}
InlinedItemRef::Foreign(i) => {
InlinedItem::Foreign(fold::noop_fold_foreign_item(P(i.clone()), &mut fld))
InlinedItem::Foreign(P(fold::noop_fold_foreign_item(i.clone(), &mut fld)))
}
}
}
......
......@@ -1156,7 +1156,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
let num_implemented_methods = ast_items.len();
for (i, &trait_item_def_id) in items.iter().enumerate() {
let ast_item = if i < num_implemented_methods {
Some(&*ast_items[i])
Some(&ast_items[i])
} else {
None
};
......@@ -1321,7 +1321,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
}
}
let trait_item = &*ms[i];
let trait_item = &ms[i];
encode_attributes(rbml_w, &trait_item.attrs);
match trait_item.node {
hir::ConstTraitItem(_, ref default) => {
......
......@@ -14,7 +14,6 @@
use rustc::middle::region::{BlockRemainder, CodeExtentData};
use rustc_front::hir;
use syntax::ast;
use syntax::ptr::P;
impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
type Output = Block<'tcx>;
......@@ -36,7 +35,7 @@ fn mirror_stmts<'a,'tcx:'a,STMTS>(cx: &mut Cx<'a,'tcx>,
block_id: ast::NodeId,
mut stmts: STMTS)
-> Vec<StmtRef<'tcx>>
where STMTS: Iterator<Item=(usize, &'tcx P<hir::Stmt>)>
where STMTS: Iterator<Item=(usize, &'tcx hir::Stmt)>
{
let mut result = vec![];
while let Some((index, stmt)) = stmts.next() {
......
......@@ -392,7 +392,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: &Rc<Module>) ->
for variant in &(*enum_definition).variants {
let item_def_id = self.ast_map.local_def_id(item.id);
self.build_reduced_graph_for_variant(&**variant, item_def_id, &module);
self.build_reduced_graph_for_variant(variant, item_def_id, &module);
}
parent.clone()
}
......
......@@ -69,7 +69,6 @@
use syntax::attr::AttrMetaMethods;
use syntax::ext::mtwt;
use syntax::parse::token::{self, special_names, special_idents};
use syntax::ptr::P;
use syntax::codemap::{self, Span, Pos};
use syntax::util::lev_distance::{lev_distance, max_suggestion_distance};
......@@ -1907,7 +1906,7 @@ fn resolve_item(&mut self, item: &Item) {
opt_trait_ref,
&**self_type,
item.id,
&impl_items[..]);
impl_items);
}
ItemTrait(_, ref generics, ref bounds, ref trait_items) => {
......@@ -2223,7 +2222,7 @@ fn resolve_implementation(&mut self,
opt_trait_reference: &Option<TraitRef>,
self_type: &Ty,
item_id: NodeId,
impl_items: &[P<ImplItem>]) {
impl_items: &[ImplItem]) {
// If applicable, create a rib for the type parameters.
self.with_type_parameter_rib(HasTypeParameters(generics,
TypeSpace,
......
......@@ -2378,7 +2378,7 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
}
}
hir::ItemImpl(_, _, ref generics, _, _, ref impl_items) => {
meth::trans_impl(ccx, item.name, &impl_items[..], generics, item.id);
meth::trans_impl(ccx, item.name, impl_items, generics, item.id);
}
hir::ItemMod(_) => {
// modules have no equivalent at runtime, they just affect
......
......@@ -110,7 +110,7 @@ pub fn trans_block<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
fcx.push_ast_cleanup_scope(cleanup_debug_loc);
for s in &b.stmts {
bcx = trans_stmt(bcx, &**s);
bcx = trans_stmt(bcx, s);
}
if dest != expr::Ignore {
......
......@@ -117,7 +117,7 @@ fn walk_block(cx: &CrateContext,
// The interesting things here are statements and the concluding expression.
for statement in &block.stmts {
scope_map.insert(rustc_front::util::stmt_id(&**statement),
scope_map.insert(rustc_front::util::stmt_id(statement),
scope_stack.last().unwrap().scope_metadata);
match statement.node {
......
......@@ -481,7 +481,7 @@ fn gate_simd_ffi(tcx: &ty::ctxt, decl: &hir::FnDecl, ty: &ty::BareFnTy) {
pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &hir::ForeignMod) {
let _icx = push_ctxt("foreign::trans_foreign_mod");
for foreign_item in &foreign_mod.items {
let lname = link_name(&**foreign_item);
let lname = link_name(foreign_item);
if let hir::ForeignItemFn(ref decl, _) = foreign_item.node {
match foreign_mod.abi {
......
......@@ -41,7 +41,6 @@
use syntax::ast;
use syntax::attr;
use syntax::codemap::DUMMY_SP;
use syntax::ptr::P;
use rustc_front::hir;
......@@ -54,7 +53,7 @@
/// see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`.
pub fn trans_impl(ccx: &CrateContext,
name: ast::Name,
impl_items: &[P<hir::ImplItem>],
impl_items: &[hir::ImplItem],
generics: &hir::Generics,
id: ast::NodeId) {
let _icx = push_ctxt("meth::trans_impl");
......
......@@ -711,11 +711,11 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
hir::ItemForeignMod(ref m) => {
if m.abi == abi::RustIntrinsic {
for item in &m.items {
intrinsic::check_intrinsic_type(ccx, &**item);
intrinsic::check_intrinsic_type(ccx, item);
}
} else if m.abi == abi::PlatformIntrinsic {
for item in &m.items {
intrinsic::check_platform_intrinsic_type(ccx, &**item);
intrinsic::check_platform_intrinsic_type(ccx, item);
}
} else {
for item in &m.items {
......@@ -880,7 +880,7 @@ fn check_method_body<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
impl_span: Span,
impl_trait_ref: &ty::TraitRef<'tcx>,
impl_items: &[P<hir::ImplItem>]) {
impl_items: &[hir::ImplItem]) {
// Locate trait methods
let tcx = ccx.tcx;
let trait_items = tcx.trait_items(impl_trait_ref.def_id);
......@@ -4024,8 +4024,8 @@ fn check_block_with_expected<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let mut any_diverges = false;
let mut any_err = false;
for s in &blk.stmts {
check_stmt(fcx, &**s);
let s_id = ::rustc_front::util::stmt_id(&**s);
check_stmt(fcx, s);
let s_id = ::rustc_front::util::stmt_id(s);
let s_ty = fcx.node_ty(s_id);
if any_diverges && !warned && match s.node {
hir::StmtDecl(ref decl, _) => {
......@@ -4193,7 +4193,7 @@ pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
sp: Span,
vs: &'tcx [P<hir::Variant>],
vs: &'tcx [hir::Variant],
id: ast::NodeId) {
fn disr_in_range(ccx: &CrateCtxt,
......@@ -4224,7 +4224,7 @@ fn int_in_range(ccx: &CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool {
}
fn do_check<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
vs: &'tcx [P<hir::Variant>],
vs: &'tcx [hir::Variant],
id: ast::NodeId,
hint: attr::ReprAttr) {
#![allow(trivial_numeric_casts)]
......
......@@ -24,7 +24,6 @@
use syntax::ast;
use syntax::codemap::{Span};
use syntax::parse::token::{special_idents};
use syntax::ptr::P;
use rustc_front::intravisit::{self, Visitor};
use rustc_front::hir;
......@@ -225,7 +224,7 @@ fn check_type_defn<F>(&mut self, item: &hir::Item, mut lookup_fields: F) where
fn check_trait(&mut self,
item: &hir::Item,
items: &[P<hir::TraitItem>])
items: &[hir::TraitItem])
{
let trait_def_id = self.tcx().map.local_def_id(item.id);
......
......@@ -1061,7 +1061,7 @@ fn convert_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
def: ty::AdtDefMaster<'tcx>,
scheme: ty::TypeScheme<'tcx>,
predicates: ty::GenericPredicates<'tcx>,
variants: &[P<hir::Variant>]) {
variants: &[hir::Variant]) {
// fill the field types
for (variant, ty_variant) in variants.iter().zip(def.variants.iter()) {
for (f, ty_f) in variant.node.data.fields().iter().zip(ty_variant.fields.iter()) {
......@@ -1479,7 +1479,7 @@ fn predicates_for_associated_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
ast_generics: &hir::Generics,
trait_predicates: &ty::GenericPredicates<'tcx>,
self_trait_ref: ty::TraitRef<'tcx>,
trait_items: &[P<hir::TraitItem>])
trait_items: &[hir::TraitItem])
-> Vec<ty::Predicate<'tcx>>
{
trait_items.iter().flat_map(|trait_item| {
......@@ -2410,7 +2410,7 @@ fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
fn enforce_impl_lifetimes_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
ast_generics: &hir::Generics,
impl_def_id: DefId,
impl_items: &[P<hir::ImplItem>])
impl_items: &[hir::ImplItem])
{
// Every lifetime used in an associated type must be constrained.
let impl_scheme = tcx.lookup_item_type(impl_def_id);
......
......@@ -176,7 +176,7 @@ pub struct Constant {
pub struct Trait {
pub unsafety: hir::Unsafety,
pub name: Name,
pub items: Vec<P<hir::TraitItem>>, //should be TraitItem
pub items: Vec<hir::TraitItem>,
pub generics: hir::Generics,
pub bounds: Vec<hir::TyParamBound>,
pub attrs: Vec<ast::Attribute>,
......@@ -192,7 +192,7 @@ pub struct Impl {
pub generics: hir::Generics,
pub trait_: Option<hir::TraitRef>,
pub for_: P<hir::Ty>,
pub items: Vec<P<hir::ImplItem>>,
pub items: Vec<hir::ImplItem>,
pub attrs: Vec<ast::Attribute>,
pub whence: Span,
pub vis: hir::Visibility,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册