Rollup merge of #30420 - petrochenkov:owned2, r=nrc
Part of https://github.com/rust-lang/rust/pull/30095 not causing mysterious segfaults. r? @nrc
This commit is contained in:
commit
9e953df6f0
33 changed files with 400 additions and 413 deletions
|
@ -517,7 +517,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
|
||||||
ty::TyEnum(adt, _) | ty::TyStruct(adt, _) => {
|
ty::TyEnum(adt, _) | ty::TyStruct(adt, _) => {
|
||||||
let v = adt.variant_of_ctor(ctor);
|
let v = adt.variant_of_ctor(ctor);
|
||||||
if let VariantKind::Struct = v.kind() {
|
if let VariantKind::Struct = v.kind() {
|
||||||
let field_pats: Vec<_> = v.fields.iter()
|
let field_pats: hir::HirVec<_> = v.fields.iter()
|
||||||
.zip(pats)
|
.zip(pats)
|
||||||
.filter(|&(_, ref pat)| pat.node != hir::PatWild)
|
.filter(|&(_, ref pat)| pat.node != hir::PatWild)
|
||||||
.map(|(field, pat)| Spanned {
|
.map(|(field, pat)| Spanned {
|
||||||
|
@ -540,14 +540,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
|
||||||
ty::TyArray(_, n) => match ctor {
|
ty::TyArray(_, n) => match ctor {
|
||||||
&Single => {
|
&Single => {
|
||||||
assert_eq!(pats_len, n);
|
assert_eq!(pats_len, n);
|
||||||
hir::PatVec(pats.collect(), None, vec!())
|
hir::PatVec(pats.collect(), None, hir::HirVec::new())
|
||||||
},
|
},
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
},
|
},
|
||||||
ty::TySlice(_) => match ctor {
|
ty::TySlice(_) => match ctor {
|
||||||
&Slice(n) => {
|
&Slice(n) => {
|
||||||
assert_eq!(pats_len, n);
|
assert_eq!(pats_len, n);
|
||||||
hir::PatVec(pats.collect(), None, vec!())
|
hir::PatVec(pats.collect(), None, hir::HirVec::new())
|
||||||
},
|
},
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
},
|
},
|
||||||
|
@ -562,7 +562,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
|
||||||
|
|
||||||
ty::TyArray(_, len) => {
|
ty::TyArray(_, len) => {
|
||||||
assert_eq!(pats_len, len);
|
assert_eq!(pats_len, len);
|
||||||
hir::PatVec(pats.collect(), None, vec![])
|
hir::PatVec(pats.collect(), None, hir::HirVec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -357,14 +357,14 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat>
|
||||||
|
|
||||||
hir::ExprVec(ref exprs) => {
|
hir::ExprVec(ref exprs) => {
|
||||||
let pats = exprs.iter().map(|expr| const_expr_to_pat(tcx, &**expr, span)).collect();
|
let pats = exprs.iter().map(|expr| const_expr_to_pat(tcx, &**expr, span)).collect();
|
||||||
hir::PatVec(pats, None, vec![])
|
hir::PatVec(pats, None, hir::HirVec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprPath(_, ref path) => {
|
hir::ExprPath(_, ref path) => {
|
||||||
let opt_def = tcx.def_map.borrow().get(&expr.id).map(|d| d.full_def());
|
let opt_def = tcx.def_map.borrow().get(&expr.id).map(|d| d.full_def());
|
||||||
match opt_def {
|
match opt_def {
|
||||||
Some(def::DefStruct(..)) =>
|
Some(def::DefStruct(..)) =>
|
||||||
hir::PatStruct(path.clone(), vec![], false),
|
hir::PatStruct(path.clone(), hir::HirVec::new(), false),
|
||||||
Some(def::DefVariant(..)) =>
|
Some(def::DefVariant(..)) =>
|
||||||
hir::PatEnum(path.clone(), None),
|
hir::PatEnum(path.clone(), None),
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -324,7 +324,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||||
self.delegate.consume(consume_id, consume_span, cmt, mode);
|
self.delegate.consume(consume_id, consume_span, cmt, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consume_exprs(&mut self, exprs: &Vec<P<hir::Expr>>) {
|
fn consume_exprs(&mut self, exprs: &[P<hir::Expr>]) {
|
||||||
for expr in exprs {
|
for expr in exprs {
|
||||||
self.consume_expr(&**expr);
|
self.consume_expr(&**expr);
|
||||||
}
|
}
|
||||||
|
@ -651,7 +651,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||||
|
|
||||||
fn walk_struct_expr(&mut self,
|
fn walk_struct_expr(&mut self,
|
||||||
_expr: &hir::Expr,
|
_expr: &hir::Expr,
|
||||||
fields: &Vec<hir::Field>,
|
fields: &[hir::Field],
|
||||||
opt_with: &Option<P<hir::Expr>>) {
|
opt_with: &Option<P<hir::Expr>>) {
|
||||||
// Consume the expressions supplying values for each field.
|
// Consume the expressions supplying values for each field.
|
||||||
for field in fields {
|
for field in fields {
|
||||||
|
@ -697,7 +697,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||||
self.walk_expr(with_expr);
|
self.walk_expr(with_expr);
|
||||||
|
|
||||||
fn contains_field_named(field: ty::FieldDef,
|
fn contains_field_named(field: ty::FieldDef,
|
||||||
fields: &Vec<hir::Field>)
|
fields: &[hir::Field])
|
||||||
-> bool
|
-> bool
|
||||||
{
|
{
|
||||||
fields.iter().any(
|
fields.iter().any(
|
||||||
|
|
|
@ -90,7 +90,6 @@ use std::cell::{Cell, RefCell};
|
||||||
use std::char::from_u32;
|
use std::char::from_u32;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
use syntax::codemap::{self, Pos, Span};
|
use syntax::codemap::{self, Pos, Span};
|
||||||
use syntax::parse::token;
|
use syntax::parse::token;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
|
@ -1154,10 +1153,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rebuild_ty_params(&self,
|
fn rebuild_ty_params(&self,
|
||||||
ty_params: OwnedSlice<hir::TyParam>,
|
ty_params: P<[hir::TyParam]>,
|
||||||
lifetime: hir::Lifetime,
|
lifetime: hir::Lifetime,
|
||||||
region_names: &HashSet<ast::Name>)
|
region_names: &HashSet<ast::Name>)
|
||||||
-> OwnedSlice<hir::TyParam> {
|
-> P<[hir::TyParam]> {
|
||||||
ty_params.map(|ty_param| {
|
ty_params.map(|ty_param| {
|
||||||
let bounds = self.rebuild_ty_param_bounds(ty_param.bounds.clone(),
|
let bounds = self.rebuild_ty_param_bounds(ty_param.bounds.clone(),
|
||||||
lifetime,
|
lifetime,
|
||||||
|
@ -1173,10 +1172,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rebuild_ty_param_bounds(&self,
|
fn rebuild_ty_param_bounds(&self,
|
||||||
ty_param_bounds: OwnedSlice<hir::TyParamBound>,
|
ty_param_bounds: hir::TyParamBounds,
|
||||||
lifetime: hir::Lifetime,
|
lifetime: hir::Lifetime,
|
||||||
region_names: &HashSet<ast::Name>)
|
region_names: &HashSet<ast::Name>)
|
||||||
-> OwnedSlice<hir::TyParamBound> {
|
-> hir::TyParamBounds {
|
||||||
ty_param_bounds.map(|tpb| {
|
ty_param_bounds.map(|tpb| {
|
||||||
match tpb {
|
match tpb {
|
||||||
&hir::RegionTyParamBound(lt) => {
|
&hir::RegionTyParamBound(lt) => {
|
||||||
|
@ -1249,13 +1248,13 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||||
add: &Vec<hir::Lifetime>,
|
add: &Vec<hir::Lifetime>,
|
||||||
keep: &HashSet<ast::Name>,
|
keep: &HashSet<ast::Name>,
|
||||||
remove: &HashSet<ast::Name>,
|
remove: &HashSet<ast::Name>,
|
||||||
ty_params: OwnedSlice<hir::TyParam>,
|
ty_params: P<[hir::TyParam]>,
|
||||||
where_clause: hir::WhereClause)
|
where_clause: hir::WhereClause)
|
||||||
-> hir::Generics {
|
-> hir::Generics {
|
||||||
let mut lifetimes = Vec::new();
|
let mut lifetimes = Vec::new();
|
||||||
for lt in add {
|
for lt in add {
|
||||||
lifetimes.push(hir::LifetimeDef { lifetime: *lt,
|
lifetimes.push(hir::LifetimeDef { lifetime: *lt,
|
||||||
bounds: Vec::new() });
|
bounds: hir::HirVec::new() });
|
||||||
}
|
}
|
||||||
for lt in &generics.lifetimes {
|
for lt in &generics.lifetimes {
|
||||||
if keep.contains(<.lifetime.name) ||
|
if keep.contains(<.lifetime.name) ||
|
||||||
|
@ -1264,7 +1263,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::Generics {
|
hir::Generics {
|
||||||
lifetimes: lifetimes,
|
lifetimes: lifetimes.into(),
|
||||||
ty_params: ty_params,
|
ty_params: ty_params,
|
||||||
where_clause: where_clause,
|
where_clause: where_clause,
|
||||||
}
|
}
|
||||||
|
@ -1275,7 +1274,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||||
lifetime: hir::Lifetime,
|
lifetime: hir::Lifetime,
|
||||||
anon_nums: &HashSet<u32>,
|
anon_nums: &HashSet<u32>,
|
||||||
region_names: &HashSet<ast::Name>)
|
region_names: &HashSet<ast::Name>)
|
||||||
-> Vec<hir::Arg> {
|
-> hir::HirVec<hir::Arg> {
|
||||||
let mut new_inputs = Vec::new();
|
let mut new_inputs = Vec::new();
|
||||||
for arg in inputs {
|
for arg in inputs {
|
||||||
let new_ty = self.rebuild_arg_ty_or_output(&*arg.ty, lifetime,
|
let new_ty = self.rebuild_arg_ty_or_output(&*arg.ty, lifetime,
|
||||||
|
@ -1287,7 +1286,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
new_inputs.push(possibly_new_arg);
|
new_inputs.push(possibly_new_arg);
|
||||||
}
|
}
|
||||||
new_inputs
|
new_inputs.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rebuild_output(&self, ty: &hir::FunctionRetTy,
|
fn rebuild_output(&self, ty: &hir::FunctionRetTy,
|
||||||
|
@ -1514,7 +1513,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
|
hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
|
||||||
lifetimes: new_lts,
|
lifetimes: new_lts.into(),
|
||||||
types: new_types,
|
types: new_types,
|
||||||
bindings: new_bindings,
|
bindings: new_bindings,
|
||||||
})
|
})
|
||||||
|
@ -1530,7 +1529,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||||
hir::Path {
|
hir::Path {
|
||||||
span: path.span,
|
span: path.span,
|
||||||
global: path.global,
|
global: path.global,
|
||||||
segments: new_segs
|
segments: new_segs.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,10 +79,10 @@ struct LifetimeContext<'a> {
|
||||||
enum ScopeChain<'a> {
|
enum ScopeChain<'a> {
|
||||||
/// EarlyScope(i, ['a, 'b, ...], s) extends s with early-bound
|
/// EarlyScope(i, ['a, 'b, ...], s) extends s with early-bound
|
||||||
/// lifetimes, assigning indexes 'a => i, 'b => i+1, ... etc.
|
/// lifetimes, assigning indexes 'a => i, 'b => i+1, ... etc.
|
||||||
EarlyScope(subst::ParamSpace, &'a Vec<hir::LifetimeDef>, Scope<'a>),
|
EarlyScope(subst::ParamSpace, &'a [hir::LifetimeDef], Scope<'a>),
|
||||||
/// LateScope(['a, 'b, ...], s) extends s with late-bound
|
/// LateScope(['a, 'b, ...], s) extends s with late-bound
|
||||||
/// lifetimes introduced by the declaration binder_id.
|
/// lifetimes introduced by the declaration binder_id.
|
||||||
LateScope(&'a Vec<hir::LifetimeDef>, Scope<'a>),
|
LateScope(&'a [hir::LifetimeDef], Scope<'a>),
|
||||||
|
|
||||||
/// lifetimes introduced by a fn are scoped to the call-site for that fn.
|
/// lifetimes introduced by a fn are scoped to the call-site for that fn.
|
||||||
FnScope { fn_id: ast::NodeId, body_id: ast::NodeId, s: Scope<'a> },
|
FnScope { fn_id: ast::NodeId, body_id: ast::NodeId, s: Scope<'a> },
|
||||||
|
@ -206,7 +206,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||||
// a trait ref, which introduces a binding scope.
|
// a trait ref, which introduces a binding scope.
|
||||||
match self.def_map.get(&ty.id).map(|d| (d.base_def, d.depth)) {
|
match self.def_map.get(&ty.id).map(|d| (d.base_def, d.depth)) {
|
||||||
Some((def::DefTrait(..), 0)) => {
|
Some((def::DefTrait(..), 0)) => {
|
||||||
self.with(LateScope(&Vec::new(), self.scope), |_, this| {
|
self.with(LateScope(&[], self.scope), |_, this| {
|
||||||
this.visit_path(path, ty.id);
|
this.visit_path(path, ty.id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ impl<'a> LifetimeContext<'a> {
|
||||||
lifetime_ref.name);
|
lifetime_ref.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<hir::LifetimeDef>) {
|
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &[hir::LifetimeDef]) {
|
||||||
for i in 0..lifetimes.len() {
|
for i in 0..lifetimes.len() {
|
||||||
let lifetime_i = &lifetimes[i];
|
let lifetime_i = &lifetimes[i];
|
||||||
|
|
||||||
|
@ -753,7 +753,7 @@ impl<'a> LifetimeContext<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn search_lifetimes<'a>(lifetimes: &'a Vec<hir::LifetimeDef>,
|
fn search_lifetimes<'a>(lifetimes: &'a [hir::LifetimeDef],
|
||||||
lifetime_ref: &hir::Lifetime)
|
lifetime_ref: &hir::Lifetime)
|
||||||
-> Option<(u32, &'a hir::Lifetime)> {
|
-> Option<(u32, &'a hir::Lifetime)> {
|
||||||
for (i, lifetime_decl) in lifetimes.iter().enumerate() {
|
for (i, lifetime_decl) in lifetimes.iter().enumerate() {
|
||||||
|
|
|
@ -82,7 +82,7 @@ struct Annotator<'a, 'tcx: 'a> {
|
||||||
impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
|
impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
|
||||||
// Determine the stability for a node based on its attributes and inherited
|
// Determine the stability for a node based on its attributes and inherited
|
||||||
// stability. The stability is recorded in the index and used as the parent.
|
// stability. The stability is recorded in the index and used as the parent.
|
||||||
fn annotate<F>(&mut self, id: NodeId, attrs: &Vec<Attribute>,
|
fn annotate<F>(&mut self, id: NodeId, attrs: &[Attribute],
|
||||||
item_sp: Span, kind: AnnotationKind, visit_children: F)
|
item_sp: Span, kind: AnnotationKind, visit_children: F)
|
||||||
where F: FnOnce(&mut Annotator)
|
where F: FnOnce(&mut Annotator)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ use middle::ty::fold::{TypeFoldable, TypeFolder};
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use syntax::abi;
|
use syntax::abi;
|
||||||
use syntax::owned_slice::OwnedSlice;
|
use syntax::ptr::P;
|
||||||
|
|
||||||
use rustc_front::hir;
|
use rustc_front::hir;
|
||||||
|
|
||||||
|
@ -555,8 +555,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for OwnedSlice<T> {
|
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for P<[T]> {
|
||||||
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> OwnedSlice<T> {
|
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> P<[T]> {
|
||||||
self.iter().map(|t| t.fold_with(folder)).collect()
|
self.iter().map(|t| t.fold_with(folder)).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ use syntax::ast::{MetaWord, MetaList, MetaNameValue};
|
||||||
use syntax::attr::ThinAttributesExt;
|
use syntax::attr::ThinAttributesExt;
|
||||||
use hir;
|
use hir;
|
||||||
use syntax::codemap::{respan, Span, Spanned};
|
use syntax::codemap::{respan, Span, Spanned};
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::parse::token;
|
use syntax::parse::token;
|
||||||
use syntax::util::move_map::MoveMap;
|
use syntax::util::move_map::MoveMap;
|
||||||
|
@ -35,7 +34,7 @@ pub trait Folder : Sized {
|
||||||
noop_fold_crate(c, self)
|
noop_fold_crate(c, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_meta_items(&mut self, meta_items: Vec<P<MetaItem>>) -> Vec<P<MetaItem>> {
|
fn fold_meta_items(&mut self, meta_items: HirVec<P<MetaItem>>) -> HirVec<P<MetaItem>> {
|
||||||
noop_fold_meta_items(meta_items, self)
|
noop_fold_meta_items(meta_items, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,11 +198,11 @@ pub trait Folder : Sized {
|
||||||
noop_fold_variant_data(vdata, self)
|
noop_fold_variant_data(vdata, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_lifetimes(&mut self, lts: Vec<Lifetime>) -> Vec<Lifetime> {
|
fn fold_lifetimes(&mut self, lts: HirVec<Lifetime>) -> HirVec<Lifetime> {
|
||||||
noop_fold_lifetimes(lts, self)
|
noop_fold_lifetimes(lts, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_lifetime_defs(&mut self, lts: Vec<LifetimeDef>) -> Vec<LifetimeDef> {
|
fn fold_lifetime_defs(&mut self, lts: HirVec<LifetimeDef>) -> HirVec<LifetimeDef> {
|
||||||
noop_fold_lifetime_defs(lts, self)
|
noop_fold_lifetime_defs(lts, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +210,7 @@ pub trait Folder : Sized {
|
||||||
noop_fold_ty_param(tp, self)
|
noop_fold_ty_param(tp, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty_params(&mut self, tps: OwnedSlice<TyParam>) -> OwnedSlice<TyParam> {
|
fn fold_ty_params(&mut self, tps: P<[TyParam]>) -> P<[TyParam]> {
|
||||||
noop_fold_ty_params(tps, self)
|
noop_fold_ty_params(tps, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,12 +219,12 @@ pub trait Folder : Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_opt_bounds(&mut self,
|
fn fold_opt_bounds(&mut self,
|
||||||
b: Option<OwnedSlice<TyParamBound>>)
|
b: Option<TyParamBounds>)
|
||||||
-> Option<OwnedSlice<TyParamBound>> {
|
-> Option<TyParamBounds> {
|
||||||
noop_fold_opt_bounds(b, self)
|
noop_fold_opt_bounds(b, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_bounds(&mut self, b: OwnedSlice<TyParamBound>) -> OwnedSlice<TyParamBound> {
|
fn fold_bounds(&mut self, b: TyParamBounds) -> TyParamBounds {
|
||||||
noop_fold_bounds(b, self)
|
noop_fold_bounds(b, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,9 +263,9 @@ pub trait Folder : Sized {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_fold_meta_items<T: Folder>(meta_items: Vec<P<MetaItem>>,
|
pub fn noop_fold_meta_items<T: Folder>(meta_items: HirVec<P<MetaItem>>,
|
||||||
fld: &mut T)
|
fld: &mut T)
|
||||||
-> Vec<P<MetaItem>> {
|
-> HirVec<P<MetaItem>> {
|
||||||
meta_items.move_map(|x| fld.fold_meta_item(x))
|
meta_items.move_map(|x| fld.fold_meta_item(x))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +304,7 @@ pub fn noop_fold_view_path<T: Folder>(view_path: P<ViewPath>, fld: &mut T) -> P<
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fold_attrs<T: Folder>(attrs: Vec<Attribute>, fld: &mut T) -> Vec<Attribute> {
|
pub fn fold_attrs<T: Folder>(attrs: HirVec<Attribute>, fld: &mut T) -> HirVec<Attribute> {
|
||||||
attrs.move_flat_map(|x| fld.fold_attribute(x))
|
attrs.move_flat_map(|x| fld.fold_attribute(x))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +477,7 @@ pub fn noop_fold_local<T: Folder>(l: P<Local>, fld: &mut T) -> P<Local> {
|
||||||
pat: fld.fold_pat(pat),
|
pat: fld.fold_pat(pat),
|
||||||
init: init.map(|e| fld.fold_expr(e)),
|
init: init.map(|e| fld.fold_expr(e)),
|
||||||
span: fld.new_span(span),
|
span: fld.new_span(span),
|
||||||
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs, fld)),
|
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs.into(), fld).into()),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -576,9 +575,9 @@ pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_fold_ty_params<T: Folder>(tps: OwnedSlice<TyParam>,
|
pub fn noop_fold_ty_params<T: Folder>(tps: P<[TyParam]>,
|
||||||
fld: &mut T)
|
fld: &mut T)
|
||||||
-> OwnedSlice<TyParam> {
|
-> P<[TyParam]> {
|
||||||
tps.move_map(|tp| fld.fold_ty_param(tp))
|
tps.move_map(|tp| fld.fold_ty_param(tp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,11 +596,13 @@ pub fn noop_fold_lifetime_def<T: Folder>(l: LifetimeDef, fld: &mut T) -> Lifetim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_fold_lifetimes<T: Folder>(lts: Vec<Lifetime>, fld: &mut T) -> Vec<Lifetime> {
|
pub fn noop_fold_lifetimes<T: Folder>(lts: HirVec<Lifetime>, fld: &mut T) -> HirVec<Lifetime> {
|
||||||
lts.move_map(|l| fld.fold_lifetime(l))
|
lts.move_map(|l| fld.fold_lifetime(l))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_fold_lifetime_defs<T: Folder>(lts: Vec<LifetimeDef>, fld: &mut T) -> Vec<LifetimeDef> {
|
pub fn noop_fold_lifetime_defs<T: Folder>(lts: HirVec<LifetimeDef>,
|
||||||
|
fld: &mut T)
|
||||||
|
-> HirVec<LifetimeDef> {
|
||||||
lts.move_map(|l| fld.fold_lifetime_def(l))
|
lts.move_map(|l| fld.fold_lifetime_def(l))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,9 +727,9 @@ pub fn noop_fold_mt<T: Folder>(MutTy { ty, mutbl }: MutTy, folder: &mut T) -> Mu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<OwnedSlice<TyParamBound>>,
|
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<TyParamBounds>,
|
||||||
folder: &mut T)
|
folder: &mut T)
|
||||||
-> Option<OwnedSlice<TyParamBound>> {
|
-> Option<TyParamBounds> {
|
||||||
b.map(|bounds| folder.fold_bounds(bounds))
|
b.map(|bounds| folder.fold_bounds(bounds))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1140,7 +1141,7 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
span: folder.new_span(span),
|
span: folder.new_span(span),
|
||||||
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs, folder)),
|
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs.into(), folder).into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,8 @@ use std::collections::BTreeMap;
|
||||||
use syntax::codemap::{self, Span, Spanned, DUMMY_SP, ExpnId};
|
use syntax::codemap::{self, Span, Spanned, DUMMY_SP, ExpnId};
|
||||||
use syntax::abi::Abi;
|
use syntax::abi::Abi;
|
||||||
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect};
|
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect};
|
||||||
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, CrateConfig};
|
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem};
|
||||||
use syntax::attr::ThinAttributes;
|
use syntax::attr::ThinAttributes;
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
use syntax::parse::token::InternedString;
|
use syntax::parse::token::InternedString;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
|
|
||||||
|
@ -53,6 +52,22 @@ use std::fmt;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||||
|
|
||||||
|
/// HIR doesn't commit to a concrete storage type and have its own alias for a vector.
|
||||||
|
/// It can be `Vec`, `P<[T]>` or potentially `Box<[T]>`, or some other container with similar
|
||||||
|
/// behavior. Unlike AST, HIR is mostly a static structure, so we can use an owned slice instead
|
||||||
|
/// of `Vec` to avoid keeping extra capacity.
|
||||||
|
pub type HirVec<T> = Vec<T>;
|
||||||
|
|
||||||
|
macro_rules! hir_vec {
|
||||||
|
($elem:expr; $n:expr) => (
|
||||||
|
$crate::hir::HirVec::from(vec![$elem; $n])
|
||||||
|
);
|
||||||
|
($($x:expr),*) => (
|
||||||
|
$crate::hir::HirVec::from(vec![$($x),*])
|
||||||
|
);
|
||||||
|
($($x:expr,)*) => (vec![$($x),*])
|
||||||
|
}
|
||||||
|
|
||||||
/// Identifier in HIR
|
/// Identifier in HIR
|
||||||
#[derive(Clone, Copy, Eq)]
|
#[derive(Clone, Copy, Eq)]
|
||||||
pub struct Ident {
|
pub struct Ident {
|
||||||
|
@ -130,7 +145,7 @@ impl fmt::Debug for Lifetime {
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct LifetimeDef {
|
pub struct LifetimeDef {
|
||||||
pub lifetime: Lifetime,
|
pub lifetime: Lifetime,
|
||||||
pub bounds: Vec<Lifetime>,
|
pub bounds: HirVec<Lifetime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A "Path" is essentially Rust's notion of a name; for instance:
|
/// A "Path" is essentially Rust's notion of a name; for instance:
|
||||||
|
@ -143,7 +158,7 @@ pub struct Path {
|
||||||
/// module (like paths in an import).
|
/// module (like paths in an import).
|
||||||
pub global: bool,
|
pub global: bool,
|
||||||
/// The segments in the path: the things separated by `::`.
|
/// The segments in the path: the things separated by `::`.
|
||||||
pub segments: Vec<PathSegment>,
|
pub segments: HirVec<PathSegment>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Path {
|
impl fmt::Debug for Path {
|
||||||
|
@ -192,9 +207,9 @@ pub enum PathParameters {
|
||||||
impl PathParameters {
|
impl PathParameters {
|
||||||
pub fn none() -> PathParameters {
|
pub fn none() -> PathParameters {
|
||||||
AngleBracketedParameters(AngleBracketedParameterData {
|
AngleBracketedParameters(AngleBracketedParameterData {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: HirVec::new(),
|
||||||
types: OwnedSlice::empty(),
|
types: P::empty(),
|
||||||
bindings: OwnedSlice::empty(),
|
bindings: P::empty(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +239,7 @@ impl PathParameters {
|
||||||
|
|
||||||
/// Returns the types that the user wrote. Note that these do not necessarily map to the type
|
/// Returns the types that the user wrote. Note that these do not necessarily map to the type
|
||||||
/// parameters in the parenthesized case.
|
/// parameters in the parenthesized case.
|
||||||
pub fn types(&self) -> Vec<&P<Ty>> {
|
pub fn types(&self) -> HirVec<&P<Ty>> {
|
||||||
match *self {
|
match *self {
|
||||||
AngleBracketedParameters(ref data) => {
|
AngleBracketedParameters(ref data) => {
|
||||||
data.types.iter().collect()
|
data.types.iter().collect()
|
||||||
|
@ -238,24 +253,24 @@ impl PathParameters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lifetimes(&self) -> Vec<&Lifetime> {
|
pub fn lifetimes(&self) -> HirVec<&Lifetime> {
|
||||||
match *self {
|
match *self {
|
||||||
AngleBracketedParameters(ref data) => {
|
AngleBracketedParameters(ref data) => {
|
||||||
data.lifetimes.iter().collect()
|
data.lifetimes.iter().collect()
|
||||||
}
|
}
|
||||||
ParenthesizedParameters(_) => {
|
ParenthesizedParameters(_) => {
|
||||||
Vec::new()
|
HirVec::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bindings(&self) -> Vec<&TypeBinding> {
|
pub fn bindings(&self) -> HirVec<&TypeBinding> {
|
||||||
match *self {
|
match *self {
|
||||||
AngleBracketedParameters(ref data) => {
|
AngleBracketedParameters(ref data) => {
|
||||||
data.bindings.iter().collect()
|
data.bindings.iter().collect()
|
||||||
}
|
}
|
||||||
ParenthesizedParameters(_) => {
|
ParenthesizedParameters(_) => {
|
||||||
Vec::new()
|
HirVec::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,12 +280,12 @@ impl PathParameters {
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct AngleBracketedParameterData {
|
pub struct AngleBracketedParameterData {
|
||||||
/// The lifetime parameters for this path segment.
|
/// The lifetime parameters for this path segment.
|
||||||
pub lifetimes: Vec<Lifetime>,
|
pub lifetimes: HirVec<Lifetime>,
|
||||||
/// The type parameters for this path segment, if present.
|
/// The type parameters for this path segment, if present.
|
||||||
pub types: OwnedSlice<P<Ty>>,
|
pub types: P<[P<Ty>]>,
|
||||||
/// Bindings (equality constraints) on associated types, if present.
|
/// Bindings (equality constraints) on associated types, if present.
|
||||||
/// E.g., `Foo<A=Bar>`.
|
/// E.g., `Foo<A=Bar>`.
|
||||||
pub bindings: OwnedSlice<TypeBinding>,
|
pub bindings: P<[TypeBinding]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AngleBracketedParameterData {
|
impl AngleBracketedParameterData {
|
||||||
|
@ -286,7 +301,7 @@ pub struct ParenthesizedParameterData {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
|
||||||
/// `(A,B)`
|
/// `(A,B)`
|
||||||
pub inputs: Vec<P<Ty>>,
|
pub inputs: HirVec<P<Ty>>,
|
||||||
|
|
||||||
/// `C`
|
/// `C`
|
||||||
pub output: Option<P<Ty>>,
|
pub output: Option<P<Ty>>,
|
||||||
|
@ -310,7 +325,7 @@ pub enum TraitBoundModifier {
|
||||||
Maybe,
|
Maybe,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type TyParamBounds = OwnedSlice<TyParamBound>;
|
pub type TyParamBounds = P<[TyParamBound]>;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct TyParam {
|
pub struct TyParam {
|
||||||
|
@ -325,8 +340,8 @@ pub struct TyParam {
|
||||||
/// of a function, enum, trait, etc.
|
/// of a function, enum, trait, etc.
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct Generics {
|
pub struct Generics {
|
||||||
pub lifetimes: Vec<LifetimeDef>,
|
pub lifetimes: HirVec<LifetimeDef>,
|
||||||
pub ty_params: OwnedSlice<TyParam>,
|
pub ty_params: P<[TyParam]>,
|
||||||
pub where_clause: WhereClause,
|
pub where_clause: WhereClause,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +361,7 @@ impl Generics {
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct WhereClause {
|
pub struct WhereClause {
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub predicates: Vec<WherePredicate>,
|
pub predicates: HirVec<WherePredicate>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A single predicate in a `where` clause
|
/// A single predicate in a `where` clause
|
||||||
|
@ -365,11 +380,11 @@ pub enum WherePredicate {
|
||||||
pub struct WhereBoundPredicate {
|
pub struct WhereBoundPredicate {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
/// Any lifetimes from a `for` binding
|
/// Any lifetimes from a `for` binding
|
||||||
pub bound_lifetimes: Vec<LifetimeDef>,
|
pub bound_lifetimes: HirVec<LifetimeDef>,
|
||||||
/// The type being bounded
|
/// The type being bounded
|
||||||
pub bounded_ty: P<Ty>,
|
pub bounded_ty: P<Ty>,
|
||||||
/// Trait and lifetime bounds (`Clone+Send+'static`)
|
/// Trait and lifetime bounds (`Clone+Send+'static`)
|
||||||
pub bounds: OwnedSlice<TyParamBound>,
|
pub bounds: TyParamBounds,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A lifetime predicate, e.g. `'a: 'b+'c`
|
/// A lifetime predicate, e.g. `'a: 'b+'c`
|
||||||
|
@ -377,7 +392,7 @@ pub struct WhereBoundPredicate {
|
||||||
pub struct WhereRegionPredicate {
|
pub struct WhereRegionPredicate {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub lifetime: Lifetime,
|
pub lifetime: Lifetime,
|
||||||
pub bounds: Vec<Lifetime>,
|
pub bounds: HirVec<Lifetime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An equality predicate (unsupported), e.g. `T=int`
|
/// An equality predicate (unsupported), e.g. `T=int`
|
||||||
|
@ -389,13 +404,15 @@ pub struct WhereEqPredicate {
|
||||||
pub ty: P<Ty>,
|
pub ty: P<Ty>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type CrateConfig = HirVec<P<MetaItem>>;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub struct Crate {
|
pub struct Crate {
|
||||||
pub module: Mod,
|
pub module: Mod,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub config: CrateConfig,
|
pub config: CrateConfig,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub exported_macros: Vec<MacroDef>,
|
pub exported_macros: HirVec<MacroDef>,
|
||||||
|
|
||||||
// NB: We use a BTreeMap here so that `visit_all_items` iterates
|
// NB: We use a BTreeMap here so that `visit_all_items` iterates
|
||||||
// over the ids in increasing order. In principle it should not
|
// over the ids in increasing order. In principle it should not
|
||||||
|
@ -432,20 +449,20 @@ impl Crate {
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct MacroDef {
|
pub struct MacroDef {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub imported_from: Option<Name>,
|
pub imported_from: Option<Name>,
|
||||||
pub export: bool,
|
pub export: bool,
|
||||||
pub use_locally: bool,
|
pub use_locally: bool,
|
||||||
pub allow_internal_unstable: bool,
|
pub allow_internal_unstable: bool,
|
||||||
pub body: Vec<TokenTree>,
|
pub body: HirVec<TokenTree>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
/// Statements in a block
|
/// Statements in a block
|
||||||
pub stmts: Vec<Stmt>,
|
pub stmts: HirVec<Stmt>,
|
||||||
/// An expression at the end of the block
|
/// An expression at the end of the block
|
||||||
/// without a semicolon, if any
|
/// without a semicolon, if any
|
||||||
pub expr: Option<P<Expr>>,
|
pub expr: Option<P<Expr>>,
|
||||||
|
@ -504,7 +521,7 @@ pub enum Pat_ {
|
||||||
PatIdent(BindingMode, Spanned<Ident>, Option<P<Pat>>),
|
PatIdent(BindingMode, Spanned<Ident>, Option<P<Pat>>),
|
||||||
|
|
||||||
/// "None" means a `Variant(..)` pattern where we don't bind the fields to names.
|
/// "None" means a `Variant(..)` pattern where we don't bind the fields to names.
|
||||||
PatEnum(Path, Option<Vec<P<Pat>>>),
|
PatEnum(Path, Option<HirVec<P<Pat>>>),
|
||||||
|
|
||||||
/// An associated const named using the qualified path `<T>::CONST` or
|
/// An associated const named using the qualified path `<T>::CONST` or
|
||||||
/// `<T as Trait>::CONST`. Associated consts from inherent impls can be
|
/// `<T as Trait>::CONST`. Associated consts from inherent impls can be
|
||||||
|
@ -514,9 +531,9 @@ pub enum Pat_ {
|
||||||
|
|
||||||
/// Destructuring of a struct, e.g. `Foo {x, y, ..}`
|
/// Destructuring of a struct, e.g. `Foo {x, y, ..}`
|
||||||
/// The `bool` is `true` in the presence of a `..`
|
/// The `bool` is `true` in the presence of a `..`
|
||||||
PatStruct(Path, Vec<Spanned<FieldPat>>, bool),
|
PatStruct(Path, HirVec<Spanned<FieldPat>>, bool),
|
||||||
/// A tuple pattern `(a, b)`
|
/// A tuple pattern `(a, b)`
|
||||||
PatTup(Vec<P<Pat>>),
|
PatTup(HirVec<P<Pat>>),
|
||||||
/// A `box` pattern
|
/// A `box` pattern
|
||||||
PatBox(P<Pat>),
|
PatBox(P<Pat>),
|
||||||
/// A reference pattern, e.g. `&mut (a, b)`
|
/// A reference pattern, e.g. `&mut (a, b)`
|
||||||
|
@ -527,7 +544,7 @@ pub enum Pat_ {
|
||||||
PatRange(P<Expr>, P<Expr>),
|
PatRange(P<Expr>, P<Expr>),
|
||||||
/// `[a, b, ..i, y, z]` is represented as:
|
/// `[a, b, ..i, y, z]` is represented as:
|
||||||
/// `PatVec(box [a, b], Some(i), box [y, z])`
|
/// `PatVec(box [a, b], Some(i), box [y, z])`
|
||||||
PatVec(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
|
PatVec(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||||
|
@ -641,8 +658,8 @@ pub enum Decl_ {
|
||||||
/// represents one arm of a 'match'
|
/// represents one arm of a 'match'
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct Arm {
|
pub struct Arm {
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub pats: Vec<P<Pat>>,
|
pub pats: HirVec<P<Pat>>,
|
||||||
pub guard: Option<P<Expr>>,
|
pub guard: Option<P<Expr>>,
|
||||||
pub body: P<Expr>,
|
pub body: P<Expr>,
|
||||||
}
|
}
|
||||||
|
@ -691,12 +708,12 @@ pub enum Expr_ {
|
||||||
/// A `box x` expression.
|
/// A `box x` expression.
|
||||||
ExprBox(P<Expr>),
|
ExprBox(P<Expr>),
|
||||||
/// An array (`[a, b, c, d]`)
|
/// An array (`[a, b, c, d]`)
|
||||||
ExprVec(Vec<P<Expr>>),
|
ExprVec(HirVec<P<Expr>>),
|
||||||
/// A function call
|
/// A function call
|
||||||
///
|
///
|
||||||
/// The first field resolves to the function itself,
|
/// The first field resolves to the function itself,
|
||||||
/// and the second field is the list of arguments
|
/// and the second field is the list of arguments
|
||||||
ExprCall(P<Expr>, Vec<P<Expr>>),
|
ExprCall(P<Expr>, HirVec<P<Expr>>),
|
||||||
/// A method call (`x.foo::<Bar, Baz>(a, b, c, d)`)
|
/// A method call (`x.foo::<Bar, Baz>(a, b, c, d)`)
|
||||||
///
|
///
|
||||||
/// The `Spanned<Name>` is the identifier for the method name.
|
/// The `Spanned<Name>` is the identifier for the method name.
|
||||||
|
@ -709,9 +726,9 @@ pub enum Expr_ {
|
||||||
///
|
///
|
||||||
/// Thus, `x.foo::<Bar, Baz>(a, b, c, d)` is represented as
|
/// Thus, `x.foo::<Bar, Baz>(a, b, c, d)` is represented as
|
||||||
/// `ExprMethodCall(foo, [Bar, Baz], [x, a, b, c, d])`.
|
/// `ExprMethodCall(foo, [Bar, Baz], [x, a, b, c, d])`.
|
||||||
ExprMethodCall(Spanned<Name>, Vec<P<Ty>>, Vec<P<Expr>>),
|
ExprMethodCall(Spanned<Name>, HirVec<P<Ty>>, HirVec<P<Expr>>),
|
||||||
/// A tuple (`(a, b, c ,d)`)
|
/// A tuple (`(a, b, c ,d)`)
|
||||||
ExprTup(Vec<P<Expr>>),
|
ExprTup(HirVec<P<Expr>>),
|
||||||
/// A binary operation (For example: `a + b`, `a * b`)
|
/// A binary operation (For example: `a + b`, `a * b`)
|
||||||
ExprBinary(BinOp, P<Expr>, P<Expr>),
|
ExprBinary(BinOp, P<Expr>, P<Expr>),
|
||||||
/// A unary operation (For example: `!x`, `*x`)
|
/// A unary operation (For example: `!x`, `*x`)
|
||||||
|
@ -734,7 +751,7 @@ pub enum Expr_ {
|
||||||
ExprLoop(P<Block>, Option<Ident>),
|
ExprLoop(P<Block>, Option<Ident>),
|
||||||
/// A `match` block, with a source that indicates whether or not it is
|
/// A `match` block, with a source that indicates whether or not it is
|
||||||
/// the result of a desugaring, and if so, which kind.
|
/// the result of a desugaring, and if so, which kind.
|
||||||
ExprMatch(P<Expr>, Vec<Arm>, MatchSource),
|
ExprMatch(P<Expr>, HirVec<Arm>, MatchSource),
|
||||||
/// A closure (for example, `move |a, b, c| {a + b + c}`)
|
/// A closure (for example, `move |a, b, c| {a + b + c}`)
|
||||||
ExprClosure(CaptureClause, P<FnDecl>, P<Block>),
|
ExprClosure(CaptureClause, P<FnDecl>, P<Block>),
|
||||||
/// A block (`{ ... }`)
|
/// A block (`{ ... }`)
|
||||||
|
@ -761,7 +778,7 @@ pub enum Expr_ {
|
||||||
/// parameters, e.g. foo::bar::<baz>.
|
/// parameters, e.g. foo::bar::<baz>.
|
||||||
///
|
///
|
||||||
/// Optionally "qualified",
|
/// Optionally "qualified",
|
||||||
/// e.g. `<Vec<T> as SomeTrait>::SomeType`.
|
/// e.g. `<HirVec<T> as SomeTrait>::SomeType`.
|
||||||
ExprPath(Option<QSelf>, Path),
|
ExprPath(Option<QSelf>, Path),
|
||||||
|
|
||||||
/// A referencing operation (`&a` or `&mut a`)
|
/// A referencing operation (`&a` or `&mut a`)
|
||||||
|
@ -780,7 +797,7 @@ pub enum Expr_ {
|
||||||
///
|
///
|
||||||
/// For example, `Foo {x: 1, y: 2}`, or
|
/// For example, `Foo {x: 1, y: 2}`, or
|
||||||
/// `Foo {x: 1, .. base}`, where `base` is the `Option<Expr>`.
|
/// `Foo {x: 1, .. base}`, where `base` is the `Option<Expr>`.
|
||||||
ExprStruct(Path, Vec<Field>, Option<P<Expr>>),
|
ExprStruct(Path, HirVec<Field>, Option<P<Expr>>),
|
||||||
|
|
||||||
/// A vector literal constructed from one repeated element.
|
/// A vector literal constructed from one repeated element.
|
||||||
///
|
///
|
||||||
|
@ -794,11 +811,11 @@ pub enum Expr_ {
|
||||||
/// separately. `position` represents the index of the associated
|
/// separately. `position` represents the index of the associated
|
||||||
/// item qualified with this Self type.
|
/// item qualified with this Self type.
|
||||||
///
|
///
|
||||||
/// <Vec<T> as a::b::Trait>::AssociatedItem
|
/// <HirVec<T> as a::b::Trait>::AssociatedItem
|
||||||
/// ^~~~~ ~~~~~~~~~~~~~~^
|
/// ^~~~~ ~~~~~~~~~~~~~~^
|
||||||
/// ty position = 3
|
/// ty position = 3
|
||||||
///
|
///
|
||||||
/// <Vec<T>>::AssociatedItem
|
/// <HirVec<T>>::AssociatedItem
|
||||||
/// ^~~~~ ^
|
/// ^~~~~ ^
|
||||||
/// ty position = 0
|
/// ty position = 0
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
|
@ -851,7 +868,7 @@ pub struct MethodSig {
|
||||||
pub struct TraitItem {
|
pub struct TraitItem {
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub node: TraitItem_,
|
pub node: TraitItem_,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -868,7 +885,7 @@ pub struct ImplItem {
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub vis: Visibility,
|
pub vis: Visibility,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub node: ImplItemKind,
|
pub node: ImplItemKind,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
@ -919,7 +936,7 @@ pub enum PrimTy {
|
||||||
pub struct BareFnTy {
|
pub struct BareFnTy {
|
||||||
pub unsafety: Unsafety,
|
pub unsafety: Unsafety,
|
||||||
pub abi: Abi,
|
pub abi: Abi,
|
||||||
pub lifetimes: Vec<LifetimeDef>,
|
pub lifetimes: HirVec<LifetimeDef>,
|
||||||
pub decl: P<FnDecl>,
|
pub decl: P<FnDecl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -936,9 +953,9 @@ pub enum Ty_ {
|
||||||
/// A bare function (e.g. `fn(usize) -> bool`)
|
/// A bare function (e.g. `fn(usize) -> bool`)
|
||||||
TyBareFn(P<BareFnTy>),
|
TyBareFn(P<BareFnTy>),
|
||||||
/// A tuple (`(A, B, C, D,...)`)
|
/// A tuple (`(A, B, C, D,...)`)
|
||||||
TyTup(Vec<P<Ty>>),
|
TyTup(HirVec<P<Ty>>),
|
||||||
/// A path (`module::module::...::Type`), optionally
|
/// A path (`module::module::...::Type`), optionally
|
||||||
/// "qualified", e.g. `<Vec<T> as SomeTrait>::SomeType`.
|
/// "qualified", e.g. `<HirVec<T> as SomeTrait>::SomeType`.
|
||||||
///
|
///
|
||||||
/// Type parameters are stored in the Path itself
|
/// Type parameters are stored in the Path itself
|
||||||
TyPath(Option<QSelf>, Path),
|
TyPath(Option<QSelf>, Path),
|
||||||
|
@ -965,9 +982,9 @@ pub struct InlineAsmOutput {
|
||||||
pub struct InlineAsm {
|
pub struct InlineAsm {
|
||||||
pub asm: InternedString,
|
pub asm: InternedString,
|
||||||
pub asm_str_style: StrStyle,
|
pub asm_str_style: StrStyle,
|
||||||
pub outputs: Vec<InlineAsmOutput>,
|
pub outputs: HirVec<InlineAsmOutput>,
|
||||||
pub inputs: Vec<(InternedString, P<Expr>)>,
|
pub inputs: HirVec<(InternedString, P<Expr>)>,
|
||||||
pub clobbers: Vec<InternedString>,
|
pub clobbers: HirVec<InternedString>,
|
||||||
pub volatile: bool,
|
pub volatile: bool,
|
||||||
pub alignstack: bool,
|
pub alignstack: bool,
|
||||||
pub dialect: AsmDialect,
|
pub dialect: AsmDialect,
|
||||||
|
@ -1008,7 +1025,7 @@ impl Arg {
|
||||||
/// Represents the header (not the body) of a function declaration
|
/// Represents the header (not the body) of a function declaration
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct FnDecl {
|
pub struct FnDecl {
|
||||||
pub inputs: Vec<Arg>,
|
pub inputs: HirVec<Arg>,
|
||||||
pub output: FunctionRetTy,
|
pub output: FunctionRetTy,
|
||||||
pub variadic: bool,
|
pub variadic: bool,
|
||||||
}
|
}
|
||||||
|
@ -1099,24 +1116,24 @@ pub struct Mod {
|
||||||
/// For `mod foo;`, the inner span ranges from the first token
|
/// For `mod foo;`, the inner span ranges from the first token
|
||||||
/// to the last token in the external file.
|
/// to the last token in the external file.
|
||||||
pub inner: Span,
|
pub inner: Span,
|
||||||
pub item_ids: Vec<ItemId>,
|
pub item_ids: HirVec<ItemId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct ForeignMod {
|
pub struct ForeignMod {
|
||||||
pub abi: Abi,
|
pub abi: Abi,
|
||||||
pub items: Vec<ForeignItem>,
|
pub items: HirVec<ForeignItem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct EnumDef {
|
pub struct EnumDef {
|
||||||
pub variants: Vec<Variant>,
|
pub variants: HirVec<Variant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct Variant_ {
|
pub struct Variant_ {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub data: VariantData,
|
pub data: VariantData,
|
||||||
/// Explicit discriminant, eg `Foo = 1`
|
/// Explicit discriminant, eg `Foo = 1`
|
||||||
pub disr_expr: Option<P<Expr>>,
|
pub disr_expr: Option<P<Expr>>,
|
||||||
|
@ -1177,7 +1194,7 @@ pub enum ViewPath_ {
|
||||||
ViewPathGlob(Path),
|
ViewPathGlob(Path),
|
||||||
|
|
||||||
/// `foo::bar::{a,b,c}`
|
/// `foo::bar::{a,b,c}`
|
||||||
ViewPathList(Path, Vec<PathListItem>),
|
ViewPathList(Path, HirVec<PathListItem>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TraitRef's appear in impls.
|
/// TraitRef's appear in impls.
|
||||||
|
@ -1195,7 +1212,7 @@ pub struct TraitRef {
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct PolyTraitRef {
|
pub struct PolyTraitRef {
|
||||||
/// The `'a` in `<'a> Foo<&'a T>`
|
/// The `'a` in `<'a> Foo<&'a T>`
|
||||||
pub bound_lifetimes: Vec<LifetimeDef>,
|
pub bound_lifetimes: HirVec<LifetimeDef>,
|
||||||
|
|
||||||
/// The `Foo<&'a T>` in `<'a> Foo<&'a T>`
|
/// The `Foo<&'a T>` in `<'a> Foo<&'a T>`
|
||||||
pub trait_ref: TraitRef,
|
pub trait_ref: TraitRef,
|
||||||
|
@ -1223,7 +1240,7 @@ pub struct StructField_ {
|
||||||
pub kind: StructFieldKind,
|
pub kind: StructFieldKind,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub ty: P<Ty>,
|
pub ty: P<Ty>,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StructField_ {
|
impl StructField_ {
|
||||||
|
@ -1272,8 +1289,8 @@ impl StructFieldKind {
|
||||||
/// Id of the whole struct lives in `Item`.
|
/// Id of the whole struct lives in `Item`.
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub enum VariantData {
|
pub enum VariantData {
|
||||||
Struct(Vec<StructField>, NodeId),
|
Struct(HirVec<StructField>, NodeId),
|
||||||
Tuple(Vec<StructField>, NodeId),
|
Tuple(HirVec<StructField>, NodeId),
|
||||||
Unit(NodeId),
|
Unit(NodeId),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1328,7 +1345,7 @@ pub struct ItemId {
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub node: Item_,
|
pub node: Item_,
|
||||||
pub vis: Visibility,
|
pub vis: Visibility,
|
||||||
|
@ -1361,7 +1378,7 @@ pub enum Item_ {
|
||||||
/// A struct definition, e.g. `struct Foo<A> {x: A}`
|
/// A struct definition, e.g. `struct Foo<A> {x: A}`
|
||||||
ItemStruct(VariantData, Generics),
|
ItemStruct(VariantData, Generics),
|
||||||
/// Represents a Trait Declaration
|
/// Represents a Trait Declaration
|
||||||
ItemTrait(Unsafety, Generics, TyParamBounds, Vec<TraitItem>),
|
ItemTrait(Unsafety, Generics, TyParamBounds, HirVec<TraitItem>),
|
||||||
|
|
||||||
// Default trait implementations
|
// Default trait implementations
|
||||||
///
|
///
|
||||||
|
@ -1373,7 +1390,7 @@ pub enum Item_ {
|
||||||
Generics,
|
Generics,
|
||||||
Option<TraitRef>, // (optional) trait this impl implements
|
Option<TraitRef>, // (optional) trait this impl implements
|
||||||
P<Ty>, // self
|
P<Ty>, // self
|
||||||
Vec<ImplItem>),
|
HirVec<ImplItem>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Item_ {
|
impl Item_ {
|
||||||
|
@ -1399,7 +1416,7 @@ impl Item_ {
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct ForeignItem {
|
pub struct ForeignItem {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub node: ForeignItem_,
|
pub node: ForeignItem_,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
|
|
@ -47,6 +47,7 @@ extern crate rustc_bitflags;
|
||||||
|
|
||||||
extern crate serialize as rustc_serialize; // used by deriving
|
extern crate serialize as rustc_serialize; // used by deriving
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
pub mod hir;
|
pub mod hir;
|
||||||
pub mod lowering;
|
pub mod lowering;
|
||||||
pub mod fold;
|
pub mod fold;
|
||||||
|
|
|
@ -70,7 +70,6 @@ use syntax::attr::{ThinAttributes, ThinAttributesExt};
|
||||||
use syntax::ext::mtwt;
|
use syntax::ext::mtwt;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::codemap::{respan, Spanned, Span};
|
use syntax::codemap::{respan, Spanned, Span};
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
use syntax::parse::token;
|
use syntax::parse::token;
|
||||||
use syntax::std_inject;
|
use syntax::std_inject;
|
||||||
use syntax::visit::{self, Visitor};
|
use syntax::visit::{self, Visitor};
|
||||||
|
@ -148,6 +147,10 @@ pub fn lower_ident(_lctx: &LoweringContext, ident: Ident) -> hir::Ident {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn lower_attrs(_lctx: &LoweringContext, attrs: &Vec<Attribute>) -> hir::HirVec<Attribute> {
|
||||||
|
attrs.clone().into()
|
||||||
|
}
|
||||||
|
|
||||||
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 {
|
P(Spanned {
|
||||||
node: match view_path.node {
|
node: match view_path.node {
|
||||||
|
@ -187,7 +190,7 @@ pub fn lower_view_path(lctx: &LoweringContext, view_path: &ViewPath) -> P<hir::V
|
||||||
|
|
||||||
pub fn lower_arm(lctx: &LoweringContext, arm: &Arm) -> hir::Arm {
|
pub fn lower_arm(lctx: &LoweringContext, arm: &Arm) -> hir::Arm {
|
||||||
hir::Arm {
|
hir::Arm {
|
||||||
attrs: arm.attrs.clone(),
|
attrs: lower_attrs(lctx, &arm.attrs),
|
||||||
pats: arm.pats.iter().map(|x| lower_pat(lctx, x)).collect(),
|
pats: arm.pats.iter().map(|x| lower_pat(lctx, x)).collect(),
|
||||||
guard: arm.guard.as_ref().map(|ref x| lower_expr(lctx, x)),
|
guard: arm.guard.as_ref().map(|ref x| lower_expr(lctx, x)),
|
||||||
body: lower_expr(lctx, &arm.body),
|
body: lower_expr(lctx, &arm.body),
|
||||||
|
@ -276,7 +279,7 @@ pub fn lower_variant(lctx: &LoweringContext, v: &Variant) -> hir::Variant {
|
||||||
Spanned {
|
Spanned {
|
||||||
node: hir::Variant_ {
|
node: hir::Variant_ {
|
||||||
name: v.node.name.name,
|
name: v.node.name.name,
|
||||||
attrs: v.node.attrs.clone(),
|
attrs: lower_attrs(lctx, &v.node.attrs),
|
||||||
data: lower_variant_data(lctx, &v.node.data),
|
data: lower_variant_data(lctx, &v.node.data),
|
||||||
disr_expr: v.node.disr_expr.as_ref().map(|e| lower_expr(lctx, e)),
|
disr_expr: v.node.disr_expr.as_ref().map(|e| lower_expr(lctx, e)),
|
||||||
},
|
},
|
||||||
|
@ -430,8 +433,8 @@ pub fn lower_ty_param(lctx: &LoweringContext, tp: &TyParam) -> hir::TyParam {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lower_ty_params(lctx: &LoweringContext,
|
pub fn lower_ty_params(lctx: &LoweringContext,
|
||||||
tps: &OwnedSlice<TyParam>)
|
tps: &P<[TyParam]>)
|
||||||
-> OwnedSlice<hir::TyParam> {
|
-> P<[hir::TyParam]> {
|
||||||
tps.iter().map(|tp| lower_ty_param(lctx, tp)).collect()
|
tps.iter().map(|tp| lower_ty_param(lctx, tp)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,13 +453,13 @@ pub fn lower_lifetime_def(lctx: &LoweringContext, l: &LifetimeDef) -> hir::Lifet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lower_lifetimes(lctx: &LoweringContext, lts: &Vec<Lifetime>) -> Vec<hir::Lifetime> {
|
pub fn lower_lifetimes(lctx: &LoweringContext, lts: &Vec<Lifetime>) -> hir::HirVec<hir::Lifetime> {
|
||||||
lts.iter().map(|l| lower_lifetime(lctx, l)).collect()
|
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>)
|
lts: &Vec<LifetimeDef>)
|
||||||
-> Vec<hir::LifetimeDef> {
|
-> hir::HirVec<hir::LifetimeDef> {
|
||||||
lts.iter().map(|l| lower_lifetime_def(lctx, l)).collect()
|
lts.iter().map(|l| lower_lifetime_def(lctx, l)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +564,7 @@ pub fn lower_struct_field(lctx: &LoweringContext, f: &StructField) -> hir::Struc
|
||||||
id: f.node.id,
|
id: f.node.id,
|
||||||
kind: lower_struct_field_kind(lctx, &f.node.kind),
|
kind: lower_struct_field_kind(lctx, &f.node.kind),
|
||||||
ty: lower_ty(lctx, &f.node.ty),
|
ty: lower_ty(lctx, &f.node.ty),
|
||||||
attrs: f.node.attrs.clone(),
|
attrs: lower_attrs(lctx, &f.node.attrs),
|
||||||
},
|
},
|
||||||
span: f.span,
|
span: f.span,
|
||||||
}
|
}
|
||||||
|
@ -583,8 +586,8 @@ pub fn lower_mt(lctx: &LoweringContext, mt: &MutTy) -> hir::MutTy {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lower_opt_bounds(lctx: &LoweringContext,
|
pub fn lower_opt_bounds(lctx: &LoweringContext,
|
||||||
b: &Option<OwnedSlice<TyParamBound>>)
|
b: &Option<TyParamBounds>)
|
||||||
-> Option<OwnedSlice<hir::TyParamBound>> {
|
-> Option<hir::TyParamBounds> {
|
||||||
b.as_ref().map(|ref bounds| lower_bounds(lctx, bounds))
|
b.as_ref().map(|ref bounds| lower_bounds(lctx, bounds))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,7 +677,7 @@ pub fn lower_trait_item(lctx: &LoweringContext, i: &TraitItem) -> hir::TraitItem
|
||||||
hir::TraitItem {
|
hir::TraitItem {
|
||||||
id: i.id,
|
id: i.id,
|
||||||
name: i.ident.name,
|
name: i.ident.name,
|
||||||
attrs: i.attrs.clone(),
|
attrs: lower_attrs(lctx, &i.attrs),
|
||||||
node: match i.node {
|
node: match i.node {
|
||||||
ConstTraitItem(ref ty, ref default) => {
|
ConstTraitItem(ref ty, ref default) => {
|
||||||
hir::ConstTraitItem(lower_ty(lctx, ty),
|
hir::ConstTraitItem(lower_ty(lctx, ty),
|
||||||
|
@ -697,7 +700,7 @@ pub fn lower_impl_item(lctx: &LoweringContext, i: &ImplItem) -> hir::ImplItem {
|
||||||
hir::ImplItem {
|
hir::ImplItem {
|
||||||
id: i.id,
|
id: i.id,
|
||||||
name: i.ident.name,
|
name: i.ident.name,
|
||||||
attrs: i.attrs.clone(),
|
attrs: lower_attrs(lctx, &i.attrs),
|
||||||
vis: lower_visibility(lctx, i.vis),
|
vis: lower_visibility(lctx, i.vis),
|
||||||
node: match i.node {
|
node: match i.node {
|
||||||
ImplItemKind::Const(ref ty, ref expr) => {
|
ImplItemKind::Const(ref ty, ref expr) => {
|
||||||
|
@ -741,25 +744,25 @@ pub fn lower_crate(lctx: &LoweringContext, c: &Crate) -> hir::Crate {
|
||||||
|
|
||||||
hir::Crate {
|
hir::Crate {
|
||||||
module: lower_mod(lctx, &c.module),
|
module: lower_mod(lctx, &c.module),
|
||||||
attrs: c.attrs.clone(),
|
attrs: lower_attrs(lctx, &c.attrs),
|
||||||
config: c.config.clone(),
|
config: c.config.clone().into(),
|
||||||
span: c.span,
|
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(),
|
||||||
items: items,
|
items: items,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lower_macro_def(_lctx: &LoweringContext, m: &MacroDef) -> hir::MacroDef {
|
pub fn lower_macro_def(lctx: &LoweringContext, m: &MacroDef) -> hir::MacroDef {
|
||||||
hir::MacroDef {
|
hir::MacroDef {
|
||||||
name: m.ident.name,
|
name: m.ident.name,
|
||||||
attrs: m.attrs.clone(),
|
attrs: lower_attrs(lctx, &m.attrs),
|
||||||
id: m.id,
|
id: m.id,
|
||||||
span: m.span,
|
span: m.span,
|
||||||
imported_from: m.imported_from.map(|x| x.name),
|
imported_from: m.imported_from.map(|x| x.name),
|
||||||
export: m.export,
|
export: m.export,
|
||||||
use_locally: m.use_locally,
|
use_locally: m.use_locally,
|
||||||
allow_internal_unstable: m.allow_internal_unstable,
|
allow_internal_unstable: m.allow_internal_unstable,
|
||||||
body: m.body.clone(),
|
body: m.body.clone().into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,7 +776,7 @@ pub fn lower_item(lctx: &LoweringContext, i: &Item) -> hir::Item {
|
||||||
hir::Item {
|
hir::Item {
|
||||||
id: i.id,
|
id: i.id,
|
||||||
name: i.ident.name,
|
name: i.ident.name,
|
||||||
attrs: i.attrs.clone(),
|
attrs: lower_attrs(lctx, &i.attrs),
|
||||||
node: node,
|
node: node,
|
||||||
vis: lower_visibility(lctx, i.vis),
|
vis: lower_visibility(lctx, i.vis),
|
||||||
span: i.span,
|
span: i.span,
|
||||||
|
@ -784,7 +787,7 @@ pub fn lower_foreign_item(lctx: &LoweringContext, i: &ForeignItem) -> hir::Forei
|
||||||
hir::ForeignItem {
|
hir::ForeignItem {
|
||||||
id: i.id,
|
id: i.id,
|
||||||
name: i.ident.name,
|
name: i.ident.name,
|
||||||
attrs: i.attrs.clone(),
|
attrs: lower_attrs(lctx, &i.attrs),
|
||||||
node: match i.node {
|
node: match i.node {
|
||||||
ForeignItemFn(ref fdec, ref generics) => {
|
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))
|
||||||
|
@ -1021,7 +1024,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
// let placer = <placer_expr> ;
|
// let placer = <placer_expr> ;
|
||||||
let s1 = {
|
let s1 = {
|
||||||
let placer_expr = signal_block_expr(lctx,
|
let placer_expr = signal_block_expr(lctx,
|
||||||
vec![],
|
hir_vec![],
|
||||||
placer_expr,
|
placer_expr,
|
||||||
e.span,
|
e.span,
|
||||||
hir::PopUnstableBlock,
|
hir::PopUnstableBlock,
|
||||||
|
@ -1032,14 +1035,14 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
// let mut place = Placer::make_place(placer);
|
// let mut place = Placer::make_place(placer);
|
||||||
let s2 = {
|
let s2 = {
|
||||||
let placer = expr_ident(lctx, e.span, placer_ident, None);
|
let placer = expr_ident(lctx, e.span, placer_ident, None);
|
||||||
let call = make_call(lctx, &make_place, vec![placer]);
|
let call = make_call(lctx, &make_place, hir_vec![placer]);
|
||||||
mk_stmt_let_mut(lctx, place_ident, call)
|
mk_stmt_let_mut(lctx, place_ident, call)
|
||||||
};
|
};
|
||||||
|
|
||||||
// let p_ptr = Place::pointer(&mut place);
|
// let p_ptr = Place::pointer(&mut place);
|
||||||
let s3 = {
|
let s3 = {
|
||||||
let agent = expr_ident(lctx, e.span, place_ident, None);
|
let agent = expr_ident(lctx, e.span, place_ident, None);
|
||||||
let args = vec![expr_mut_addr_of(lctx, e.span, agent, None)];
|
let args = hir_vec![expr_mut_addr_of(lctx, e.span, agent, None)];
|
||||||
let call = make_call(lctx, &place_pointer, args);
|
let call = make_call(lctx, &place_pointer, args);
|
||||||
mk_stmt_let(lctx, p_ptr_ident, call)
|
mk_stmt_let(lctx, p_ptr_ident, call)
|
||||||
};
|
};
|
||||||
|
@ -1047,13 +1050,13 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
// pop_unsafe!(EXPR));
|
// pop_unsafe!(EXPR));
|
||||||
let pop_unsafe_expr = {
|
let pop_unsafe_expr = {
|
||||||
let value_expr = signal_block_expr(lctx,
|
let value_expr = signal_block_expr(lctx,
|
||||||
vec![],
|
hir_vec![],
|
||||||
value_expr,
|
value_expr,
|
||||||
e.span,
|
e.span,
|
||||||
hir::PopUnstableBlock,
|
hir::PopUnstableBlock,
|
||||||
None);
|
None);
|
||||||
signal_block_expr(lctx,
|
signal_block_expr(lctx,
|
||||||
vec![],
|
hir_vec![],
|
||||||
value_expr,
|
value_expr,
|
||||||
e.span,
|
e.span,
|
||||||
hir::PopUnsafeBlock(hir::CompilerGenerated), None)
|
hir::PopUnsafeBlock(hir::CompilerGenerated), None)
|
||||||
|
@ -1067,21 +1070,21 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
let ptr = expr_ident(lctx, e.span, p_ptr_ident, None);
|
let ptr = expr_ident(lctx, e.span, p_ptr_ident, None);
|
||||||
let call_move_val_init =
|
let call_move_val_init =
|
||||||
hir::StmtSemi(
|
hir::StmtSemi(
|
||||||
make_call(lctx, &move_val_init, vec![ptr, pop_unsafe_expr]),
|
make_call(lctx, &move_val_init, hir_vec![ptr, pop_unsafe_expr]),
|
||||||
lctx.next_id());
|
lctx.next_id());
|
||||||
let call_move_val_init = respan(e.span, call_move_val_init);
|
let call_move_val_init = respan(e.span, call_move_val_init);
|
||||||
|
|
||||||
let place = expr_ident(lctx, e.span, place_ident, None);
|
let place = expr_ident(lctx, e.span, place_ident, None);
|
||||||
let call = make_call(lctx, &inplace_finalize, vec![place]);
|
let call = make_call(lctx, &inplace_finalize, hir_vec![place]);
|
||||||
signal_block_expr(lctx,
|
signal_block_expr(lctx,
|
||||||
vec![call_move_val_init],
|
hir_vec![call_move_val_init],
|
||||||
call,
|
call,
|
||||||
e.span,
|
e.span,
|
||||||
hir::PushUnsafeBlock(hir::CompilerGenerated), None)
|
hir::PushUnsafeBlock(hir::CompilerGenerated), None)
|
||||||
};
|
};
|
||||||
|
|
||||||
signal_block_expr(lctx,
|
signal_block_expr(lctx,
|
||||||
vec![s1, s2, s3],
|
hir_vec![s1, s2, s3],
|
||||||
expr,
|
expr,
|
||||||
e.span,
|
e.span,
|
||||||
hir::PushUnstableBlock,
|
hir::PushUnstableBlock,
|
||||||
|
@ -1142,7 +1145,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
let els = lower_expr(lctx, els);
|
let els = lower_expr(lctx, els);
|
||||||
let id = lctx.next_id();
|
let id = lctx.next_id();
|
||||||
let blk = P(hir::Block {
|
let blk = P(hir::Block {
|
||||||
stmts: vec![],
|
stmts: hir_vec![],
|
||||||
expr: Some(els),
|
expr: Some(els),
|
||||||
id: id,
|
id: id,
|
||||||
rules: hir::DefaultBlock,
|
rules: hir::DefaultBlock,
|
||||||
|
@ -1239,7 +1242,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
.collect(),
|
.collect(),
|
||||||
asm: asm.clone(),
|
asm: asm.clone(),
|
||||||
asm_str_style: asm_str_style,
|
asm_str_style: asm_str_style,
|
||||||
clobbers: clobbers.clone(),
|
clobbers: clobbers.clone().into(),
|
||||||
volatile: volatile,
|
volatile: volatile,
|
||||||
alignstack: alignstack,
|
alignstack: alignstack,
|
||||||
dialect: dialect,
|
dialect: dialect,
|
||||||
|
@ -1276,7 +1279,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
let pat_arm = {
|
let pat_arm = {
|
||||||
let body = lower_block(lctx, body);
|
let body = lower_block(lctx, body);
|
||||||
let body_expr = expr_block(lctx, body, None);
|
let body_expr = expr_block(lctx, body, None);
|
||||||
arm(vec![lower_pat(lctx, pat)], body_expr)
|
arm(hir_vec![lower_pat(lctx, pat)], body_expr)
|
||||||
};
|
};
|
||||||
|
|
||||||
// `[_ if <else_opt_if_cond> => <else_opt_if_body>,]`
|
// `[_ if <else_opt_if_cond> => <else_opt_if_body>,]`
|
||||||
|
@ -1291,8 +1294,8 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
hir::ExprIf(cond, then, else_opt) => {
|
hir::ExprIf(cond, then, else_opt) => {
|
||||||
let pat_under = pat_wild(lctx, e.span);
|
let pat_under = pat_wild(lctx, e.span);
|
||||||
arms.push(hir::Arm {
|
arms.push(hir::Arm {
|
||||||
attrs: vec![],
|
attrs: hir_vec![],
|
||||||
pats: vec![pat_under],
|
pats: hir_vec![pat_under],
|
||||||
guard: Some(cond),
|
guard: Some(cond),
|
||||||
body: expr_block(lctx, then, None),
|
body: expr_block(lctx, then, None),
|
||||||
});
|
});
|
||||||
|
@ -1326,8 +1329,8 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
let pat_under = pat_wild(lctx, e.span);
|
let pat_under = pat_wild(lctx, e.span);
|
||||||
let else_expr =
|
let else_expr =
|
||||||
else_opt.unwrap_or_else(
|
else_opt.unwrap_or_else(
|
||||||
|| expr_tuple(lctx, e.span, vec![], None));
|
|| expr_tuple(lctx, e.span, hir_vec![], None));
|
||||||
arm(vec![pat_under], else_expr)
|
arm(hir_vec![pat_under], else_expr)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut arms = Vec::with_capacity(else_if_arms.len() + 2);
|
let mut arms = Vec::with_capacity(else_if_arms.len() + 2);
|
||||||
|
@ -1340,7 +1343,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
expr(lctx,
|
expr(lctx,
|
||||||
e.span,
|
e.span,
|
||||||
hir::ExprMatch(sub_expr,
|
hir::ExprMatch(sub_expr,
|
||||||
arms,
|
arms.into(),
|
||||||
hir::MatchSource::IfLetDesugar {
|
hir::MatchSource::IfLetDesugar {
|
||||||
contains_else_clause: contains_else_clause,
|
contains_else_clause: contains_else_clause,
|
||||||
}),
|
}),
|
||||||
|
@ -1365,18 +1368,18 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
let pat_arm = {
|
let pat_arm = {
|
||||||
let body = lower_block(lctx, body);
|
let body = lower_block(lctx, body);
|
||||||
let body_expr = expr_block(lctx, body, None);
|
let body_expr = expr_block(lctx, body, None);
|
||||||
arm(vec![lower_pat(lctx, pat)], body_expr)
|
arm(hir_vec![lower_pat(lctx, pat)], body_expr)
|
||||||
};
|
};
|
||||||
|
|
||||||
// `_ => break`
|
// `_ => break`
|
||||||
let break_arm = {
|
let break_arm = {
|
||||||
let pat_under = pat_wild(lctx, e.span);
|
let pat_under = pat_wild(lctx, e.span);
|
||||||
let break_expr = expr_break(lctx, e.span, None);
|
let break_expr = expr_break(lctx, e.span, None);
|
||||||
arm(vec![pat_under], break_expr)
|
arm(hir_vec![pat_under], break_expr)
|
||||||
};
|
};
|
||||||
|
|
||||||
// `match <sub_expr> { ... }`
|
// `match <sub_expr> { ... }`
|
||||||
let arms = vec![pat_arm, break_arm];
|
let arms = hir_vec![pat_arm, break_arm];
|
||||||
let sub_expr = lower_expr(lctx, sub_expr);
|
let sub_expr = lower_expr(lctx, sub_expr);
|
||||||
let match_expr = expr(lctx,
|
let match_expr = expr(lctx,
|
||||||
e.span,
|
e.span,
|
||||||
|
@ -1432,14 +1435,14 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
let pat = lower_pat(lctx, pat);
|
let pat = lower_pat(lctx, pat);
|
||||||
let some_pat = pat_some(lctx, e.span, pat);
|
let some_pat = pat_some(lctx, e.span, pat);
|
||||||
|
|
||||||
arm(vec![some_pat], body_expr)
|
arm(hir_vec![some_pat], body_expr)
|
||||||
};
|
};
|
||||||
|
|
||||||
// `::std::option::Option::None => break`
|
// `::std::option::Option::None => break`
|
||||||
let break_arm = {
|
let break_arm = {
|
||||||
let break_expr = expr_break(lctx, e.span, None);
|
let break_expr = expr_break(lctx, e.span, None);
|
||||||
|
|
||||||
arm(vec![pat_none(lctx, e.span)], break_expr)
|
arm(hir_vec![pat_none(lctx, e.span)], break_expr)
|
||||||
};
|
};
|
||||||
|
|
||||||
// `match ::std::iter::Iterator::next(&mut iter) { ... }`
|
// `match ::std::iter::Iterator::next(&mut iter) { ... }`
|
||||||
|
@ -1455,9 +1458,9 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
let next_expr = expr_call(lctx,
|
let next_expr = expr_call(lctx,
|
||||||
e.span,
|
e.span,
|
||||||
next_path,
|
next_path,
|
||||||
vec![ref_mut_iter],
|
hir_vec![ref_mut_iter],
|
||||||
None);
|
None);
|
||||||
let arms = vec![pat_arm, break_arm];
|
let arms = hir_vec![pat_arm, break_arm];
|
||||||
|
|
||||||
expr(lctx,
|
expr(lctx,
|
||||||
e.span,
|
e.span,
|
||||||
|
@ -1477,7 +1480,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
e.span,
|
e.span,
|
||||||
iter,
|
iter,
|
||||||
hir::BindByValue(hir::MutMutable));
|
hir::BindByValue(hir::MutMutable));
|
||||||
arm(vec![iter_pat], loop_expr)
|
arm(hir_vec![iter_pat], loop_expr)
|
||||||
};
|
};
|
||||||
|
|
||||||
// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
|
// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
|
||||||
|
@ -1489,13 +1492,13 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let into_iter = expr_path(lctx, into_iter_path, None);
|
let into_iter = expr_path(lctx, into_iter_path, None);
|
||||||
expr_call(lctx, e.span, into_iter, vec![head], None)
|
expr_call(lctx, e.span, into_iter, hir_vec![head], None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let match_expr = expr_match(lctx,
|
let match_expr = expr_match(lctx,
|
||||||
e.span,
|
e.span,
|
||||||
into_iter_expr,
|
into_iter_expr,
|
||||||
vec![iter_arm],
|
hir_vec![iter_arm],
|
||||||
hir::MatchSource::ForLoopDesugar,
|
hir::MatchSource::ForLoopDesugar,
|
||||||
None);
|
None);
|
||||||
|
|
||||||
|
@ -1503,7 +1506,7 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
|
||||||
let result_ident = lctx.str_to_ident("result");
|
let result_ident = lctx.str_to_ident("result");
|
||||||
let let_stmt = stmt_let(lctx, e.span, false, result_ident, match_expr, None);
|
let let_stmt = stmt_let(lctx, e.span, false, result_ident, match_expr, None);
|
||||||
let result = expr_ident(lctx, e.span, result_ident, None);
|
let result = expr_ident(lctx, e.span, result_ident, None);
|
||||||
let block = block_all(lctx, e.span, vec![let_stmt], Some(result));
|
let block = block_all(lctx, e.span, hir_vec![let_stmt], Some(result));
|
||||||
// add the attributes to the outer returned expr node
|
// add the attributes to the outer returned expr node
|
||||||
expr_block(lctx, block, e.attrs.clone())
|
expr_block(lctx, block, e.attrs.clone())
|
||||||
});
|
});
|
||||||
|
@ -1602,9 +1605,9 @@ pub fn lower_trait_bound_modifier(_lctx: &LoweringContext,
|
||||||
|
|
||||||
// Helper methods for building HIR.
|
// Helper methods for building HIR.
|
||||||
|
|
||||||
fn arm(pats: Vec<P<hir::Pat>>, expr: P<hir::Expr>) -> hir::Arm {
|
fn arm(pats: hir::HirVec<P<hir::Pat>>, expr: P<hir::Expr>) -> hir::Arm {
|
||||||
hir::Arm {
|
hir::Arm {
|
||||||
attrs: vec![],
|
attrs: hir_vec![],
|
||||||
pats: pats,
|
pats: pats,
|
||||||
guard: None,
|
guard: None,
|
||||||
body: expr,
|
body: expr,
|
||||||
|
@ -1619,7 +1622,7 @@ fn expr_break(lctx: &LoweringContext, span: Span,
|
||||||
fn expr_call(lctx: &LoweringContext,
|
fn expr_call(lctx: &LoweringContext,
|
||||||
span: Span,
|
span: Span,
|
||||||
e: P<hir::Expr>,
|
e: P<hir::Expr>,
|
||||||
args: Vec<P<hir::Expr>>,
|
args: hir::HirVec<P<hir::Expr>>,
|
||||||
attrs: ThinAttributes)
|
attrs: ThinAttributes)
|
||||||
-> P<hir::Expr> {
|
-> P<hir::Expr> {
|
||||||
expr(lctx, span, hir::ExprCall(e, args), attrs)
|
expr(lctx, span, hir::ExprCall(e, args), attrs)
|
||||||
|
@ -1643,7 +1646,7 @@ fn expr_path(lctx: &LoweringContext, path: hir::Path,
|
||||||
fn expr_match(lctx: &LoweringContext,
|
fn expr_match(lctx: &LoweringContext,
|
||||||
span: Span,
|
span: Span,
|
||||||
arg: P<hir::Expr>,
|
arg: P<hir::Expr>,
|
||||||
arms: Vec<hir::Arm>,
|
arms: hir::HirVec<hir::Arm>,
|
||||||
source: hir::MatchSource,
|
source: hir::MatchSource,
|
||||||
attrs: ThinAttributes)
|
attrs: ThinAttributes)
|
||||||
-> P<hir::Expr> {
|
-> P<hir::Expr> {
|
||||||
|
@ -1655,7 +1658,7 @@ fn expr_block(lctx: &LoweringContext, b: P<hir::Block>,
|
||||||
expr(lctx, b.span, hir::ExprBlock(b), attrs)
|
expr(lctx, b.span, hir::ExprBlock(b), attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_tuple(lctx: &LoweringContext, sp: Span, exprs: Vec<P<hir::Expr>>,
|
fn expr_tuple(lctx: &LoweringContext, sp: Span, exprs: hir::HirVec<P<hir::Expr>>,
|
||||||
attrs: ThinAttributes) -> P<hir::Expr> {
|
attrs: ThinAttributes) -> P<hir::Expr> {
|
||||||
expr(lctx, sp, hir::ExprTup(exprs), attrs)
|
expr(lctx, sp, hir::ExprTup(exprs), attrs)
|
||||||
}
|
}
|
||||||
|
@ -1695,12 +1698,12 @@ fn stmt_let(lctx: &LoweringContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_expr(lctx: &LoweringContext, expr: P<hir::Expr>) -> P<hir::Block> {
|
fn block_expr(lctx: &LoweringContext, expr: P<hir::Expr>) -> P<hir::Block> {
|
||||||
block_all(lctx, expr.span, Vec::new(), Some(expr))
|
block_all(lctx, expr.span, hir::HirVec::new(), Some(expr))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_all(lctx: &LoweringContext,
|
fn block_all(lctx: &LoweringContext,
|
||||||
span: Span,
|
span: Span,
|
||||||
stmts: Vec<hir::Stmt>,
|
stmts: hir::HirVec<hir::Stmt>,
|
||||||
expr: Option<P<hir::Expr>>)
|
expr: Option<P<hir::Expr>>)
|
||||||
-> P<hir::Block> {
|
-> P<hir::Block> {
|
||||||
P(hir::Block {
|
P(hir::Block {
|
||||||
|
@ -1715,19 +1718,19 @@ fn block_all(lctx: &LoweringContext,
|
||||||
fn pat_some(lctx: &LoweringContext, span: Span, pat: P<hir::Pat>) -> P<hir::Pat> {
|
fn pat_some(lctx: &LoweringContext, span: Span, pat: P<hir::Pat>) -> P<hir::Pat> {
|
||||||
let some = std_path(lctx, &["option", "Option", "Some"]);
|
let some = std_path(lctx, &["option", "Option", "Some"]);
|
||||||
let path = path_global(span, some);
|
let path = path_global(span, some);
|
||||||
pat_enum(lctx, span, path, vec![pat])
|
pat_enum(lctx, span, path, hir_vec![pat])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_none(lctx: &LoweringContext, span: Span) -> P<hir::Pat> {
|
fn pat_none(lctx: &LoweringContext, span: Span) -> P<hir::Pat> {
|
||||||
let none = std_path(lctx, &["option", "Option", "None"]);
|
let none = std_path(lctx, &["option", "Option", "None"]);
|
||||||
let path = path_global(span, none);
|
let path = path_global(span, none);
|
||||||
pat_enum(lctx, span, path, vec![])
|
pat_enum(lctx, span, path, hir_vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_enum(lctx: &LoweringContext,
|
fn pat_enum(lctx: &LoweringContext,
|
||||||
span: Span,
|
span: Span,
|
||||||
path: hir::Path,
|
path: hir::Path,
|
||||||
subpats: Vec<P<hir::Pat>>)
|
subpats: hir::HirVec<P<hir::Pat>>)
|
||||||
-> P<hir::Pat> {
|
-> P<hir::Pat> {
|
||||||
let pt = hir::PatEnum(path, Some(subpats));
|
let pt = hir::PatEnum(path, Some(subpats));
|
||||||
pat(lctx, span, pt)
|
pat(lctx, span, pt)
|
||||||
|
@ -1768,17 +1771,17 @@ fn path_ident(span: Span, id: hir::Ident) -> hir::Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path(span: Span, strs: Vec<hir::Ident>) -> hir::Path {
|
fn path(span: Span, strs: Vec<hir::Ident>) -> hir::Path {
|
||||||
path_all(span, false, strs, Vec::new(), Vec::new(), Vec::new())
|
path_all(span, false, strs, hir::HirVec::new(), Vec::new(), Vec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_global(span: Span, strs: Vec<hir::Ident>) -> hir::Path {
|
fn path_global(span: Span, strs: Vec<hir::Ident>) -> hir::Path {
|
||||||
path_all(span, true, strs, Vec::new(), Vec::new(), Vec::new())
|
path_all(span, true, strs, hir::HirVec::new(), Vec::new(), Vec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_all(sp: Span,
|
fn path_all(sp: Span,
|
||||||
global: bool,
|
global: bool,
|
||||||
mut idents: Vec<hir::Ident>,
|
mut idents: Vec<hir::Ident>,
|
||||||
lifetimes: Vec<hir::Lifetime>,
|
lifetimes: hir::HirVec<hir::Lifetime>,
|
||||||
types: Vec<P<hir::Ty>>,
|
types: Vec<P<hir::Ty>>,
|
||||||
bindings: Vec<hir::TypeBinding>)
|
bindings: Vec<hir::TypeBinding>)
|
||||||
-> hir::Path {
|
-> hir::Path {
|
||||||
|
@ -1795,14 +1798,14 @@ fn path_all(sp: Span,
|
||||||
identifier: last_identifier,
|
identifier: last_identifier,
|
||||||
parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
|
parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
|
||||||
lifetimes: lifetimes,
|
lifetimes: lifetimes,
|
||||||
types: OwnedSlice::from_vec(types),
|
types: P::from_vec(types),
|
||||||
bindings: OwnedSlice::from_vec(bindings),
|
bindings: P::from_vec(bindings),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
hir::Path {
|
hir::Path {
|
||||||
span: sp,
|
span: sp,
|
||||||
global: global,
|
global: global,
|
||||||
segments: segments,
|
segments: segments.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1823,7 +1826,7 @@ fn core_path(lctx: &LoweringContext, span: Span, components: &[&str]) -> hir::Pa
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signal_block_expr(lctx: &LoweringContext,
|
fn signal_block_expr(lctx: &LoweringContext,
|
||||||
stmts: Vec<hir::Stmt>,
|
stmts: hir::HirVec<hir::Stmt>,
|
||||||
expr: P<hir::Expr>,
|
expr: P<hir::Expr>,
|
||||||
span: Span,
|
span: Span,
|
||||||
rule: hir::BlockCheckMode,
|
rule: hir::BlockCheckMode,
|
||||||
|
|
|
@ -12,7 +12,6 @@ pub use self::AnnNode::*;
|
||||||
|
|
||||||
use syntax::abi;
|
use syntax::abi;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
use syntax::codemap::{self, CodeMap, BytePos, Spanned};
|
use syntax::codemap::{self, CodeMap, BytePos, Spanned};
|
||||||
use syntax::errors;
|
use syntax::errors;
|
||||||
use syntax::parse::token::{self, BinOpToken};
|
use syntax::parse::token::{self, BinOpToken};
|
||||||
|
@ -519,10 +518,10 @@ impl<'a> State<'a> {
|
||||||
hir::TyBareFn(ref f) => {
|
hir::TyBareFn(ref f) => {
|
||||||
let generics = hir::Generics {
|
let generics = hir::Generics {
|
||||||
lifetimes: f.lifetimes.clone(),
|
lifetimes: f.lifetimes.clone(),
|
||||||
ty_params: OwnedSlice::empty(),
|
ty_params: P::empty(),
|
||||||
where_clause: hir::WhereClause {
|
where_clause: hir::WhereClause {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
predicates: Vec::new(),
|
predicates: hir::HirVec::new(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
try!(self.print_ty_fn(f.abi, f.unsafety, &*f.decl, None, &generics, None));
|
try!(self.print_ty_fn(f.abi, f.unsafety, &*f.decl, None, &generics, None));
|
||||||
|
@ -2257,11 +2256,11 @@ impl<'a> State<'a> {
|
||||||
try!(self.print_generics(generics));
|
try!(self.print_generics(generics));
|
||||||
}
|
}
|
||||||
let generics = hir::Generics {
|
let generics = hir::Generics {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: hir::HirVec::new(),
|
||||||
ty_params: OwnedSlice::empty(),
|
ty_params: P::empty(),
|
||||||
where_clause: hir::WhereClause {
|
where_clause: hir::WhereClause {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
predicates: Vec::new(),
|
predicates: hir::HirVec::new(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
try!(self.print_fn(decl,
|
try!(self.print_fn(decl,
|
||||||
|
|
|
@ -15,7 +15,6 @@ use syntax::ast_util;
|
||||||
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID};
|
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID};
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
|
|
||||||
pub fn walk_pat<F>(pat: &Pat, mut it: F) -> bool
|
pub fn walk_pat<F>(pat: &Pat, mut it: F) -> bool
|
||||||
where F: FnMut(&Pat) -> bool
|
where F: FnMut(&Pat) -> bool
|
||||||
|
@ -335,11 +334,11 @@ pub fn is_path(e: P<Expr>) -> bool {
|
||||||
|
|
||||||
pub fn empty_generics() -> Generics {
|
pub fn empty_generics() -> Generics {
|
||||||
Generics {
|
Generics {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: HirVec::new(),
|
||||||
ty_params: OwnedSlice::empty(),
|
ty_params: P::empty(),
|
||||||
where_clause: WhereClause {
|
where_clause: WhereClause {
|
||||||
id: DUMMY_NODE_ID,
|
id: DUMMY_NODE_ID,
|
||||||
predicates: Vec::new(),
|
predicates: HirVec::new(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,13 +349,13 @@ pub fn ident_to_path(s: Span, ident: Ident) -> Path {
|
||||||
hir::Path {
|
hir::Path {
|
||||||
span: s,
|
span: s,
|
||||||
global: false,
|
global: false,
|
||||||
segments: vec!(hir::PathSegment {
|
segments: hir_vec![hir::PathSegment {
|
||||||
identifier: ident,
|
identifier: ident,
|
||||||
parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
|
parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: HirVec::new(),
|
||||||
types: OwnedSlice::empty(),
|
types: P::empty(),
|
||||||
bindings: OwnedSlice::empty(),
|
bindings: P::empty(),
|
||||||
}),
|
}),
|
||||||
}),
|
}],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_pats(&mut self, pats: &'tcx Vec<P<hir::Pat>>) -> Vec<Pattern<'tcx>> {
|
fn to_pats(&mut self, pats: &'tcx [P<hir::Pat>]) -> Vec<Pattern<'tcx>> {
|
||||||
pats.iter().map(|p| self.to_pat(p)).collect()
|
pats.iter().map(|p| self.to_pat(p)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,9 +267,9 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
||||||
fn slice_or_array_pattern(&mut self,
|
fn slice_or_array_pattern(&mut self,
|
||||||
pat: &'tcx hir::Pat,
|
pat: &'tcx hir::Pat,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
prefix: &'tcx Vec<P<hir::Pat>>,
|
prefix: &'tcx [P<hir::Pat>],
|
||||||
slice: &'tcx Option<P<hir::Pat>>,
|
slice: &'tcx Option<P<hir::Pat>>,
|
||||||
suffix: &'tcx Vec<P<hir::Pat>>)
|
suffix: &'tcx [P<hir::Pat>])
|
||||||
-> PatternKind<'tcx> {
|
-> PatternKind<'tcx> {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TySlice(..) => {
|
ty::TySlice(..) => {
|
||||||
|
|
|
@ -41,7 +41,6 @@ use std::fs::File;
|
||||||
use syntax::ast::{self, NodeId};
|
use syntax::ast::{self, NodeId};
|
||||||
use syntax::codemap::*;
|
use syntax::codemap::*;
|
||||||
use syntax::parse::token::{self, keywords};
|
use syntax::parse::token::{self, keywords};
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
use syntax::visit::{self, Visitor};
|
use syntax::visit::{self, Visitor};
|
||||||
use syntax::print::pprust::{path_to_string, ty_to_string};
|
use syntax::print::pprust::{path_to_string, ty_to_string};
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
|
@ -572,7 +571,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
||||||
fn process_trait(&mut self,
|
fn process_trait(&mut self,
|
||||||
item: &ast::Item,
|
item: &ast::Item,
|
||||||
generics: &ast::Generics,
|
generics: &ast::Generics,
|
||||||
trait_refs: &OwnedSlice<ast::TyParamBound>,
|
trait_refs: &ast::TyParamBounds,
|
||||||
methods: &[P<ast::TraitItem>]) {
|
methods: &[P<ast::TraitItem>]) {
|
||||||
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
|
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
|
||||||
let val = self.span.snippet(item.span);
|
let val = self.span.snippet(item.span);
|
||||||
|
|
|
@ -1037,7 +1037,7 @@ pub fn trans_static(ccx: &CrateContext,
|
||||||
m: hir::Mutability,
|
m: hir::Mutability,
|
||||||
expr: &hir::Expr,
|
expr: &hir::Expr,
|
||||||
id: ast::NodeId,
|
id: ast::NodeId,
|
||||||
attrs: &Vec<ast::Attribute>)
|
attrs: &[ast::Attribute])
|
||||||
-> Result<ValueRef, ConstEvalErr> {
|
-> Result<ValueRef, ConstEvalErr> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let _icx = push_ctxt("trans_static");
|
let _icx = push_ctxt("trans_static");
|
||||||
|
|
|
@ -119,7 +119,6 @@ use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::attr::AttrMetaMethods;
|
use syntax::attr::AttrMetaMethods;
|
||||||
use syntax::codemap::{self, Span, Spanned};
|
use syntax::codemap::{self, Span, Spanned};
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
use syntax::parse::token::{self, InternedString};
|
use syntax::parse::token::{self, InternedString};
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::util::lev_distance::lev_distance;
|
use syntax::util::lev_distance::lev_distance;
|
||||||
|
@ -4907,7 +4906,7 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &hir::Block) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||||
tps: &OwnedSlice<hir::TyParam>,
|
tps: &P<[hir::TyParam]>,
|
||||||
ty: Ty<'tcx>) {
|
ty: Ty<'tcx>) {
|
||||||
debug!("check_bounds_are_used(n_tps={}, ty={:?})",
|
debug!("check_bounds_are_used(n_tps={}, ty={:?})",
|
||||||
tps.len(), ty);
|
tps.len(), ty);
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl<T, U> Clean<U> for ty::Binder<T> where T: Clean<U> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Clean<U>, U> Clean<Vec<U>> for syntax::owned_slice::OwnedSlice<T> {
|
impl<T: Clean<U>, U> Clean<Vec<U>> for P<[T]> {
|
||||||
fn clean(&self, cx: &DocContext) -> Vec<U> {
|
fn clean(&self, cx: &DocContext) -> Vec<U> {
|
||||||
self.iter().map(|x| x.clean(cx)).collect()
|
self.iter().map(|x| x.clean(cx)).collect()
|
||||||
}
|
}
|
||||||
|
@ -1584,8 +1584,13 @@ impl Clean<Type> for hir::Ty {
|
||||||
resolve_type(cx, p.clean(cx), self.id)
|
resolve_type(cx, p.clean(cx), self.id)
|
||||||
}
|
}
|
||||||
TyPath(Some(ref qself), ref p) => {
|
TyPath(Some(ref qself), ref p) => {
|
||||||
let mut trait_path = p.clone();
|
let mut segments: Vec<_> = p.segments.clone().into();
|
||||||
trait_path.segments.pop();
|
segments.pop();
|
||||||
|
let trait_path = hir::Path {
|
||||||
|
span: p.span,
|
||||||
|
global: p.global,
|
||||||
|
segments: segments.into(),
|
||||||
|
};
|
||||||
Type::QPath {
|
Type::QPath {
|
||||||
name: p.segments.last().unwrap().identifier.name.clean(cx),
|
name: p.segments.last().unwrap().identifier.name.clean(cx),
|
||||||
self_type: box qself.ty.clean(cx),
|
self_type: box qself.ty.clean(cx),
|
||||||
|
|
|
@ -24,7 +24,7 @@ use rustc_front::hir;
|
||||||
|
|
||||||
pub struct Module {
|
pub struct Module {
|
||||||
pub name: Option<Name>,
|
pub name: Option<Name>,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub where_outer: Span,
|
pub where_outer: Span,
|
||||||
pub where_inner: Span,
|
pub where_inner: Span,
|
||||||
pub extern_crates: Vec<ExternCrate>,
|
pub extern_crates: Vec<ExternCrate>,
|
||||||
|
@ -58,7 +58,7 @@ impl Module {
|
||||||
depr: None,
|
depr: None,
|
||||||
where_outer: syntax::codemap::DUMMY_SP,
|
where_outer: syntax::codemap::DUMMY_SP,
|
||||||
where_inner: syntax::codemap::DUMMY_SP,
|
where_inner: syntax::codemap::DUMMY_SP,
|
||||||
attrs : Vec::new(),
|
attrs : hir::HirVec::new(),
|
||||||
extern_crates: Vec::new(),
|
extern_crates: Vec::new(),
|
||||||
imports : Vec::new(),
|
imports : Vec::new(),
|
||||||
structs : Vec::new(),
|
structs : Vec::new(),
|
||||||
|
@ -103,8 +103,8 @@ pub struct Struct {
|
||||||
pub struct_type: StructType,
|
pub struct_type: StructType,
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub generics: hir::Generics,
|
pub generics: hir::Generics,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub fields: Vec<hir::StructField>,
|
pub fields: hir::HirVec<hir::StructField>,
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,9 +112,9 @@ pub struct Enum {
|
||||||
pub vis: hir::Visibility,
|
pub vis: hir::Visibility,
|
||||||
pub stab: Option<attr::Stability>,
|
pub stab: Option<attr::Stability>,
|
||||||
pub depr: Option<attr::Deprecation>,
|
pub depr: Option<attr::Deprecation>,
|
||||||
pub variants: Vec<Variant>,
|
pub variants: hir::HirVec<Variant>,
|
||||||
pub generics: hir::Generics,
|
pub generics: hir::Generics,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
|
@ -122,7 +122,7 @@ pub struct Enum {
|
||||||
|
|
||||||
pub struct Variant {
|
pub struct Variant {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub def: hir::VariantData,
|
pub def: hir::VariantData,
|
||||||
pub stab: Option<attr::Stability>,
|
pub stab: Option<attr::Stability>,
|
||||||
pub depr: Option<attr::Deprecation>,
|
pub depr: Option<attr::Deprecation>,
|
||||||
|
@ -131,7 +131,7 @@ pub struct Variant {
|
||||||
|
|
||||||
pub struct Function {
|
pub struct Function {
|
||||||
pub decl: hir::FnDecl,
|
pub decl: hir::FnDecl,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub vis: hir::Visibility,
|
pub vis: hir::Visibility,
|
||||||
|
@ -149,7 +149,7 @@ pub struct Typedef {
|
||||||
pub gen: hir::Generics,
|
pub gen: hir::Generics,
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub id: ast::NodeId,
|
pub id: ast::NodeId,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
pub vis: hir::Visibility,
|
pub vis: hir::Visibility,
|
||||||
pub stab: Option<attr::Stability>,
|
pub stab: Option<attr::Stability>,
|
||||||
|
@ -162,7 +162,7 @@ pub struct Static {
|
||||||
pub mutability: hir::Mutability,
|
pub mutability: hir::Mutability,
|
||||||
pub expr: P<hir::Expr>,
|
pub expr: P<hir::Expr>,
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub vis: hir::Visibility,
|
pub vis: hir::Visibility,
|
||||||
pub stab: Option<attr::Stability>,
|
pub stab: Option<attr::Stability>,
|
||||||
pub depr: Option<attr::Deprecation>,
|
pub depr: Option<attr::Deprecation>,
|
||||||
|
@ -174,7 +174,7 @@ pub struct Constant {
|
||||||
pub type_: P<hir::Ty>,
|
pub type_: P<hir::Ty>,
|
||||||
pub expr: P<hir::Expr>,
|
pub expr: P<hir::Expr>,
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub vis: hir::Visibility,
|
pub vis: hir::Visibility,
|
||||||
pub stab: Option<attr::Stability>,
|
pub stab: Option<attr::Stability>,
|
||||||
pub depr: Option<attr::Deprecation>,
|
pub depr: Option<attr::Deprecation>,
|
||||||
|
@ -185,10 +185,10 @@ pub struct Constant {
|
||||||
pub struct Trait {
|
pub struct Trait {
|
||||||
pub unsafety: hir::Unsafety,
|
pub unsafety: hir::Unsafety,
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub items: Vec<hir::TraitItem>,
|
pub items: hir::HirVec<hir::TraitItem>,
|
||||||
pub generics: hir::Generics,
|
pub generics: hir::Generics,
|
||||||
pub bounds: Vec<hir::TyParamBound>,
|
pub bounds: hir::HirVec<hir::TyParamBound>,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub id: ast::NodeId,
|
pub id: ast::NodeId,
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
pub vis: hir::Visibility,
|
pub vis: hir::Visibility,
|
||||||
|
@ -202,8 +202,8 @@ pub struct Impl {
|
||||||
pub generics: hir::Generics,
|
pub generics: hir::Generics,
|
||||||
pub trait_: Option<hir::TraitRef>,
|
pub trait_: Option<hir::TraitRef>,
|
||||||
pub for_: P<hir::Ty>,
|
pub for_: P<hir::Ty>,
|
||||||
pub items: Vec<hir::ImplItem>,
|
pub items: hir::HirVec<hir::ImplItem>,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
pub vis: hir::Visibility,
|
pub vis: hir::Visibility,
|
||||||
pub stab: Option<attr::Stability>,
|
pub stab: Option<attr::Stability>,
|
||||||
|
@ -215,16 +215,16 @@ pub struct DefaultImpl {
|
||||||
pub unsafety: hir::Unsafety,
|
pub unsafety: hir::Unsafety,
|
||||||
pub trait_: hir::TraitRef,
|
pub trait_: hir::TraitRef,
|
||||||
pub id: ast::NodeId,
|
pub id: ast::NodeId,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Macro {
|
pub struct Macro {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub id: ast::NodeId,
|
pub id: ast::NodeId,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
pub matchers: Vec<Span>,
|
pub matchers: hir::HirVec<Span>,
|
||||||
pub stab: Option<attr::Stability>,
|
pub stab: Option<attr::Stability>,
|
||||||
pub depr: Option<attr::Deprecation>,
|
pub depr: Option<attr::Deprecation>,
|
||||||
pub imported_from: Option<Name>,
|
pub imported_from: Option<Name>,
|
||||||
|
@ -234,14 +234,14 @@ pub struct ExternCrate {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub path: Option<String>,
|
pub path: Option<String>,
|
||||||
pub vis: hir::Visibility,
|
pub vis: hir::Visibility,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Import {
|
pub struct Import {
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub vis: hir::Visibility,
|
pub vis: hir::Visibility,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub node: hir::ViewPath_,
|
pub node: hir::ViewPath_,
|
||||||
pub whence: Span,
|
pub whence: Span,
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ use doctree::*;
|
||||||
|
|
||||||
pub struct RustdocVisitor<'a, 'tcx: 'a> {
|
pub struct RustdocVisitor<'a, 'tcx: 'a> {
|
||||||
pub module: Module,
|
pub module: Module,
|
||||||
pub attrs: Vec<ast::Attribute>,
|
pub attrs: hir::HirVec<ast::Attribute>,
|
||||||
pub cx: &'a core::DocContext<'a, 'tcx>,
|
pub cx: &'a core::DocContext<'a, 'tcx>,
|
||||||
pub analysis: Option<&'a core::CrateAnalysis>,
|
pub analysis: Option<&'a core::CrateAnalysis>,
|
||||||
view_item_stack: HashSet<ast::NodeId>,
|
view_item_stack: HashSet<ast::NodeId>,
|
||||||
|
@ -53,7 +53,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
stack.insert(ast::CRATE_NODE_ID);
|
stack.insert(ast::CRATE_NODE_ID);
|
||||||
RustdocVisitor {
|
RustdocVisitor {
|
||||||
module: Module::new(None),
|
module: Module::new(None),
|
||||||
attrs: Vec::new(),
|
attrs: hir::HirVec::new(),
|
||||||
cx: cx,
|
cx: cx,
|
||||||
analysis: analysis,
|
analysis: analysis,
|
||||||
view_item_stack: stack,
|
view_item_stack: stack,
|
||||||
|
@ -157,7 +157,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn visit_mod_contents(&mut self, span: Span, attrs: Vec<ast::Attribute> ,
|
pub fn visit_mod_contents(&mut self, span: Span, attrs: hir::HirVec<ast::Attribute>,
|
||||||
vis: hir::Visibility, id: ast::NodeId,
|
vis: hir::Visibility, id: ast::NodeId,
|
||||||
m: &hir::Mod,
|
m: &hir::Mod,
|
||||||
name: Option<ast::Name>) -> Module {
|
name: Option<ast::Name>) -> Module {
|
||||||
|
@ -192,7 +192,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
let mine = paths.into_iter().filter(|path| {
|
let mine = paths.into_iter().filter(|path| {
|
||||||
!self.resolve_id(path.node.id(), None, false, om,
|
!self.resolve_id(path.node.id(), None, false, om,
|
||||||
please_inline)
|
please_inline)
|
||||||
}).collect::<Vec<hir::PathListItem>>();
|
}).collect::<hir::HirVec<hir::PathListItem>>();
|
||||||
|
|
||||||
if mine.is_empty() {
|
if mine.is_empty() {
|
||||||
None
|
None
|
||||||
|
|
|
@ -50,7 +50,6 @@ use codemap::{Span, Spanned, DUMMY_SP, ExpnId};
|
||||||
use abi::Abi;
|
use abi::Abi;
|
||||||
use ext::base;
|
use ext::base;
|
||||||
use ext::tt::macro_parser;
|
use ext::tt::macro_parser;
|
||||||
use owned_slice::OwnedSlice;
|
|
||||||
use parse::token::InternedString;
|
use parse::token::InternedString;
|
||||||
use parse::token;
|
use parse::token;
|
||||||
use parse::lexer;
|
use parse::lexer;
|
||||||
|
@ -261,8 +260,8 @@ impl PathParameters {
|
||||||
pub fn none() -> PathParameters {
|
pub fn none() -> PathParameters {
|
||||||
AngleBracketedParameters(AngleBracketedParameterData {
|
AngleBracketedParameters(AngleBracketedParameterData {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: Vec::new(),
|
||||||
types: OwnedSlice::empty(),
|
types: P::empty(),
|
||||||
bindings: OwnedSlice::empty(),
|
bindings: P::empty(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,10 +333,10 @@ pub struct AngleBracketedParameterData {
|
||||||
/// The lifetime parameters for this path segment.
|
/// The lifetime parameters for this path segment.
|
||||||
pub lifetimes: Vec<Lifetime>,
|
pub lifetimes: Vec<Lifetime>,
|
||||||
/// The type parameters for this path segment, if present.
|
/// The type parameters for this path segment, if present.
|
||||||
pub types: OwnedSlice<P<Ty>>,
|
pub types: P<[P<Ty>]>,
|
||||||
/// Bindings (equality constraints) on associated types, if present.
|
/// Bindings (equality constraints) on associated types, if present.
|
||||||
/// E.g., `Foo<A=Bar>`.
|
/// E.g., `Foo<A=Bar>`.
|
||||||
pub bindings: OwnedSlice<P<TypeBinding>>,
|
pub bindings: P<[P<TypeBinding>]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AngleBracketedParameterData {
|
impl AngleBracketedParameterData {
|
||||||
|
@ -394,7 +393,7 @@ pub enum TraitBoundModifier {
|
||||||
Maybe,
|
Maybe,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type TyParamBounds = OwnedSlice<TyParamBound>;
|
pub type TyParamBounds = P<[TyParamBound]>;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct TyParam {
|
pub struct TyParam {
|
||||||
|
@ -410,7 +409,7 @@ pub struct TyParam {
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub struct Generics {
|
pub struct Generics {
|
||||||
pub lifetimes: Vec<LifetimeDef>,
|
pub lifetimes: Vec<LifetimeDef>,
|
||||||
pub ty_params: OwnedSlice<TyParam>,
|
pub ty_params: P<[TyParam]>,
|
||||||
pub where_clause: WhereClause,
|
pub where_clause: WhereClause,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,7 +429,7 @@ impl Default for Generics {
|
||||||
fn default() -> Generics {
|
fn default() -> Generics {
|
||||||
Generics {
|
Generics {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: Vec::new(),
|
||||||
ty_params: OwnedSlice::empty(),
|
ty_params: P::empty(),
|
||||||
where_clause: WhereClause {
|
where_clause: WhereClause {
|
||||||
id: DUMMY_NODE_ID,
|
id: DUMMY_NODE_ID,
|
||||||
predicates: Vec::new(),
|
predicates: Vec::new(),
|
||||||
|
@ -466,7 +465,7 @@ pub struct WhereBoundPredicate {
|
||||||
/// The type being bounded
|
/// The type being bounded
|
||||||
pub bounded_ty: P<Ty>,
|
pub bounded_ty: P<Ty>,
|
||||||
/// Trait and lifetime bounds (`Clone+Send+'static`)
|
/// Trait and lifetime bounds (`Clone+Send+'static`)
|
||||||
pub bounds: OwnedSlice<TyParamBound>,
|
pub bounds: TyParamBounds,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A lifetime predicate, e.g. `'a: 'b+'c`
|
/// A lifetime predicate, e.g. `'a: 'b+'c`
|
||||||
|
|
|
@ -12,7 +12,6 @@ use ast::*;
|
||||||
use ast;
|
use ast;
|
||||||
use codemap;
|
use codemap;
|
||||||
use codemap::Span;
|
use codemap::Span;
|
||||||
use owned_slice::OwnedSlice;
|
|
||||||
use parse::token;
|
use parse::token;
|
||||||
use print::pprust;
|
use print::pprust;
|
||||||
use ptr::P;
|
use ptr::P;
|
||||||
|
@ -43,8 +42,8 @@ pub fn ident_to_path(s: Span, identifier: Ident) -> Path {
|
||||||
identifier: identifier,
|
identifier: identifier,
|
||||||
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: Vec::new(),
|
||||||
types: OwnedSlice::empty(),
|
types: P::empty(),
|
||||||
bindings: OwnedSlice::empty(),
|
bindings: P::empty(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
|
@ -14,7 +14,6 @@ use ast;
|
||||||
use attr;
|
use attr;
|
||||||
use codemap::{Span, respan, Spanned, DUMMY_SP, Pos};
|
use codemap::{Span, respan, Spanned, DUMMY_SP, Pos};
|
||||||
use ext::base::ExtCtxt;
|
use ext::base::ExtCtxt;
|
||||||
use owned_slice::OwnedSlice;
|
|
||||||
use parse::token::special_idents;
|
use parse::token::special_idents;
|
||||||
use parse::token::InternedString;
|
use parse::token::InternedString;
|
||||||
use parse::token;
|
use parse::token;
|
||||||
|
@ -56,7 +55,7 @@ pub trait AstBuilder {
|
||||||
|
|
||||||
fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty>;
|
fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty>;
|
||||||
fn ty_path(&self, ast::Path) -> P<ast::Ty>;
|
fn ty_path(&self, ast::Path) -> P<ast::Ty>;
|
||||||
fn ty_sum(&self, ast::Path, OwnedSlice<ast::TyParamBound>) -> P<ast::Ty>;
|
fn ty_sum(&self, ast::Path, ast::TyParamBounds) -> P<ast::Ty>;
|
||||||
fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>;
|
fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>;
|
||||||
|
|
||||||
fn ty_rptr(&self, span: Span,
|
fn ty_rptr(&self, span: Span,
|
||||||
|
@ -70,13 +69,13 @@ pub trait AstBuilder {
|
||||||
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>;
|
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>;
|
||||||
fn ty_infer(&self, sp: Span) -> P<ast::Ty>;
|
fn ty_infer(&self, sp: Span) -> P<ast::Ty>;
|
||||||
|
|
||||||
fn ty_vars(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> ;
|
fn ty_vars(&self, ty_params: &P<[ast::TyParam]>) -> Vec<P<ast::Ty>> ;
|
||||||
fn ty_vars_global(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> ;
|
fn ty_vars_global(&self, ty_params: &P<[ast::TyParam]>) -> Vec<P<ast::Ty>> ;
|
||||||
|
|
||||||
fn typaram(&self,
|
fn typaram(&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
id: ast::Ident,
|
id: ast::Ident,
|
||||||
bounds: OwnedSlice<ast::TyParamBound>,
|
bounds: ast::TyParamBounds,
|
||||||
default: Option<P<ast::Ty>>) -> ast::TyParam;
|
default: Option<P<ast::Ty>>) -> ast::TyParam;
|
||||||
|
|
||||||
fn trait_ref(&self, path: ast::Path) -> ast::TraitRef;
|
fn trait_ref(&self, path: ast::Path) -> ast::TraitRef;
|
||||||
|
@ -331,8 +330,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
identifier: last_identifier,
|
identifier: last_identifier,
|
||||||
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
||||||
lifetimes: lifetimes,
|
lifetimes: lifetimes,
|
||||||
types: OwnedSlice::from_vec(types),
|
types: P::from_vec(types),
|
||||||
bindings: OwnedSlice::from_vec(bindings),
|
bindings: P::from_vec(bindings),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
ast::Path {
|
ast::Path {
|
||||||
|
@ -369,8 +368,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
identifier: ident,
|
identifier: ident,
|
||||||
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
||||||
lifetimes: lifetimes,
|
lifetimes: lifetimes,
|
||||||
types: OwnedSlice::from_vec(types),
|
types: P::from_vec(types),
|
||||||
bindings: OwnedSlice::from_vec(bindings),
|
bindings: P::from_vec(bindings),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -399,7 +398,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
self.ty(path.span, ast::TyPath(None, path))
|
self.ty(path.span, ast::TyPath(None, path))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_sum(&self, path: ast::Path, bounds: OwnedSlice<ast::TyParamBound>) -> P<ast::Ty> {
|
fn ty_sum(&self, path: ast::Path, bounds: ast::TyParamBounds) -> P<ast::Ty> {
|
||||||
self.ty(path.span,
|
self.ty(path.span,
|
||||||
ast::TyObjectSum(self.ty_path(path),
|
ast::TyObjectSum(self.ty_path(path),
|
||||||
bounds))
|
bounds))
|
||||||
|
@ -448,7 +447,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
fn typaram(&self,
|
fn typaram(&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
id: ast::Ident,
|
id: ast::Ident,
|
||||||
bounds: OwnedSlice<ast::TyParamBound>,
|
bounds: ast::TyParamBounds,
|
||||||
default: Option<P<ast::Ty>>) -> ast::TyParam {
|
default: Option<P<ast::Ty>>) -> ast::TyParam {
|
||||||
ast::TyParam {
|
ast::TyParam {
|
||||||
ident: id,
|
ident: id,
|
||||||
|
@ -462,11 +461,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
// these are strange, and probably shouldn't be used outside of
|
// these are strange, and probably shouldn't be used outside of
|
||||||
// pipes. Specifically, the global version possible generates
|
// pipes. Specifically, the global version possible generates
|
||||||
// incorrect code.
|
// incorrect code.
|
||||||
fn ty_vars(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> {
|
fn ty_vars(&self, ty_params: &P<[ast::TyParam]>) -> Vec<P<ast::Ty>> {
|
||||||
ty_params.iter().map(|p| self.ty_ident(DUMMY_SP, p.ident)).collect()
|
ty_params.iter().map(|p| self.ty_ident(DUMMY_SP, p.ident)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_vars_global(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> {
|
fn ty_vars_global(&self, ty_params: &P<[ast::TyParam]>) -> Vec<P<ast::Ty>> {
|
||||||
ty_params
|
ty_params
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| self.ty_path(self.path_global(DUMMY_SP, vec!(p.ident))))
|
.map(|p| self.ty_path(self.path_global(DUMMY_SP, vec!(p.ident))))
|
||||||
|
|
|
@ -23,7 +23,6 @@ use ast;
|
||||||
use attr::{ThinAttributes, ThinAttributesExt};
|
use attr::{ThinAttributes, ThinAttributesExt};
|
||||||
use ast_util;
|
use ast_util;
|
||||||
use codemap::{respan, Span, Spanned};
|
use codemap::{respan, Span, Spanned};
|
||||||
use owned_slice::OwnedSlice;
|
|
||||||
use parse::token;
|
use parse::token;
|
||||||
use ptr::P;
|
use ptr::P;
|
||||||
use util::small_vector::SmallVector;
|
use util::small_vector::SmallVector;
|
||||||
|
@ -233,7 +232,7 @@ pub trait Folder : Sized {
|
||||||
noop_fold_ty_param(tp, self)
|
noop_fold_ty_param(tp, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty_params(&mut self, tps: OwnedSlice<TyParam>) -> OwnedSlice<TyParam> {
|
fn fold_ty_params(&mut self, tps: P<[TyParam]>) -> P<[TyParam]> {
|
||||||
noop_fold_ty_params(tps, self)
|
noop_fold_ty_params(tps, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,13 +256,13 @@ pub trait Folder : Sized {
|
||||||
noop_fold_opt_lifetime(o_lt, self)
|
noop_fold_opt_lifetime(o_lt, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_opt_bounds(&mut self, b: Option<OwnedSlice<TyParamBound>>)
|
fn fold_opt_bounds(&mut self, b: Option<TyParamBounds>)
|
||||||
-> Option<OwnedSlice<TyParamBound>> {
|
-> Option<TyParamBounds> {
|
||||||
noop_fold_opt_bounds(b, self)
|
noop_fold_opt_bounds(b, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_bounds(&mut self, b: OwnedSlice<TyParamBound>)
|
fn fold_bounds(&mut self, b: TyParamBounds)
|
||||||
-> OwnedSlice<TyParamBound> {
|
-> TyParamBounds {
|
||||||
noop_fold_bounds(b, self)
|
noop_fold_bounds(b, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,8 +713,8 @@ pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_fold_ty_params<T: Folder>(tps: OwnedSlice<TyParam>, fld: &mut T)
|
pub fn noop_fold_ty_params<T: Folder>(tps: P<[TyParam]>, fld: &mut T)
|
||||||
-> OwnedSlice<TyParam> {
|
-> P<[TyParam]> {
|
||||||
tps.move_map(|tp| fld.fold_ty_param(tp))
|
tps.move_map(|tp| fld.fold_ty_param(tp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,8 +870,8 @@ pub fn noop_fold_mt<T: Folder>(MutTy {ty, mutbl}: MutTy, folder: &mut T) -> MutT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<OwnedSlice<TyParamBound>>, folder: &mut T)
|
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<TyParamBounds>, folder: &mut T)
|
||||||
-> Option<OwnedSlice<TyParamBound>> {
|
-> Option<TyParamBounds> {
|
||||||
b.map(|bounds| folder.fold_bounds(bounds))
|
b.map(|bounds| folder.fold_bounds(bounds))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,100 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::default::Default;
|
/// A non-growable owned slice.
|
||||||
use std::fmt;
|
#[unstable(feature = "rustc_private", issue = "0")]
|
||||||
use std::iter::{IntoIterator, FromIterator};
|
#[rustc_deprecated(since = "1.7.0", reason = "use `ptr::P<[T]>` instead")]
|
||||||
use std::ops::Deref;
|
pub type OwnedSlice<T> = ::ptr::P<[T]>;
|
||||||
use std::slice;
|
|
||||||
use std::vec;
|
|
||||||
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
|
||||||
|
|
||||||
/// A non-growable owned slice. This is a separate type to allow the
|
|
||||||
/// representation to change.
|
|
||||||
#[derive(Hash, PartialEq, Eq, PartialOrd, Ord)]
|
|
||||||
pub struct OwnedSlice<T> {
|
|
||||||
data: Box<[T]>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T:fmt::Debug> fmt::Debug for OwnedSlice<T> {
|
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
self.data.fmt(fmt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> OwnedSlice<T> {
|
|
||||||
pub fn empty() -> OwnedSlice<T> {
|
|
||||||
OwnedSlice { data: Box::new([]) }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(never)]
|
|
||||||
pub fn from_vec(v: Vec<T>) -> OwnedSlice<T> {
|
|
||||||
OwnedSlice { data: v.into_boxed_slice() }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(never)]
|
|
||||||
pub fn into_vec(self) -> Vec<T> {
|
|
||||||
self.data.into_vec()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_slice<'a>(&'a self) -> &'a [T] {
|
|
||||||
&*self.data
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn move_iter(self) -> vec::IntoIter<T> {
|
|
||||||
self.into_vec().into_iter()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn map<U, F: FnMut(&T) -> U>(&self, f: F) -> OwnedSlice<U> {
|
|
||||||
self.iter().map(f).collect()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Deref for OwnedSlice<T> {
|
|
||||||
type Target = [T];
|
|
||||||
|
|
||||||
fn deref(&self) -> &[T] {
|
|
||||||
self.as_slice()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Default for OwnedSlice<T> {
|
|
||||||
fn default() -> OwnedSlice<T> {
|
|
||||||
OwnedSlice::empty()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Clone> Clone for OwnedSlice<T> {
|
|
||||||
fn clone(&self) -> OwnedSlice<T> {
|
|
||||||
OwnedSlice::from_vec(self.to_vec())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> FromIterator<T> for OwnedSlice<T> {
|
|
||||||
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> OwnedSlice<T> {
|
|
||||||
OwnedSlice::from_vec(iter.into_iter().collect())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T> IntoIterator for &'a OwnedSlice<T> {
|
|
||||||
type Item = &'a T;
|
|
||||||
type IntoIter = slice::Iter<'a, T>;
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
|
||||||
self.data.into_iter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Encodable> Encodable for OwnedSlice<T> {
|
|
||||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
|
||||||
Encodable::encode(&**self, s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Decodable> Decodable for OwnedSlice<T> {
|
|
||||||
fn decode<D: Decoder>(d: &mut D) -> Result<OwnedSlice<T>, D::Error> {
|
|
||||||
Ok(OwnedSlice::from_vec(match Decodable::decode(d) {
|
|
||||||
Ok(t) => t,
|
|
||||||
Err(e) => return Err(e)
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -671,7 +671,6 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use codemap::{Span, BytePos, Pos, Spanned, NO_EXPANSION};
|
use codemap::{Span, BytePos, Pos, Spanned, NO_EXPANSION};
|
||||||
use owned_slice::OwnedSlice;
|
|
||||||
use ast::{self, TokenTree};
|
use ast::{self, TokenTree};
|
||||||
use abi;
|
use abi;
|
||||||
use attr::{first_attr_value_str_by_name, AttrMetaMethods};
|
use attr::{first_attr_value_str_by_name, AttrMetaMethods};
|
||||||
|
@ -947,7 +946,7 @@ mod tests {
|
||||||
abi::Rust,
|
abi::Rust,
|
||||||
ast::Generics{ // no idea on either of these:
|
ast::Generics{ // no idea on either of these:
|
||||||
lifetimes: Vec::new(),
|
lifetimes: Vec::new(),
|
||||||
ty_params: OwnedSlice::empty(),
|
ty_params: P::empty(),
|
||||||
where_clause: ast::WhereClause {
|
where_clause: ast::WhereClause {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
predicates: Vec::new(),
|
predicates: Vec::new(),
|
||||||
|
|
|
@ -50,7 +50,7 @@ use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue};
|
||||||
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
|
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
|
||||||
use ast::{Ty, Ty_, TypeBinding, TyMac};
|
use ast::{Ty, Ty_, TypeBinding, TyMac};
|
||||||
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
|
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
|
||||||
use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPtr};
|
use ast::{TyParam, TyParamBounds, TyParen, TyPath, TyPtr};
|
||||||
use ast::{TyRptr, TyTup, TyU32, TyVec};
|
use ast::{TyRptr, TyTup, TyU32, TyVec};
|
||||||
use ast::TypeTraitItem;
|
use ast::TypeTraitItem;
|
||||||
use ast::{UnnamedField, UnsafeBlock};
|
use ast::{UnnamedField, UnsafeBlock};
|
||||||
|
@ -73,7 +73,6 @@ use parse::{new_sub_parser_from_file, ParseSess};
|
||||||
use util::parser::{AssocOp, Fixity};
|
use util::parser::{AssocOp, Fixity};
|
||||||
use print::pprust;
|
use print::pprust;
|
||||||
use ptr::P;
|
use ptr::P;
|
||||||
use owned_slice::OwnedSlice;
|
|
||||||
use parse::PResult;
|
use parse::PResult;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
@ -751,7 +750,7 @@ impl<'a> Parser<'a> {
|
||||||
pub fn parse_seq_to_before_gt_or_return<T, F>(&mut self,
|
pub fn parse_seq_to_before_gt_or_return<T, F>(&mut self,
|
||||||
sep: Option<token::Token>,
|
sep: Option<token::Token>,
|
||||||
mut f: F)
|
mut f: F)
|
||||||
-> PResult<(OwnedSlice<T>, bool)> where
|
-> PResult<(P<[T]>, bool)> where
|
||||||
F: FnMut(&mut Parser) -> PResult<Option<T>>,
|
F: FnMut(&mut Parser) -> PResult<Option<T>>,
|
||||||
{
|
{
|
||||||
let mut v = Vec::new();
|
let mut v = Vec::new();
|
||||||
|
@ -772,7 +771,7 @@ impl<'a> Parser<'a> {
|
||||||
if i % 2 == 0 {
|
if i % 2 == 0 {
|
||||||
match try!(f(self)) {
|
match try!(f(self)) {
|
||||||
Some(result) => v.push(result),
|
Some(result) => v.push(result),
|
||||||
None => return Ok((OwnedSlice::from_vec(v), true))
|
None => return Ok((P::from_vec(v), true))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(t) = sep.as_ref() {
|
if let Some(t) = sep.as_ref() {
|
||||||
|
@ -781,7 +780,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok((OwnedSlice::from_vec(v), false));
|
return Ok((P::from_vec(v), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a sequence bracketed by '<' and '>', stopping
|
/// Parse a sequence bracketed by '<' and '>', stopping
|
||||||
|
@ -789,7 +788,7 @@ impl<'a> Parser<'a> {
|
||||||
pub fn parse_seq_to_before_gt<T, F>(&mut self,
|
pub fn parse_seq_to_before_gt<T, F>(&mut self,
|
||||||
sep: Option<token::Token>,
|
sep: Option<token::Token>,
|
||||||
mut f: F)
|
mut f: F)
|
||||||
-> PResult<OwnedSlice<T>> where
|
-> PResult<P<[T]>> where
|
||||||
F: FnMut(&mut Parser) -> PResult<T>,
|
F: FnMut(&mut Parser) -> PResult<T>,
|
||||||
{
|
{
|
||||||
let (result, returned) = try!(self.parse_seq_to_before_gt_or_return(sep,
|
let (result, returned) = try!(self.parse_seq_to_before_gt_or_return(sep,
|
||||||
|
@ -801,7 +800,7 @@ impl<'a> Parser<'a> {
|
||||||
pub fn parse_seq_to_gt<T, F>(&mut self,
|
pub fn parse_seq_to_gt<T, F>(&mut self,
|
||||||
sep: Option<token::Token>,
|
sep: Option<token::Token>,
|
||||||
f: F)
|
f: F)
|
||||||
-> PResult<OwnedSlice<T>> where
|
-> PResult<P<[T]>> where
|
||||||
F: FnMut(&mut Parser) -> PResult<T>,
|
F: FnMut(&mut Parser) -> PResult<T>,
|
||||||
{
|
{
|
||||||
let v = try!(self.parse_seq_to_before_gt(sep, f));
|
let v = try!(self.parse_seq_to_before_gt(sep, f));
|
||||||
|
@ -812,7 +811,7 @@ impl<'a> Parser<'a> {
|
||||||
pub fn parse_seq_to_gt_or_return<T, F>(&mut self,
|
pub fn parse_seq_to_gt_or_return<T, F>(&mut self,
|
||||||
sep: Option<token::Token>,
|
sep: Option<token::Token>,
|
||||||
f: F)
|
f: F)
|
||||||
-> PResult<(OwnedSlice<T>, bool)> where
|
-> PResult<(P<[T]>, bool)> where
|
||||||
F: FnMut(&mut Parser) -> PResult<Option<T>>,
|
F: FnMut(&mut Parser) -> PResult<Option<T>>,
|
||||||
{
|
{
|
||||||
let (v, returned) = try!(self.parse_seq_to_before_gt_or_return(sep, f));
|
let (v, returned) = try!(self.parse_seq_to_before_gt_or_return(sep, f));
|
||||||
|
@ -1076,7 +1075,7 @@ impl<'a> Parser<'a> {
|
||||||
let other_bounds = if try!(self.eat(&token::BinOp(token::Plus)) ){
|
let other_bounds = if try!(self.eat(&token::BinOp(token::Plus)) ){
|
||||||
try!(self.parse_ty_param_bounds(BoundParsingMode::Bare))
|
try!(self.parse_ty_param_bounds(BoundParsingMode::Bare))
|
||||||
} else {
|
} else {
|
||||||
OwnedSlice::empty()
|
P::empty()
|
||||||
};
|
};
|
||||||
let all_bounds =
|
let all_bounds =
|
||||||
Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter()
|
Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter()
|
||||||
|
@ -1709,8 +1708,8 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
||||||
lifetimes: lifetimes,
|
lifetimes: lifetimes,
|
||||||
types: OwnedSlice::from_vec(types),
|
types: P::from_vec(types),
|
||||||
bindings: OwnedSlice::from_vec(bindings),
|
bindings: P::from_vec(bindings),
|
||||||
})
|
})
|
||||||
} else if try!(self.eat(&token::OpenDelim(token::Paren)) ){
|
} else if try!(self.eat(&token::OpenDelim(token::Paren)) ){
|
||||||
let lo = self.last_span.lo;
|
let lo = self.last_span.lo;
|
||||||
|
@ -1773,8 +1772,8 @@ impl<'a> Parser<'a> {
|
||||||
identifier: identifier,
|
identifier: identifier,
|
||||||
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
||||||
lifetimes: lifetimes,
|
lifetimes: lifetimes,
|
||||||
types: OwnedSlice::from_vec(types),
|
types: P::from_vec(types),
|
||||||
bindings: OwnedSlice::from_vec(bindings),
|
bindings: P::from_vec(bindings),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3882,10 +3881,10 @@ impl<'a> Parser<'a> {
|
||||||
// otherwise returns empty list.
|
// otherwise returns empty list.
|
||||||
fn parse_colon_then_ty_param_bounds(&mut self,
|
fn parse_colon_then_ty_param_bounds(&mut self,
|
||||||
mode: BoundParsingMode)
|
mode: BoundParsingMode)
|
||||||
-> PResult<OwnedSlice<TyParamBound>>
|
-> PResult<TyParamBounds>
|
||||||
{
|
{
|
||||||
if !try!(self.eat(&token::Colon) ){
|
if !try!(self.eat(&token::Colon) ){
|
||||||
Ok(OwnedSlice::empty())
|
Ok(P::empty())
|
||||||
} else {
|
} else {
|
||||||
self.parse_ty_param_bounds(mode)
|
self.parse_ty_param_bounds(mode)
|
||||||
}
|
}
|
||||||
|
@ -3897,7 +3896,7 @@ impl<'a> Parser<'a> {
|
||||||
// and bound = 'region | trait_ref
|
// and bound = 'region | trait_ref
|
||||||
fn parse_ty_param_bounds(&mut self,
|
fn parse_ty_param_bounds(&mut self,
|
||||||
mode: BoundParsingMode)
|
mode: BoundParsingMode)
|
||||||
-> PResult<OwnedSlice<TyParamBound>>
|
-> PResult<TyParamBounds>
|
||||||
{
|
{
|
||||||
let mut result = vec!();
|
let mut result = vec!();
|
||||||
loop {
|
loop {
|
||||||
|
@ -3939,7 +3938,7 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(OwnedSlice::from_vec(result));
|
return Ok(P::from_vec(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Matches typaram = IDENT (`?` unbound)? optbounds ( EQ ty )?
|
/// Matches typaram = IDENT (`?` unbound)? optbounds ( EQ ty )?
|
||||||
|
|
|
@ -17,7 +17,6 @@ use ast::Attribute;
|
||||||
use attr::ThinAttributesExt;
|
use attr::ThinAttributesExt;
|
||||||
use util::parser::AssocOp;
|
use util::parser::AssocOp;
|
||||||
use attr;
|
use attr;
|
||||||
use owned_slice::OwnedSlice;
|
|
||||||
use attr::{AttrMetaMethods, AttributeMethods};
|
use attr::{AttrMetaMethods, AttributeMethods};
|
||||||
use codemap::{self, CodeMap, BytePos};
|
use codemap::{self, CodeMap, BytePos};
|
||||||
use errors;
|
use errors;
|
||||||
|
@ -1001,7 +1000,7 @@ impl<'a> State<'a> {
|
||||||
ast::TyBareFn(ref f) => {
|
ast::TyBareFn(ref f) => {
|
||||||
let generics = ast::Generics {
|
let generics = ast::Generics {
|
||||||
lifetimes: f.lifetimes.clone(),
|
lifetimes: f.lifetimes.clone(),
|
||||||
ty_params: OwnedSlice::empty(),
|
ty_params: P::empty(),
|
||||||
where_clause: ast::WhereClause {
|
where_clause: ast::WhereClause {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
predicates: Vec::new(),
|
predicates: Vec::new(),
|
||||||
|
@ -3024,7 +3023,7 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
let generics = ast::Generics {
|
let generics = ast::Generics {
|
||||||
lifetimes: Vec::new(),
|
lifetimes: Vec::new(),
|
||||||
ty_params: OwnedSlice::empty(),
|
ty_params: P::empty(),
|
||||||
where_clause: ast::WhereClause {
|
where_clause: ast::WhereClause {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
predicates: Vec::new(),
|
predicates: Vec::new(),
|
||||||
|
|
|
@ -37,14 +37,15 @@
|
||||||
//! Moreover, a switch to, e.g. `P<'a, T>` would be easy and mostly automated.
|
//! Moreover, a switch to, e.g. `P<'a, T>` would be easy and mostly automated.
|
||||||
|
|
||||||
use std::fmt::{self, Display, Debug};
|
use std::fmt::{self, Display, Debug};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::iter::FromIterator;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ptr;
|
use std::{ptr, slice, vec};
|
||||||
|
|
||||||
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||||
|
|
||||||
/// An owned smart pointer.
|
/// An owned smart pointer.
|
||||||
pub struct P<T> {
|
#[derive(Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
pub struct P<T: ?Sized> {
|
||||||
ptr: Box<T>
|
ptr: Box<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,14 +93,6 @@ impl<T: 'static + Clone> Clone for P<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: PartialEq> PartialEq for P<T> {
|
|
||||||
fn eq(&self, other: &P<T>) -> bool {
|
|
||||||
**self == **other
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Eq> Eq for P<T> {}
|
|
||||||
|
|
||||||
impl<T: Debug> Debug for P<T> {
|
impl<T: Debug> Debug for P<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
Debug::fmt(&**self, f)
|
Debug::fmt(&**self, f)
|
||||||
|
@ -111,19 +104,12 @@ impl<T: Display> Display for P<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
|
||||||
impl<T> fmt::Pointer for P<T> {
|
impl<T> fmt::Pointer for P<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
fmt::Pointer::fmt(&self.ptr, f)
|
fmt::Pointer::fmt(&self.ptr, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Hash> Hash for P<T> {
|
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
|
||||||
(**self).hash(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: 'static + Decodable> Decodable for P<T> {
|
impl<T: 'static + Decodable> Decodable for P<T> {
|
||||||
fn decode<D: Decoder>(d: &mut D) -> Result<P<T>, D::Error> {
|
fn decode<D: Decoder>(d: &mut D) -> Result<P<T>, D::Error> {
|
||||||
Decodable::decode(d).map(P)
|
Decodable::decode(d).map(P)
|
||||||
|
@ -135,3 +121,87 @@ impl<T: Encodable> Encodable for P<T> {
|
||||||
(**self).encode(s)
|
(**self).encode(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl<T:fmt::Debug> fmt::Debug for P<[T]> {
|
||||||
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
self.ptr.fmt(fmt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> P<[T]> {
|
||||||
|
pub fn empty() -> P<[T]> {
|
||||||
|
P { ptr: Default::default() }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
|
pub fn from_vec(v: Vec<T>) -> P<[T]> {
|
||||||
|
P { ptr: v.into_boxed_slice() }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
|
pub fn into_vec(self) -> Vec<T> {
|
||||||
|
self.ptr.into_vec()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_slice<'a>(&'a self) -> &'a [T] {
|
||||||
|
&*self.ptr
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn move_iter(self) -> vec::IntoIter<T> {
|
||||||
|
self.into_vec().into_iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn map<U, F: FnMut(&T) -> U>(&self, f: F) -> P<[U]> {
|
||||||
|
self.iter().map(f).collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Deref for P<[T]> {
|
||||||
|
type Target = [T];
|
||||||
|
|
||||||
|
fn deref(&self) -> &[T] {
|
||||||
|
self.as_slice()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Default for P<[T]> {
|
||||||
|
fn default() -> P<[T]> {
|
||||||
|
P::empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Clone> Clone for P<[T]> {
|
||||||
|
fn clone(&self) -> P<[T]> {
|
||||||
|
P::from_vec(self.to_vec())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> FromIterator<T> for P<[T]> {
|
||||||
|
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> P<[T]> {
|
||||||
|
P::from_vec(iter.into_iter().collect())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T> IntoIterator for &'a P<[T]> {
|
||||||
|
type Item = &'a T;
|
||||||
|
type IntoIter = slice::Iter<'a, T>;
|
||||||
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
self.ptr.into_iter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Encodable> Encodable for P<[T]> {
|
||||||
|
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
|
Encodable::encode(&**self, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Decodable> Decodable for P<[T]> {
|
||||||
|
fn decode<D: Decoder>(d: &mut D) -> Result<P<[T]>, D::Error> {
|
||||||
|
Ok(P::from_vec(match Decodable::decode(d) {
|
||||||
|
Ok(t) => t,
|
||||||
|
Err(e) => return Err(e)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ use ext::expand::ExpansionConfig;
|
||||||
use fold::Folder;
|
use fold::Folder;
|
||||||
use util::move_map::MoveMap;
|
use util::move_map::MoveMap;
|
||||||
use fold;
|
use fold;
|
||||||
use owned_slice::OwnedSlice;
|
|
||||||
use parse::token::{intern, InternedString};
|
use parse::token::{intern, InternedString};
|
||||||
use parse::{token, ParseSess};
|
use parse::{token, ParseSess};
|
||||||
use print::pprust;
|
use print::pprust;
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use owned_slice::OwnedSlice;
|
|
||||||
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
pub trait MoveMap<T>: Sized {
|
pub trait MoveMap<T>: Sized {
|
||||||
|
@ -69,11 +67,11 @@ impl<T> MoveMap<T> for Vec<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> MoveMap<T> for OwnedSlice<T> {
|
impl<T> MoveMap<T> for ::ptr::P<[T]> {
|
||||||
fn move_flat_map<F, I>(self, f: F) -> Self
|
fn move_flat_map<F, I>(self, f: F) -> Self
|
||||||
where F: FnMut(T) -> I,
|
where F: FnMut(T) -> I,
|
||||||
I: IntoIterator<Item=T>
|
I: IntoIterator<Item=T>
|
||||||
{
|
{
|
||||||
OwnedSlice::from_vec(self.into_vec().move_flat_map(f))
|
::ptr::P::from_vec(self.into_vec().move_flat_map(f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,6 @@ use syntax::codemap::{self, DUMMY_SP};
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::errors::Handler;
|
use syntax::errors::Handler;
|
||||||
use syntax::util::move_map::MoveMap;
|
use syntax::util::move_map::MoveMap;
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
use syntax::parse::token::{intern, InternedString};
|
use syntax::parse::token::{intern, InternedString};
|
||||||
use syntax::parse::token::special_idents;
|
use syntax::parse::token::special_idents;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
|
@ -516,7 +515,7 @@ impl<'a> TraitDef<'a> {
|
||||||
|
|
||||||
cx.typaram(self.span,
|
cx.typaram(self.span,
|
||||||
ty_param.ident,
|
ty_param.ident,
|
||||||
OwnedSlice::from_vec(bounds),
|
P::from_vec(bounds),
|
||||||
None)
|
None)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -528,7 +527,7 @@ impl<'a> TraitDef<'a> {
|
||||||
span: self.span,
|
span: self.span,
|
||||||
bound_lifetimes: wb.bound_lifetimes.clone(),
|
bound_lifetimes: wb.bound_lifetimes.clone(),
|
||||||
bounded_ty: wb.bounded_ty.clone(),
|
bounded_ty: wb.bounded_ty.clone(),
|
||||||
bounds: OwnedSlice::from_vec(wb.bounds.iter().cloned().collect())
|
bounds: P::from_vec(wb.bounds.iter().cloned().collect())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ast::WherePredicate::RegionPredicate(ref rb) => {
|
ast::WherePredicate::RegionPredicate(ref rb) => {
|
||||||
|
@ -579,7 +578,7 @@ impl<'a> TraitDef<'a> {
|
||||||
span: self.span,
|
span: self.span,
|
||||||
bound_lifetimes: vec![],
|
bound_lifetimes: vec![],
|
||||||
bounded_ty: ty,
|
bounded_ty: ty,
|
||||||
bounds: OwnedSlice::from_vec(bounds),
|
bounds: P::from_vec(bounds),
|
||||||
};
|
};
|
||||||
|
|
||||||
let predicate = ast::WherePredicate::BoundPredicate(predicate);
|
let predicate = ast::WherePredicate::BoundPredicate(predicate);
|
||||||
|
@ -590,7 +589,7 @@ impl<'a> TraitDef<'a> {
|
||||||
|
|
||||||
let trait_generics = Generics {
|
let trait_generics = Generics {
|
||||||
lifetimes: lifetimes,
|
lifetimes: lifetimes,
|
||||||
ty_params: OwnedSlice::from_vec(ty_params),
|
ty_params: P::from_vec(ty_params),
|
||||||
where_clause: where_clause
|
where_clause: where_clause
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ use syntax::ast::{Expr,Generics,Ident};
|
||||||
use syntax::ext::base::ExtCtxt;
|
use syntax::ext::base::ExtCtxt;
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
use syntax::codemap::{Span,respan};
|
use syntax::codemap::{Span,respan};
|
||||||
use syntax::owned_slice::OwnedSlice;
|
|
||||||
use syntax::parse::token::special_idents;
|
use syntax::parse::token::special_idents;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
|
|
||||||
|
@ -209,7 +208,7 @@ fn mk_generics(lifetimes: Vec<ast::LifetimeDef>, ty_params: Vec<ast::TyParam>)
|
||||||
-> Generics {
|
-> Generics {
|
||||||
Generics {
|
Generics {
|
||||||
lifetimes: lifetimes,
|
lifetimes: lifetimes,
|
||||||
ty_params: OwnedSlice::from_vec(ty_params),
|
ty_params: P::from_vec(ty_params),
|
||||||
where_clause: ast::WhereClause {
|
where_clause: ast::WhereClause {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
predicates: Vec::new(),
|
predicates: Vec::new(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue