let _ignore = sess.dep_graph.in_ignore();
LoweringContext {
- crate_root: if std_inject::no_core(krate) {
- None
- } else if std_inject::no_std(krate) {
- Some("core")
- } else {
- Some("std")
- },
+ crate_root: std_inject::injected_crate_name(krate),
sess: sess,
parent_def: None,
resolver: resolver,
hir::Crate {
module: self.lower_mod(&c.module),
attrs: self.lower_attrs(&c.attrs),
- config: c.config.clone().into(),
span: c.span,
exported_macros: c.exported_macros.iter().map(|m| self.lower_macro_def(m)).collect(),
items: items,
}
fn lower_ty(&mut self, t: &Ty) -> P<hir::Ty> {
- use syntax::ast::TyKind::*;
P(hir::Ty {
id: t.id,
node: match t.node {
- Infer | ImplicitSelf => hir::TyInfer,
- Vec(ref ty) => hir::TyVec(self.lower_ty(ty)),
- Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt)),
- Rptr(ref region, ref mt) => {
+ TyKind::Infer | TyKind::ImplicitSelf => hir::TyInfer,
+ TyKind::Slice(ref ty) => hir::TySlice(self.lower_ty(ty)),
+ TyKind::Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt)),
+ TyKind::Rptr(ref region, ref mt) => {
hir::TyRptr(self.lower_opt_lifetime(region), self.lower_mt(mt))
}
- BareFn(ref f) => {
+ TyKind::BareFn(ref f) => {
hir::TyBareFn(P(hir::BareFnTy {
lifetimes: self.lower_lifetime_defs(&f.lifetimes),
unsafety: self.lower_unsafety(f.unsafety),
decl: self.lower_fn_decl(&f.decl),
}))
}
- Never => hir::TyNever,
- Tup(ref tys) => hir::TyTup(tys.iter().map(|ty| self.lower_ty(ty)).collect()),
- Paren(ref ty) => {
+ TyKind::Never => hir::TyNever,
+ TyKind::Tup(ref tys) => {
+ hir::TyTup(tys.iter().map(|ty| self.lower_ty(ty)).collect())
+ }
+ TyKind::Paren(ref ty) => {
return self.lower_ty(ty);
}
- Path(ref qself, ref path) => {
+ TyKind::Path(ref qself, ref path) => {
let qself = qself.as_ref().map(|&QSelf { ref ty, position }| {
hir::QSelf {
ty: self.lower_ty(ty),
});
hir::TyPath(qself, self.lower_path(path))
}
- ObjectSum(ref ty, ref bounds) => {
+ TyKind::ObjectSum(ref ty, ref bounds) => {
hir::TyObjectSum(self.lower_ty(ty), self.lower_bounds(bounds))
}
- FixedLengthVec(ref ty, ref e) => {
- hir::TyFixedLengthVec(self.lower_ty(ty), self.lower_expr(e))
+ TyKind::Array(ref ty, ref e) => {
+ hir::TyArray(self.lower_ty(ty), self.lower_expr(e))
}
- Typeof(ref expr) => {
+ TyKind::Typeof(ref expr) => {
hir::TyTypeof(self.lower_expr(expr))
}
- PolyTraitRef(ref bounds) => {
+ TyKind::PolyTraitRef(ref bounds) => {
hir::TyPolyTraitRef(self.lower_bounds(bounds))
}
- ImplTrait(ref bounds) => {
+ TyKind::ImplTrait(ref bounds) => {
hir::TyImplTrait(self.lower_bounds(bounds))
}
- Mac(_) => panic!("TyMac should have been expanded by now."),
+ TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
},
span: t.span,
})
bounds: self.lower_bounds(&tp.bounds),
default: tp.default.as_ref().map(|x| self.lower_ty(x)),
span: tp.span,
+ pure_wrt_drop: tp.attrs.iter().any(|attr| attr.check_name("may_dangle")),
}
}
hir::LifetimeDef {
lifetime: self.lower_lifetime(&l.lifetime),
bounds: self.lower_lifetimes(&l.bounds),
+ pure_wrt_drop: l.attrs.iter().any(|attr| attr.check_name("may_dangle")),
}
}
name: respan(f.ident.span, f.ident.node.name),
expr: self.lower_expr(&f.expr),
span: f.span,
+ is_shorthand: f.is_shorthand,
}
}
id: m.id,
span: m.span,
imported_from: m.imported_from.map(|x| x.name),
- export: m.export,
- use_locally: m.use_locally,
allow_internal_unstable: m.allow_internal_unstable,
body: m.body.clone().into(),
}
})
}
PatKind::Lit(ref e) => hir::PatKind::Lit(self.lower_expr(e)),
- PatKind::TupleStruct(ref pth, ref pats, ddpos) => {
- hir::PatKind::TupleStruct(self.lower_path(pth),
- pats.iter().map(|x| self.lower_pat(x)).collect(),
- ddpos)
+ PatKind::TupleStruct(ref path, ref pats, ddpos) => {
+ hir::PatKind::TupleStruct(self.lower_path(path),
+ pats.iter().map(|x| self.lower_pat(x)).collect(), ddpos)
}
PatKind::Path(ref opt_qself, ref path) => {
let opt_qself = opt_qself.as_ref().map(|qself| {
PatKind::Range(ref e1, ref e2) => {
hir::PatKind::Range(self.lower_expr(e1), self.lower_expr(e2))
}
- PatKind::Vec(ref before, ref slice, ref after) => {
- hir::PatKind::Vec(before.iter().map(|x| self.lower_pat(x)).collect(),
+ PatKind::Slice(ref before, ref slice, ref after) => {
+ hir::PatKind::Slice(before.iter().map(|x| self.lower_pat(x)).collect(),
slice.as_ref().map(|x| self.lower_pat(x)),
after.iter().map(|x| self.lower_pat(x)).collect())
}
}
ExprKind::Vec(ref exprs) => {
- hir::ExprVec(exprs.iter().map(|x| self.lower_expr(x)).collect())
+ hir::ExprArray(exprs.iter().map(|x| self.lower_expr(x)).collect())
}
ExprKind::Repeat(ref expr, ref count) => {
let expr = self.lower_expr(expr);
ExprKind::Break(opt_ident) => hir::ExprBreak(self.lower_opt_sp_ident(opt_ident)),
ExprKind::Continue(opt_ident) => hir::ExprAgain(self.lower_opt_sp_ident(opt_ident)),
ExprKind::Ret(ref e) => hir::ExprRet(e.as_ref().map(|x| self.lower_expr(x))),
- ExprKind::InlineAsm(InlineAsm {
- ref inputs,
- ref outputs,
- ref asm,
- asm_str_style,
- ref clobbers,
- volatile,
- alignstack,
- dialect,
- expn_id,
- }) => hir::ExprInlineAsm(hir::InlineAsm {
- inputs: inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
- outputs: outputs.iter()
- .map(|out| {
- hir::InlineAsmOutput {
- constraint: out.constraint.clone(),
- is_rw: out.is_rw,
- is_indirect: out.is_indirect,
- }
- })
- .collect(),
- asm: asm.clone(),
- asm_str_style: asm_str_style,
- clobbers: clobbers.clone().into(),
- volatile: volatile,
- alignstack: alignstack,
- dialect: dialect,
- expn_id: expn_id,
- }, outputs.iter().map(|out| self.lower_expr(&out.expr)).collect(),
- inputs.iter().map(|&(_, ref input)| self.lower_expr(input)).collect()),
+ ExprKind::InlineAsm(ref asm) => {
+ let hir_asm = hir::InlineAsm {
+ inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
+ outputs: asm.outputs.iter().map(|out| {
+ hir::InlineAsmOutput {
+ constraint: out.constraint.clone(),
+ is_rw: out.is_rw,
+ is_indirect: out.is_indirect,
+ }
+ }).collect(),
+ asm: asm.asm.clone(),
+ asm_str_style: asm.asm_str_style,
+ clobbers: asm.clobbers.clone().into(),
+ volatile: asm.volatile,
+ alignstack: asm.alignstack,
+ dialect: asm.dialect,
+ expn_id: asm.expn_id,
+ };
+ let outputs =
+ asm.outputs.iter().map(|out| self.lower_expr(&out.expr)).collect();
+ let inputs =
+ asm.inputs.iter().map(|&(_, ref input)| self.lower_expr(input)).collect();
+ hir::ExprInlineAsm(P(hir_asm), outputs, inputs)
+ }
ExprKind::Struct(ref path, ref fields, ref maybe_expr) => {
- hir::ExprStruct(self.lower_path(path),
+ hir::ExprStruct(P(self.lower_path(path)),
fields.iter().map(|x| self.lower_field(x)).collect(),
maybe_expr.as_ref().map(|x| self.lower_expr(x)))
}
},
span: span,
expr: expr,
+ is_shorthand: false,
}
}
e: Option<P<hir::Expr>>,
attrs: ThinVec<Attribute>) -> P<hir::Expr> {
let def = self.resolver.resolve_generated_global_path(&path, false);
- let expr = self.expr(sp, hir::ExprStruct(path, fields, e), attrs);
+ let expr = self.expr(sp, hir::ExprStruct(P(path), fields, e), attrs);
self.resolver.record_resolution(expr.id, def);
expr
}