Rename ast::GenericParam and ast::GenericArg
It's so confusing to have everything having the same name, at least while refactoring.
This commit is contained in:
parent
f9d0968906
commit
d643946550
@ -810,7 +810,7 @@ impl<'a> LoweringContext<'a> {
|
||||
{
|
||||
let (in_band_defs, (mut lowered_generics, res)) = self.with_in_scope_lifetime_defs(
|
||||
generics.params.iter().filter_map(|p| match p {
|
||||
GenericParam::Lifetime(ld) => Some(ld),
|
||||
GenericParamAST::Lifetime(ld) => Some(ld),
|
||||
_ => None,
|
||||
}),
|
||||
|this| {
|
||||
@ -1040,14 +1040,14 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn lower_generic_arg(&mut self,
|
||||
p: &ast::GenericArg,
|
||||
p: &ast::GenericArgAST,
|
||||
itctx: ImplTraitContext)
|
||||
-> hir::GenericArg {
|
||||
match p {
|
||||
ast::GenericArg::Lifetime(lt) => {
|
||||
ast::GenericArgAST::Lifetime(lt) => {
|
||||
GenericArg::Lifetime(self.lower_lifetime(<))
|
||||
}
|
||||
ast::GenericArg::Type(ty) => {
|
||||
ast::GenericArgAST::Type(ty) => {
|
||||
GenericArg::Type(self.lower_ty(&ty, itctx))
|
||||
}
|
||||
}
|
||||
@ -1069,7 +1069,7 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
TyKind::BareFn(ref f) => self.with_in_scope_lifetime_defs(
|
||||
f.generic_params.iter().filter_map(|p| match p {
|
||||
GenericParam::Lifetime(ld) => Some(ld),
|
||||
GenericParamAST::Lifetime(ld) => Some(ld),
|
||||
_ => None,
|
||||
}),
|
||||
|this| {
|
||||
@ -1980,17 +1980,17 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
fn lower_generic_params(
|
||||
&mut self,
|
||||
params: &Vec<GenericParam>,
|
||||
params: &Vec<GenericParamAST>,
|
||||
add_bounds: &NodeMap<Vec<TyParamBound>>,
|
||||
itctx: ImplTraitContext,
|
||||
) -> hir::HirVec<hir::GenericParam> {
|
||||
params
|
||||
.iter()
|
||||
.map(|param| match *param {
|
||||
GenericParam::Lifetime(ref lifetime_def) => {
|
||||
GenericParamAST::Lifetime(ref lifetime_def) => {
|
||||
hir::GenericParam::Lifetime(self.lower_lifetime_def(lifetime_def))
|
||||
}
|
||||
GenericParam::Type(ref ty_param) => hir::GenericParam::Type(self.lower_ty_param(
|
||||
GenericParamAST::Type(ref ty_param) => hir::GenericParam::Type(self.lower_ty_param(
|
||||
ty_param,
|
||||
add_bounds.get(&ty_param.id).map_or(&[][..], |x| &x),
|
||||
itctx,
|
||||
@ -2030,7 +2030,7 @@ impl<'a> LoweringContext<'a> {
|
||||
self.resolver.definitions().as_local_node_id(def_id)
|
||||
{
|
||||
for param in &g.params {
|
||||
if let GenericParam::Type(ref ty_param) = *param {
|
||||
if let GenericParamAST::Type(ref ty_param) = *param {
|
||||
if node_id == ty_param.id {
|
||||
add_bounds
|
||||
.entry(ty_param.id)
|
||||
@ -2078,7 +2078,7 @@ impl<'a> LoweringContext<'a> {
|
||||
}) => {
|
||||
self.with_in_scope_lifetime_defs(
|
||||
bound_generic_params.iter().filter_map(|p| match p {
|
||||
GenericParam::Lifetime(ld) => Some(ld),
|
||||
GenericParamAST::Lifetime(ld) => Some(ld),
|
||||
_ => None,
|
||||
}),
|
||||
|this| {
|
||||
@ -2397,7 +2397,7 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
let new_impl_items = self.with_in_scope_lifetime_defs(
|
||||
ast_generics.params.iter().filter_map(|p| match p {
|
||||
GenericParam::Lifetime(ld) => Some(ld),
|
||||
GenericParamAST::Lifetime(ld) => Some(ld),
|
||||
_ => None,
|
||||
}),
|
||||
|this| {
|
||||
|
@ -170,9 +170,9 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_generic_param(&mut self, param: &'a GenericParam) {
|
||||
fn visit_generic_param(&mut self, param: &'a GenericParamAST) {
|
||||
match *param {
|
||||
GenericParam::Lifetime(ref lifetime_def) => {
|
||||
GenericParamAST::Lifetime(ref lifetime_def) => {
|
||||
self.create_def(
|
||||
lifetime_def.lifetime.id,
|
||||
DefPathData::LifetimeDef(lifetime_def.lifetime.ident.name.as_interned_str()),
|
||||
@ -180,7 +180,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
||||
lifetime_def.lifetime.ident.span
|
||||
);
|
||||
}
|
||||
GenericParam::Type(ref ty_param) => {
|
||||
GenericParamAST::Type(ref ty_param) => {
|
||||
self.create_def(
|
||||
ty_param.id,
|
||||
DefPathData::TypeParam(ty_param.ident.name.as_interned_str()),
|
||||
|
@ -990,7 +990,7 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
|
||||
run_lints!(self, check_expr_post, early_passes, e);
|
||||
}
|
||||
|
||||
fn visit_generic_param(&mut self, param: &'a ast::GenericParam) {
|
||||
fn visit_generic_param(&mut self, param: &'a ast::GenericParamAST) {
|
||||
run_lints!(self, check_generic_param, early_passes, param);
|
||||
ast_visit::walk_generic_param(self, param);
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ pub trait EarlyLintPass: LintPass {
|
||||
fn check_expr(&mut self, _: &EarlyContext, _: &ast::Expr) { }
|
||||
fn check_expr_post(&mut self, _: &EarlyContext, _: &ast::Expr) { }
|
||||
fn check_ty(&mut self, _: &EarlyContext, _: &ast::Ty) { }
|
||||
fn check_generic_param(&mut self, _: &EarlyContext, _: &ast::GenericParam) { }
|
||||
fn check_generic_param(&mut self, _: &EarlyContext, _: &ast::GenericParamAST) { }
|
||||
fn check_generics(&mut self, _: &EarlyContext, _: &ast::Generics) { }
|
||||
fn check_where_predicate(&mut self, _: &EarlyContext, _: &ast::WherePredicate) { }
|
||||
fn check_poly_trait_ref(&mut self, _: &EarlyContext, _: &ast::PolyTraitRef,
|
||||
|
@ -138,12 +138,12 @@ impl<'a> AstValidator<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_late_bound_lifetime_defs(&self, params: &Vec<GenericParam>) {
|
||||
fn check_late_bound_lifetime_defs(&self, params: &Vec<GenericParamAST>) {
|
||||
// Check: Only lifetime parameters
|
||||
let non_lifetime_param_spans : Vec<_> = params.iter()
|
||||
.filter_map(|param| match *param {
|
||||
GenericParam::Lifetime(_) => None,
|
||||
GenericParam::Type(ref t) => Some(t.ident.span),
|
||||
GenericParamAST::Lifetime(_) => None,
|
||||
GenericParamAST::Type(ref t) => Some(t.ident.span),
|
||||
}).collect();
|
||||
if !non_lifetime_param_spans.is_empty() {
|
||||
self.err_handler().span_err(non_lifetime_param_spans,
|
||||
@ -153,14 +153,14 @@ impl<'a> AstValidator<'a> {
|
||||
// Check: No bounds on lifetime parameters
|
||||
for param in params.iter() {
|
||||
match *param {
|
||||
GenericParam::Lifetime(ref l) => {
|
||||
GenericParamAST::Lifetime(ref l) => {
|
||||
if !l.bounds.is_empty() {
|
||||
let spans: Vec<_> = l.bounds.iter().map(|b| b.ident.span).collect();
|
||||
self.err_handler().span_err(spans,
|
||||
"lifetime bounds cannot be used in this context");
|
||||
}
|
||||
}
|
||||
GenericParam::Type(_) => {}
|
||||
GenericParamAST::Type(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -335,7 +335,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
}
|
||||
ItemKind::TraitAlias(Generics { ref params, .. }, ..) => {
|
||||
for param in params {
|
||||
if let GenericParam::Type(TyParam {
|
||||
if let GenericParamAST::Type(TyParam {
|
||||
ident,
|
||||
ref bounds,
|
||||
ref default,
|
||||
@ -414,17 +414,17 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
let mut seen_default = None;
|
||||
for param in &g.params {
|
||||
match (param, seen_non_lifetime_param) {
|
||||
(&GenericParam::Lifetime(ref ld), true) => {
|
||||
(&GenericParamAST::Lifetime(ref ld), true) => {
|
||||
self.err_handler()
|
||||
.span_err(ld.lifetime.ident.span, "lifetime parameters must be leading");
|
||||
},
|
||||
(&GenericParam::Lifetime(_), false) => {}
|
||||
(&GenericParamAST::Lifetime(_), false) => {}
|
||||
_ => {
|
||||
seen_non_lifetime_param = true;
|
||||
}
|
||||
}
|
||||
|
||||
if let GenericParam::Type(ref ty_param @ TyParam { default: Some(_), .. }) = *param {
|
||||
if let GenericParamAST::Type(ref ty_param @ TyParam { default: Some(_), .. }) = *param {
|
||||
seen_default = Some(ty_param.ident.span);
|
||||
} else if let Some(span) = seen_default {
|
||||
self.err_handler()
|
||||
|
@ -56,7 +56,7 @@ use syntax::util::lev_distance::find_best_match_for_name;
|
||||
use syntax::visit::{self, FnKind, Visitor};
|
||||
use syntax::attr;
|
||||
use syntax::ast::{Arm, BindingMode, Block, Crate, Expr, ExprKind};
|
||||
use syntax::ast::{FnDecl, ForeignItem, ForeignItemKind, GenericParam, Generics};
|
||||
use syntax::ast::{FnDecl, ForeignItem, ForeignItemKind, GenericParamAST, Generics};
|
||||
use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind};
|
||||
use syntax::ast::{Label, Local, Mutability, Pat, PatKind, Path};
|
||||
use syntax::ast::{QSelf, TraitItemKind, TraitRef, Ty, TyKind};
|
||||
@ -798,14 +798,14 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> {
|
||||
// them one by one as they are processed and become available.
|
||||
let mut default_ban_rib = Rib::new(ForwardTyParamBanRibKind);
|
||||
default_ban_rib.bindings.extend(generics.params.iter()
|
||||
.filter_map(|p| if let GenericParam::Type(ref tp) = *p { Some(tp) } else { None })
|
||||
.filter_map(|p| if let GenericParamAST::Type(ref tp) = *p { Some(tp) } else { None })
|
||||
.skip_while(|p| p.default.is_none())
|
||||
.map(|p| (Ident::with_empty_ctxt(p.ident.name), Def::Err)));
|
||||
|
||||
for param in &generics.params {
|
||||
match *param {
|
||||
GenericParam::Lifetime(_) => self.visit_generic_param(param),
|
||||
GenericParam::Type(ref ty_param) => {
|
||||
GenericParamAST::Lifetime(_) => self.visit_generic_param(param),
|
||||
GenericParamAST::Type(ref ty_param) => {
|
||||
for bound in &ty_param.bounds {
|
||||
self.visit_ty_param_bound(bound);
|
||||
}
|
||||
@ -2198,7 +2198,7 @@ impl<'a> Resolver<'a> {
|
||||
let mut function_type_rib = Rib::new(rib_kind);
|
||||
let mut seen_bindings = FxHashMap();
|
||||
for param in &generics.params {
|
||||
if let GenericParam::Type(ref type_parameter) = *param {
|
||||
if let GenericParamAST::Type(ref type_parameter) = *param {
|
||||
let ident = type_parameter.ident.modern();
|
||||
debug!("with_type_parameter_rib: {}", type_parameter.id);
|
||||
|
||||
|
@ -370,7 +370,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
||||
id: NodeId,
|
||||
) {
|
||||
for param in &generics.params {
|
||||
if let ast::GenericParam::Type(ref ty_param) = *param {
|
||||
if let ast::GenericParamAST::Type(ref ty_param) = *param {
|
||||
let param_ss = ty_param.ident.span;
|
||||
let name = escape(self.span.snippet(param_ss));
|
||||
// Append $id to name to make sure each one is unique
|
||||
@ -1479,7 +1479,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
|
||||
|
||||
fn visit_generics(&mut self, generics: &'l ast::Generics) {
|
||||
for param in &generics.params {
|
||||
if let ast::GenericParam::Type(ref ty_param) = *param {
|
||||
if let ast::GenericParamAST::Type(ref ty_param) = *param {
|
||||
for bound in ty_param.bounds.iter() {
|
||||
if let ast::TraitTyParamBound(ref trait_ref, _) = *bound {
|
||||
self.process_path(trait_ref.trait_ref.ref_id, &trait_ref.trait_ref.path)
|
||||
|
@ -935,8 +935,8 @@ fn make_signature(decl: &ast::FnDecl, generics: &ast::Generics) -> String {
|
||||
.params
|
||||
.iter()
|
||||
.map(|param| match *param {
|
||||
ast::GenericParam::Lifetime(ref l) => l.lifetime.ident.name.to_string(),
|
||||
ast::GenericParam::Type(ref t) => t.ident.to_string(),
|
||||
ast::GenericParamAST::Lifetime(ref l) => l.lifetime.ident.name.to_string(),
|
||||
ast::GenericParamAST::Type(ref t) => t.ident.to_string(),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(", "));
|
||||
|
@ -224,7 +224,7 @@ impl Sig for ast::Ty {
|
||||
text.push_str(&f.generic_params
|
||||
.iter()
|
||||
.filter_map(|p| match *p {
|
||||
ast::GenericParam::Lifetime(ref l) => {
|
||||
ast::GenericParamAST::Lifetime(ref l) => {
|
||||
Some(l.lifetime.ident.to_string())
|
||||
}
|
||||
_ => None,
|
||||
@ -618,7 +618,7 @@ impl Sig for ast::Generics {
|
||||
let mut defs = vec![];
|
||||
for param in &self.params {
|
||||
match *param {
|
||||
ast::GenericParam::Lifetime(ref l) => {
|
||||
ast::GenericParamAST::Lifetime(ref l) => {
|
||||
let mut l_text = l.lifetime.ident.to_string();
|
||||
defs.push(SigElement {
|
||||
id: id_from_node_id(l.lifetime.id, scx),
|
||||
@ -639,7 +639,7 @@ impl Sig for ast::Generics {
|
||||
text.push_str(&l_text);
|
||||
text.push(',');
|
||||
}
|
||||
ast::GenericParam::Type(ref t) => {
|
||||
ast::GenericParamAST::Type(ref t) => {
|
||||
let mut t_text = t.ident.to_string();
|
||||
defs.push(SigElement {
|
||||
id: id_from_node_id(t.id, scx),
|
||||
|
@ -168,7 +168,7 @@ impl GenericArgs {
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub enum GenericArg {
|
||||
pub enum GenericArgAST {
|
||||
Lifetime(Lifetime),
|
||||
Type(P<Ty>),
|
||||
}
|
||||
@ -179,7 +179,7 @@ pub struct AngleBracketedArgs {
|
||||
/// Overall span
|
||||
pub span: Span,
|
||||
/// The arguments for this path segment.
|
||||
pub args: Vec<GenericArg>,
|
||||
pub args: Vec<GenericArgAST>,
|
||||
/// Bindings (equality constraints) on associated types, if present.
|
||||
///
|
||||
/// E.g., `Foo<A=Bar>`.
|
||||
@ -189,7 +189,7 @@ pub struct AngleBracketedArgs {
|
||||
impl AngleBracketedArgs {
|
||||
pub fn lifetimes(&self) -> impl DoubleEndedIterator<Item = &Lifetime> {
|
||||
self.args.iter().filter_map(|arg| {
|
||||
if let GenericArg::Lifetime(lt) = arg {
|
||||
if let GenericArgAST::Lifetime(lt) = arg {
|
||||
Some(lt)
|
||||
} else {
|
||||
None
|
||||
@ -199,7 +199,7 @@ impl AngleBracketedArgs {
|
||||
|
||||
pub fn types(&self) -> impl DoubleEndedIterator<Item = &P<Ty>> {
|
||||
self.args.iter().filter_map(|arg| {
|
||||
if let GenericArg::Type(ty) = arg {
|
||||
if let GenericArgAST::Type(ty) = arg {
|
||||
Some(ty)
|
||||
} else {
|
||||
None
|
||||
@ -338,22 +338,22 @@ pub struct TyParam {
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub enum GenericParam {
|
||||
pub enum GenericParamAST {
|
||||
Lifetime(LifetimeDef),
|
||||
Type(TyParam),
|
||||
}
|
||||
|
||||
impl GenericParam {
|
||||
impl GenericParamAST {
|
||||
pub fn is_lifetime_param(&self) -> bool {
|
||||
match *self {
|
||||
GenericParam::Lifetime(_) => true,
|
||||
GenericParamAST::Lifetime(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_type_param(&self) -> bool {
|
||||
match *self {
|
||||
GenericParam::Type(_) => true,
|
||||
GenericParamAST::Type(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -363,7 +363,7 @@ impl GenericParam {
|
||||
/// a function, enum, trait, etc.
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct Generics {
|
||||
pub params: Vec<GenericParam>,
|
||||
pub params: Vec<GenericParamAST>,
|
||||
pub where_clause: WhereClause,
|
||||
pub span: Span,
|
||||
}
|
||||
@ -383,7 +383,7 @@ impl Generics {
|
||||
|
||||
pub fn span_for_name(&self, name: &str) -> Option<Span> {
|
||||
for param in &self.params {
|
||||
if let GenericParam::Type(ref t) = *param {
|
||||
if let GenericParamAST::Type(ref t) = *param {
|
||||
if t.ident.name == name {
|
||||
return Some(t.ident.span);
|
||||
}
|
||||
@ -444,7 +444,7 @@ impl WherePredicate {
|
||||
pub struct WhereBoundPredicate {
|
||||
pub span: Span,
|
||||
/// Any generics from a `for` binding
|
||||
pub bound_generic_params: Vec<GenericParam>,
|
||||
pub bound_generic_params: Vec<GenericParamAST>,
|
||||
/// The type being bounded
|
||||
pub bounded_ty: P<Ty>,
|
||||
/// Trait and lifetime bounds (`Clone+Send+'static`)
|
||||
@ -1576,7 +1576,7 @@ impl fmt::Debug for Ty {
|
||||
pub struct BareFnTy {
|
||||
pub unsafety: Unsafety,
|
||||
pub abi: Abi,
|
||||
pub generic_params: Vec<GenericParam>,
|
||||
pub generic_params: Vec<GenericParamAST>,
|
||||
pub decl: P<FnDecl>
|
||||
}
|
||||
|
||||
@ -1955,7 +1955,7 @@ pub struct TraitRef {
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct PolyTraitRef {
|
||||
/// The `'a` in `<'a> Foo<&'a T>`
|
||||
pub bound_generic_params: Vec<GenericParam>,
|
||||
pub bound_generic_params: Vec<GenericParamAST>,
|
||||
|
||||
/// The `Foo<&'a T>` in `<'a> Foo<&'a T>`
|
||||
pub trait_ref: TraitRef,
|
||||
@ -1964,7 +1964,7 @@ pub struct PolyTraitRef {
|
||||
}
|
||||
|
||||
impl PolyTraitRef {
|
||||
pub fn new(generic_params: Vec<GenericParam>, path: Path, span: Span) -> Self {
|
||||
pub fn new(generic_params: Vec<GenericParamAST>, path: Path, span: Span) -> Self {
|
||||
PolyTraitRef {
|
||||
bound_generic_params: generic_params,
|
||||
trait_ref: TraitRef { path: path, ref_id: DUMMY_NODE_ID },
|
||||
|
@ -31,7 +31,7 @@ pub trait AstBuilder {
|
||||
fn path_all(&self, sp: Span,
|
||||
global: bool,
|
||||
idents: Vec<ast::Ident>,
|
||||
args: Vec<ast::GenericArg>,
|
||||
args: Vec<ast::GenericArgAST>,
|
||||
bindings: Vec<ast::TypeBinding>)
|
||||
-> ast::Path;
|
||||
|
||||
@ -42,7 +42,7 @@ pub trait AstBuilder {
|
||||
fn qpath_all(&self, self_type: P<ast::Ty>,
|
||||
trait_path: ast::Path,
|
||||
ident: ast::Ident,
|
||||
args: Vec<ast::GenericArg>,
|
||||
args: Vec<ast::GenericArgAST>,
|
||||
bindings: Vec<ast::TypeBinding>)
|
||||
-> (ast::QSelf, ast::Path);
|
||||
|
||||
@ -314,7 +314,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
span: Span,
|
||||
global: bool,
|
||||
mut idents: Vec<ast::Ident> ,
|
||||
args: Vec<ast::GenericArg>,
|
||||
args: Vec<ast::GenericArgAST>,
|
||||
bindings: Vec<ast::TypeBinding> )
|
||||
-> ast::Path {
|
||||
let last_ident = idents.pop().unwrap();
|
||||
@ -356,7 +356,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
self_type: P<ast::Ty>,
|
||||
trait_path: ast::Path,
|
||||
ident: ast::Ident,
|
||||
args: Vec<ast::GenericArg>,
|
||||
args: Vec<ast::GenericArgAST>,
|
||||
bindings: Vec<ast::TypeBinding>)
|
||||
-> (ast::QSelf, ast::Path) {
|
||||
let mut path = trait_path;
|
||||
@ -424,7 +424,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
self.path_all(DUMMY_SP,
|
||||
true,
|
||||
self.std_path(&["option", "Option"]),
|
||||
vec![ast::GenericArg::Type(ty)],
|
||||
vec![ast::GenericArgAST::Type(ty)],
|
||||
Vec::new()))
|
||||
}
|
||||
|
||||
|
@ -132,10 +132,10 @@ pub trait Folder : Sized {
|
||||
noop_fold_exprs(es, self)
|
||||
}
|
||||
|
||||
fn fold_generic_arg(&mut self, arg: GenericArg) -> GenericArg {
|
||||
fn fold_generic_arg(&mut self, arg: GenericArgAST) -> GenericArgAST {
|
||||
match arg {
|
||||
GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.fold_lifetime(lt)),
|
||||
GenericArg::Type(ty) => GenericArg::Type(self.fold_ty(ty)),
|
||||
GenericArgAST::Lifetime(lt) => GenericArgAST::Lifetime(self.fold_lifetime(lt)),
|
||||
GenericArgAST::Type(ty) => GenericArgAST::Type(self.fold_ty(ty)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,11 +244,11 @@ pub trait Folder : Sized {
|
||||
noop_fold_ty_param(tp, self)
|
||||
}
|
||||
|
||||
fn fold_generic_param(&mut self, param: GenericParam) -> GenericParam {
|
||||
fn fold_generic_param(&mut self, param: GenericParamAST) -> GenericParamAST {
|
||||
noop_fold_generic_param(param, self)
|
||||
}
|
||||
|
||||
fn fold_generic_params(&mut self, params: Vec<GenericParam>) -> Vec<GenericParam> {
|
||||
fn fold_generic_params(&mut self, params: Vec<GenericParamAST>) -> Vec<GenericParamAST> {
|
||||
noop_fold_generic_params(params, self)
|
||||
}
|
||||
|
||||
@ -702,11 +702,11 @@ pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn noop_fold_generic_param<T: Folder>(param: GenericParam, fld: &mut T) -> GenericParam {
|
||||
pub fn noop_fold_generic_param<T: Folder>(param: GenericParamAST, fld: &mut T) -> GenericParamAST {
|
||||
match param {
|
||||
GenericParam::Lifetime(l) => {
|
||||
GenericParamAST::Lifetime(l) => {
|
||||
let attrs: Vec<_> = l.attrs.into();
|
||||
GenericParam::Lifetime(LifetimeDef {
|
||||
GenericParamAST::Lifetime(LifetimeDef {
|
||||
attrs: attrs.into_iter()
|
||||
.flat_map(|x| fld.fold_attribute(x).into_iter())
|
||||
.collect::<Vec<_>>()
|
||||
@ -718,14 +718,14 @@ pub fn noop_fold_generic_param<T: Folder>(param: GenericParam, fld: &mut T) -> G
|
||||
bounds: l.bounds.move_map(|l| noop_fold_lifetime(l, fld)),
|
||||
})
|
||||
}
|
||||
GenericParam::Type(t) => GenericParam::Type(fld.fold_ty_param(t)),
|
||||
GenericParamAST::Type(t) => GenericParamAST::Type(fld.fold_ty_param(t)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn noop_fold_generic_params<T: Folder>(
|
||||
params: Vec<GenericParam>,
|
||||
params: Vec<GenericParamAST>,
|
||||
fld: &mut T
|
||||
) -> Vec<GenericParam> {
|
||||
) -> Vec<GenericParamAST> {
|
||||
params.move_map(|p| fld.fold_generic_param(p))
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ use ast::EnumDef;
|
||||
use ast::{Expr, ExprKind, RangeLimits};
|
||||
use ast::{Field, FnDecl};
|
||||
use ast::{ForeignItem, ForeignItemKind, FunctionRetTy};
|
||||
use ast::GenericParam;
|
||||
use ast::GenericArg;
|
||||
use ast::GenericParamAST;
|
||||
use ast::GenericArgAST;
|
||||
use ast::{Ident, ImplItem, IsAuto, Item, ItemKind};
|
||||
use ast::{Label, Lifetime, LifetimeDef, Lit, LitKind};
|
||||
use ast::Local;
|
||||
@ -1246,8 +1246,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
/// parse a TyKind::BareFn type:
|
||||
fn parse_ty_bare_fn(&mut self, generic_params: Vec<GenericParam>)
|
||||
-> PResult<'a, TyKind> {
|
||||
fn parse_ty_bare_fn(&mut self, generic_params: Vec<GenericParamAST>) -> PResult<'a, TyKind> {
|
||||
/*
|
||||
|
||||
[unsafe] [extern "ABI"] fn (S) -> T
|
||||
@ -1566,7 +1565,7 @@ impl<'a> Parser<'a> {
|
||||
Ok(P(ty))
|
||||
}
|
||||
|
||||
fn parse_remaining_bounds(&mut self, generic_params: Vec<GenericParam>, path: ast::Path,
|
||||
fn parse_remaining_bounds(&mut self, generic_params: Vec<GenericParamAST>, path: ast::Path,
|
||||
lo: Span, parse_plus: bool) -> PResult<'a, TyKind> {
|
||||
let poly_trait_ref = PolyTraitRef::new(generic_params, path, lo.to(self.prev_span));
|
||||
let mut bounds = vec![TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)];
|
||||
@ -4864,7 +4863,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
/// Parses (possibly empty) list of lifetime and type parameters, possibly including
|
||||
/// trailing comma and erroneous trailing attributes.
|
||||
crate fn parse_generic_params(&mut self) -> PResult<'a, Vec<ast::GenericParam>> {
|
||||
crate fn parse_generic_params(&mut self) -> PResult<'a, Vec<ast::GenericParamAST>> {
|
||||
let mut params = Vec::new();
|
||||
let mut seen_ty_param = false;
|
||||
loop {
|
||||
@ -4877,7 +4876,7 @@ impl<'a> Parser<'a> {
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
params.push(ast::GenericParam::Lifetime(LifetimeDef {
|
||||
params.push(ast::GenericParamAST::Lifetime(LifetimeDef {
|
||||
attrs: attrs.into(),
|
||||
lifetime,
|
||||
bounds,
|
||||
@ -4888,7 +4887,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
} else if self.check_ident() {
|
||||
// Parse type parameter.
|
||||
params.push(ast::GenericParam::Type(self.parse_ty_param(attrs)?));
|
||||
params.push(ast::GenericParamAST::Type(self.parse_ty_param(attrs)?));
|
||||
seen_ty_param = true;
|
||||
} else {
|
||||
// Check for trailing attributes and stop parsing.
|
||||
@ -4938,7 +4937,7 @@ impl<'a> Parser<'a> {
|
||||
/// Parses (possibly empty) list of lifetime and type arguments and associated type bindings,
|
||||
/// possibly including trailing comma.
|
||||
fn parse_generic_args(&mut self)
|
||||
-> PResult<'a, (Vec<GenericArg>, Vec<TypeBinding>)> {
|
||||
-> PResult<'a, (Vec<GenericArgAST>, Vec<TypeBinding>)> {
|
||||
let mut args = Vec::new();
|
||||
let mut bindings = Vec::new();
|
||||
let mut seen_type = false;
|
||||
@ -4946,7 +4945,7 @@ impl<'a> Parser<'a> {
|
||||
loop {
|
||||
if self.check_lifetime() && self.look_ahead(1, |t| !t.is_like_plus()) {
|
||||
// Parse lifetime argument.
|
||||
args.push(GenericArg::Lifetime(self.expect_lifetime()));
|
||||
args.push(GenericArgAST::Lifetime(self.expect_lifetime()));
|
||||
if seen_type || seen_binding {
|
||||
self.span_err(self.prev_span,
|
||||
"lifetime parameters must be declared prior to type parameters");
|
||||
@ -4971,7 +4970,7 @@ impl<'a> Parser<'a> {
|
||||
self.span_err(ty_param.span,
|
||||
"type parameters must be declared prior to associated type bindings");
|
||||
}
|
||||
args.push(GenericArg::Type(ty_param));
|
||||
args.push(GenericArgAST::Type(ty_param));
|
||||
seen_type = true;
|
||||
} else {
|
||||
break
|
||||
@ -5693,7 +5692,7 @@ impl<'a> Parser<'a> {
|
||||
Ok((keywords::Invalid.ident(), item_kind, Some(attrs)))
|
||||
}
|
||||
|
||||
fn parse_late_bound_lifetime_defs(&mut self) -> PResult<'a, Vec<GenericParam>> {
|
||||
fn parse_late_bound_lifetime_defs(&mut self) -> PResult<'a, Vec<GenericParamAST>> {
|
||||
if self.eat_keyword(keywords::For) {
|
||||
self.expect_lt()?;
|
||||
let params = self.parse_generic_params()?;
|
||||
|
@ -13,7 +13,7 @@ pub use self::AnnNode::*;
|
||||
use rustc_target::spec::abi::{self, Abi};
|
||||
use ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax};
|
||||
use ast::{SelfKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
|
||||
use ast::{Attribute, MacDelimiter, GenericArg};
|
||||
use ast::{Attribute, MacDelimiter, GenericArgAST};
|
||||
use util::parser::{self, AssocOp, Fixity};
|
||||
use attr;
|
||||
use codemap::{self, CodeMap};
|
||||
@ -344,7 +344,7 @@ pub fn trait_item_to_string(i: &ast::TraitItem) -> String {
|
||||
to_string(|s| s.print_trait_item(i))
|
||||
}
|
||||
|
||||
pub fn generic_params_to_string(generic_params: &[ast::GenericParam]) -> String {
|
||||
pub fn generic_params_to_string(generic_params: &[ast::GenericParamAST]) -> String {
|
||||
to_string(|s| s.print_generic_params(generic_params))
|
||||
}
|
||||
|
||||
@ -1017,10 +1017,10 @@ impl<'a> State<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn print_generic_arg(&mut self, generic_arg: &GenericArg) -> io::Result<()> {
|
||||
pub fn print_generic_arg(&mut self, generic_arg: &GenericArgAST) -> io::Result<()> {
|
||||
match generic_arg {
|
||||
GenericArg::Lifetime(lt) => self.print_lifetime(lt),
|
||||
GenericArg::Type(ty) => self.print_type(ty),
|
||||
GenericArgAST::Lifetime(lt) => self.print_lifetime(lt),
|
||||
GenericArgAST::Type(ty) => self.print_type(ty),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1443,7 +1443,7 @@ impl<'a> State<'a> {
|
||||
|
||||
fn print_formal_generic_params(
|
||||
&mut self,
|
||||
generic_params: &[ast::GenericParam]
|
||||
generic_params: &[ast::GenericParamAST]
|
||||
) -> io::Result<()> {
|
||||
if !generic_params.is_empty() {
|
||||
self.s.word("for")?;
|
||||
@ -2869,7 +2869,7 @@ impl<'a> State<'a> {
|
||||
|
||||
pub fn print_generic_params(
|
||||
&mut self,
|
||||
generic_params: &[ast::GenericParam]
|
||||
generic_params: &[ast::GenericParamAST]
|
||||
) -> io::Result<()> {
|
||||
if generic_params.is_empty() {
|
||||
return Ok(());
|
||||
@ -2879,11 +2879,11 @@ impl<'a> State<'a> {
|
||||
|
||||
self.commasep(Inconsistent, &generic_params, |s, param| {
|
||||
match *param {
|
||||
ast::GenericParam::Lifetime(ref lifetime_def) => {
|
||||
ast::GenericParamAST::Lifetime(ref lifetime_def) => {
|
||||
s.print_outer_attributes_inline(&lifetime_def.attrs)?;
|
||||
s.print_lifetime_bounds(&lifetime_def.lifetime, &lifetime_def.bounds)
|
||||
},
|
||||
ast::GenericParam::Type(ref ty_param) => s.print_ty_param(ty_param),
|
||||
ast::GenericParamAST::Type(ref ty_param) => s.print_ty_param(ty_param),
|
||||
}
|
||||
})?;
|
||||
|
||||
@ -3047,7 +3047,7 @@ impl<'a> State<'a> {
|
||||
unsafety: ast::Unsafety,
|
||||
decl: &ast::FnDecl,
|
||||
name: Option<ast::Ident>,
|
||||
generic_params: &Vec<ast::GenericParam>)
|
||||
generic_params: &Vec<ast::GenericParamAST>)
|
||||
-> io::Result<()> {
|
||||
self.ibox(INDENT_UNIT)?;
|
||||
if !generic_params.is_empty() {
|
||||
|
@ -71,7 +71,7 @@ impl<'ast> Visitor<'ast> for NodeCounter {
|
||||
self.count += 1;
|
||||
walk_ty(self, t)
|
||||
}
|
||||
fn visit_generic_param(&mut self, param: &GenericParam) {
|
||||
fn visit_generic_param(&mut self, param: &GenericParamAST) {
|
||||
self.count += 1;
|
||||
walk_generic_param(self, param)
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ pub trait Visitor<'ast>: Sized {
|
||||
fn visit_expr(&mut self, ex: &'ast Expr) { walk_expr(self, ex) }
|
||||
fn visit_expr_post(&mut self, _ex: &'ast Expr) { }
|
||||
fn visit_ty(&mut self, t: &'ast Ty) { walk_ty(self, t) }
|
||||
fn visit_generic_param(&mut self, param: &'ast GenericParam) { walk_generic_param(self, param) }
|
||||
fn visit_generic_param(&mut self, param: &'ast GenericParamAST) { walk_generic_param(self, param) }
|
||||
fn visit_generics(&mut self, g: &'ast Generics) { walk_generics(self, g) }
|
||||
fn visit_where_predicate(&mut self, p: &'ast WherePredicate) {
|
||||
walk_where_predicate(self, p)
|
||||
@ -131,10 +131,10 @@ pub trait Visitor<'ast>: Sized {
|
||||
fn visit_generic_args(&mut self, path_span: Span, generic_args: &'ast GenericArgs) {
|
||||
walk_generic_args(self, path_span, generic_args)
|
||||
}
|
||||
fn visit_generic_arg(&mut self, generic_arg: &'ast GenericArg) {
|
||||
fn visit_generic_arg(&mut self, generic_arg: &'ast GenericArgAST) {
|
||||
match generic_arg {
|
||||
GenericArg::Lifetime(lt) => self.visit_lifetime(lt),
|
||||
GenericArg::Type(ty) => self.visit_ty(ty),
|
||||
GenericArgAST::Lifetime(lt) => self.visit_lifetime(lt),
|
||||
GenericArgAST::Type(ty) => self.visit_ty(ty),
|
||||
}
|
||||
}
|
||||
fn visit_assoc_type_binding(&mut self, type_binding: &'ast TypeBinding) {
|
||||
@ -488,14 +488,14 @@ pub fn walk_ty_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a TyPar
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_generic_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a GenericParam) {
|
||||
pub fn walk_generic_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a GenericParamAST) {
|
||||
match *param {
|
||||
GenericParam::Lifetime(ref l) => {
|
||||
GenericParamAST::Lifetime(ref l) => {
|
||||
visitor.visit_ident(l.lifetime.ident);
|
||||
walk_list!(visitor, visit_lifetime, &l.bounds);
|
||||
walk_list!(visitor, visit_attribute, &*l.attrs);
|
||||
}
|
||||
GenericParam::Type(ref t) => {
|
||||
GenericParamAST::Type(ref t) => {
|
||||
visitor.visit_ident(t.ident);
|
||||
walk_list!(visitor, visit_ty_param_bound, &t.bounds);
|
||||
walk_list!(visitor, visit_ty, &t.default);
|
||||
|
@ -13,7 +13,7 @@ use deriving::generic::*;
|
||||
use deriving::generic::ty::*;
|
||||
|
||||
use syntax::ast::{self, Expr, Generics, ItemKind, MetaItem, VariantData};
|
||||
use syntax::ast::GenericArg;
|
||||
use syntax::ast::GenericArgAST;
|
||||
use syntax::attr;
|
||||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||
use syntax::ext::build::AstBuilder;
|
||||
@ -124,7 +124,7 @@ fn cs_clone_shallow(name: &str,
|
||||
let span = span.with_ctxt(cx.backtrace());
|
||||
let assert_path = cx.path_all(span, true,
|
||||
cx.std_path(&["clone", helper_name]),
|
||||
vec![GenericArg::Type(ty)], vec![]);
|
||||
vec![GenericArgAST::Type(ty)], vec![]);
|
||||
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
|
||||
}
|
||||
fn process_variant(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>, variant: &VariantData) {
|
||||
|
@ -12,7 +12,7 @@ use deriving::path_std;
|
||||
use deriving::generic::*;
|
||||
use deriving::generic::ty::*;
|
||||
|
||||
use syntax::ast::{self, Expr, MetaItem, GenericArg};
|
||||
use syntax::ast::{self, Expr, MetaItem, GenericArgAST};
|
||||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||
use syntax::ext::build::AstBuilder;
|
||||
use syntax::ptr::P;
|
||||
@ -62,7 +62,7 @@ fn cs_total_eq_assert(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
||||
let span = span.with_ctxt(cx.backtrace());
|
||||
let assert_path = cx.path_all(span, true,
|
||||
cx.std_path(&["cmp", helper_name]),
|
||||
vec![GenericArg::Type(ty)], vec![]);
|
||||
vec![GenericArgAST::Type(ty)], vec![]);
|
||||
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
|
||||
}
|
||||
fn process_variant(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>, variant: &ast::VariantData) {
|
||||
|
@ -192,8 +192,8 @@ use std::collections::HashSet;
|
||||
use std::vec;
|
||||
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast::{self, BinOpKind, EnumDef, Expr, GenericParam, Generics, Ident, PatKind};
|
||||
use syntax::ast::{VariantData, GenericArg};
|
||||
use syntax::ast::{self, BinOpKind, EnumDef, Expr, GenericParamAST, Generics, Ident, PatKind};
|
||||
use syntax::ast::{VariantData, GenericArgAST};
|
||||
use syntax::attr;
|
||||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||
use syntax::ext::build::AstBuilder;
|
||||
@ -548,8 +548,8 @@ impl<'a> TraitDef<'a> {
|
||||
// Create the generic parameters
|
||||
params.extend(generics.params.iter().map(|param| {
|
||||
match *param {
|
||||
ref l @ GenericParam::Lifetime(_) => l.clone(),
|
||||
GenericParam::Type(ref ty_param) => {
|
||||
ref l @ GenericParamAST::Lifetime(_) => l.clone(),
|
||||
GenericParamAST::Type(ref ty_param) => {
|
||||
// I don't think this can be moved out of the loop, since
|
||||
// a TyParamBound requires an ast id
|
||||
let mut bounds: Vec<_> =
|
||||
@ -568,7 +568,7 @@ impl<'a> TraitDef<'a> {
|
||||
bounds.push((*declared_bound).clone());
|
||||
}
|
||||
|
||||
GenericParam::Type(cx.typaram(self.span, ty_param.ident, vec![], bounds, None))
|
||||
GenericParamAST::Type(cx.typaram(self.span, ty_param.ident, vec![], bounds, None))
|
||||
}
|
||||
}
|
||||
}));
|
||||
@ -607,7 +607,7 @@ impl<'a> TraitDef<'a> {
|
||||
|
||||
let mut ty_params = params.iter()
|
||||
.filter_map(|param| match *param {
|
||||
ast::GenericParam::Type(ref t) => Some(t),
|
||||
ast::GenericParamAST::Type(ref t) => Some(t),
|
||||
_ => None,
|
||||
})
|
||||
.peekable();
|
||||
@ -668,7 +668,7 @@ impl<'a> TraitDef<'a> {
|
||||
let self_ty_params: Vec<P<ast::Ty>> = generics.params
|
||||
.iter()
|
||||
.filter_map(|param| match *param {
|
||||
GenericParam::Type(ref ty_param)
|
||||
GenericParamAST::Type(ref ty_param)
|
||||
=> Some(cx.ty_ident(self.span, ty_param.ident)),
|
||||
_ => None,
|
||||
})
|
||||
@ -677,15 +677,15 @@ impl<'a> TraitDef<'a> {
|
||||
let self_lifetimes: Vec<ast::Lifetime> = generics.params
|
||||
.iter()
|
||||
.filter_map(|param| match *param {
|
||||
GenericParam::Lifetime(ref ld) => Some(ld.lifetime),
|
||||
GenericParamAST::Lifetime(ref ld) => Some(ld.lifetime),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
|
||||
let self_params = self_lifetimes.into_iter()
|
||||
.map(|lt| GenericArg::Lifetime(lt))
|
||||
.map(|lt| GenericArgAST::Lifetime(lt))
|
||||
.chain(self_ty_params.into_iter().map(|ty|
|
||||
GenericArg::Type(ty)))
|
||||
GenericArgAST::Type(ty)))
|
||||
.collect();
|
||||
|
||||
// Create the type of `self`.
|
||||
|
@ -15,7 +15,7 @@ pub use self::PtrTy::*;
|
||||
pub use self::Ty::*;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::ast::{Expr, GenericParam, Generics, Ident, SelfKind, GenericArg};
|
||||
use syntax::ast::{Expr, GenericParamAST, Generics, Ident, SelfKind, GenericArgAST};
|
||||
use syntax::ext::base::ExtCtxt;
|
||||
use syntax::ext::build::AstBuilder;
|
||||
use syntax::codemap::{respan, DUMMY_SP};
|
||||
@ -89,8 +89,8 @@ impl<'a> Path<'a> {
|
||||
let tys: Vec<P<ast::Ty>> =
|
||||
self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics)).collect();
|
||||
let params = lt.into_iter()
|
||||
.map(|lt| GenericArg::Lifetime(lt))
|
||||
.chain(tys.into_iter().map(|ty| GenericArg::Type(ty)))
|
||||
.map(|lt| GenericArgAST::Lifetime(lt))
|
||||
.chain(tys.into_iter().map(|ty| GenericArgAST::Type(ty)))
|
||||
.collect();
|
||||
|
||||
match self.kind {
|
||||
@ -192,7 +192,7 @@ impl<'a> Ty<'a> {
|
||||
let ty_params: Vec<P<ast::Ty>> = self_generics.params
|
||||
.iter()
|
||||
.filter_map(|param| match *param {
|
||||
GenericParam::Type(ref ty_param) => Some(cx.ty_ident(span, ty_param.ident)),
|
||||
GenericParamAST::Type(ref ty_param) => Some(cx.ty_ident(span, ty_param.ident)),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
@ -200,15 +200,15 @@ impl<'a> Ty<'a> {
|
||||
let lifetimes: Vec<ast::Lifetime> = self_generics.params
|
||||
.iter()
|
||||
.filter_map(|param| match *param {
|
||||
GenericParam::Lifetime(ref ld) => Some(ld.lifetime),
|
||||
GenericParamAST::Lifetime(ref ld) => Some(ld.lifetime),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
|
||||
let params = lifetimes.into_iter()
|
||||
.map(|lt| GenericArg::Lifetime(lt))
|
||||
.map(|lt| GenericArgAST::Lifetime(lt))
|
||||
.chain(ty_params.into_iter().map(|ty|
|
||||
GenericArg::Type(ty)))
|
||||
GenericArgAST::Type(ty)))
|
||||
.collect();
|
||||
|
||||
cx.path_all(span,
|
||||
@ -242,7 +242,7 @@ fn mk_ty_param(cx: &ExtCtxt,
|
||||
cx.typaram(span, cx.ident_of(name), attrs.to_owned(), bounds, None)
|
||||
}
|
||||
|
||||
fn mk_generics(params: Vec<GenericParam>, span: Span) -> Generics {
|
||||
fn mk_generics(params: Vec<GenericParamAST>, span: Span) -> Generics {
|
||||
Generics {
|
||||
params,
|
||||
where_clause: ast::WhereClause {
|
||||
@ -280,13 +280,13 @@ impl<'a> LifetimeBounds<'a> {
|
||||
let bounds = bounds.iter()
|
||||
.map(|b| cx.lifetime(span, Ident::from_str(b)))
|
||||
.collect();
|
||||
GenericParam::Lifetime(cx.lifetime_def(span, Ident::from_str(lt), vec![], bounds))
|
||||
GenericParamAST::Lifetime(cx.lifetime_def(span, Ident::from_str(lt), vec![], bounds))
|
||||
})
|
||||
.chain(self.bounds
|
||||
.iter()
|
||||
.map(|t| {
|
||||
let (name, ref bounds) = *t;
|
||||
GenericParam::Type(mk_ty_param(
|
||||
GenericParamAST::Type(mk_ty_param(
|
||||
cx, span, name, &[], &bounds, self_ty, self_generics
|
||||
))
|
||||
})
|
||||
|
@ -135,7 +135,7 @@ fn hygienic_type_parameter(item: &Annotatable, base: &str) -> String {
|
||||
ast::ItemKind::Struct(_, ast::Generics { ref params, .. }) |
|
||||
ast::ItemKind::Enum(_, ast::Generics { ref params, .. }) => {
|
||||
for param in params.iter() {
|
||||
if let ast::GenericParam::Type(ref ty) = *param{
|
||||
if let ast::GenericParamAST::Type(ref ty) = *param {
|
||||
typaram.push_str(&ty.ident.as_str());
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
// interface.
|
||||
//
|
||||
|
||||
use syntax::ast::{self, Ident, GenericArg};
|
||||
use syntax::ast::{self, Ident, GenericArgAST};
|
||||
use syntax::ext::base::*;
|
||||
use syntax::ext::base;
|
||||
use syntax::ext::build::AstBuilder;
|
||||
@ -39,7 +39,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt,
|
||||
cx.expr_path(cx.path_all(sp,
|
||||
true,
|
||||
cx.std_path(&["option", "Option", "None"]),
|
||||
vec![GenericArg::Type(cx.ty_rptr(sp,
|
||||
vec![GenericArgAST::Type(cx.ty_rptr(sp,
|
||||
cx.ty_ident(sp, Ident::from_str("str")),
|
||||
Some(lt),
|
||||
ast::Mutability::Immutable))],
|
||||
|
Loading…
Reference in New Issue
Block a user