Rename ParamBound(s) to GenericBound(s)

This commit is contained in:
varkor
2018-06-14 12:08:58 +01:00
parent 991efa4284
commit c5f16e0e18
29 changed files with 181 additions and 181 deletions

View File

@@ -10,7 +10,7 @@
// The Rust abstract syntax tree.
pub use self::ParamBound::*;
pub use self::GenericBound::*;
pub use self::UnsafeSource::*;
pub use self::GenericArgs::*;
pub use symbol::{Ident, Symbol as Name};
@@ -282,12 +282,12 @@ pub enum TraitBoundModifier {
/// the "special" built-in traits (see middle::lang_items) and
/// detects Copy, Send and Sync.
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum ParamBound {
pub enum GenericBound {
Trait(PolyTraitRef, TraitBoundModifier),
Outlives(Lifetime)
}
impl ParamBound {
impl GenericBound {
pub fn span(&self) -> Span {
match self {
&Trait(ref t, ..) => t.span,
@@ -296,7 +296,7 @@ impl ParamBound {
}
}
pub type ParamBounds = Vec<ParamBound>;
pub type GenericBounds = Vec<GenericBound>;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum GenericParamKind {
@@ -312,7 +312,7 @@ pub struct GenericParam {
pub id: NodeId,
pub ident: Ident,
pub attrs: ThinVec<Attribute>,
pub bounds: ParamBounds,
pub bounds: GenericBounds,
pub kind: GenericParamKind,
}
@@ -381,7 +381,7 @@ pub struct WhereBoundPredicate {
/// The type being bounded
pub bounded_ty: P<Ty>,
/// Trait and lifetime bounds (`Clone+Send+'static`)
pub bounds: ParamBounds,
pub bounds: GenericBounds,
}
/// A lifetime predicate.
@@ -391,7 +391,7 @@ pub struct WhereBoundPredicate {
pub struct WhereRegionPredicate {
pub span: Span,
pub lifetime: Lifetime,
pub bounds: ParamBounds,
pub bounds: GenericBounds,
}
/// An equality predicate (unsupported).
@@ -927,7 +927,7 @@ impl Expr {
}
}
fn to_bound(&self) -> Option<ParamBound> {
fn to_bound(&self) -> Option<GenericBound> {
match &self.node {
ExprKind::Path(None, path) =>
Some(Trait(PolyTraitRef::new(Vec::new(), path.clone(), self.span),
@@ -1352,7 +1352,7 @@ pub struct TraitItem {
pub enum TraitItemKind {
Const(P<Ty>, Option<P<Expr>>),
Method(MethodSig, Option<P<Block>>),
Type(ParamBounds, Option<P<Ty>>),
Type(GenericBounds, Option<P<Ty>>),
Macro(Mac),
}
@@ -1537,10 +1537,10 @@ pub enum TyKind {
Path(Option<QSelf>, Path),
/// A trait object type `Bound1 + Bound2 + Bound3`
/// where `Bound` is a trait or a lifetime.
TraitObject(ParamBounds, TraitObjectSyntax),
TraitObject(GenericBounds, TraitObjectSyntax),
/// An `impl Bound1 + Bound2 + Bound3` type
/// where `Bound` is a trait or a lifetime.
ImplTrait(ParamBounds),
ImplTrait(GenericBounds),
/// No-op; kept solely so that we can pretty-print faithfully
Paren(P<Ty>),
/// Unused for now
@@ -2061,11 +2061,11 @@ pub enum ItemKind {
/// A Trait declaration (`trait` or `pub trait`).
///
/// E.g. `trait Foo { .. }`, `trait Foo<T> { .. }` or `auto trait Foo {}`
Trait(IsAuto, Unsafety, Generics, ParamBounds, Vec<TraitItem>),
Trait(IsAuto, Unsafety, Generics, GenericBounds, Vec<TraitItem>),
/// Trait alias
///
/// E.g. `trait Foo = Bar + Quux;`
TraitAlias(Generics, ParamBounds),
TraitAlias(Generics, GenericBounds),
/// An implementation.
///
/// E.g. `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`

View File

@@ -68,18 +68,18 @@ pub trait AstBuilder {
span: Span,
id: ast::Ident,
attrs: Vec<ast::Attribute>,
bounds: ast::ParamBounds,
bounds: ast::GenericBounds,
default: Option<P<ast::Ty>>) -> ast::GenericParam;
fn trait_ref(&self, path: ast::Path) -> ast::TraitRef;
fn poly_trait_ref(&self, span: Span, path: ast::Path) -> ast::PolyTraitRef;
fn ty_param_bound(&self, path: ast::Path) -> ast::ParamBound;
fn ty_param_bound(&self, path: ast::Path) -> ast::GenericBound;
fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime;
fn lifetime_def(&self,
span: Span,
ident: ast::Ident,
attrs: Vec<ast::Attribute>,
bounds: ast::ParamBounds)
bounds: ast::GenericBounds)
-> ast::GenericParam;
// statements
@@ -436,7 +436,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
span: Span,
ident: ast::Ident,
attrs: Vec<ast::Attribute>,
bounds: ast::ParamBounds,
bounds: ast::GenericBounds,
default: Option<P<ast::Ty>>) -> ast::GenericParam {
ast::GenericParam {
ident: ident.with_span_pos(span),
@@ -464,7 +464,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
}
}
fn ty_param_bound(&self, path: ast::Path) -> ast::ParamBound {
fn ty_param_bound(&self, path: ast::Path) -> ast::GenericBound {
ast::Trait(self.poly_trait_ref(path.span, path), ast::TraitBoundModifier::None)
}
@@ -476,7 +476,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
span: Span,
ident: ast::Ident,
attrs: Vec<ast::Attribute>,
bounds: ast::ParamBounds)
bounds: ast::GenericBounds)
-> ast::GenericParam {
let lifetime = self.lifetime(span, ident);
ast::GenericParam {

View File

@@ -268,15 +268,15 @@ pub trait Folder : Sized {
noop_fold_interpolated(nt, self)
}
fn fold_opt_bounds(&mut self, b: Option<ParamBounds>) -> Option<ParamBounds> {
fn fold_opt_bounds(&mut self, b: Option<GenericBounds>) -> Option<GenericBounds> {
noop_fold_opt_bounds(b, self)
}
fn fold_bounds(&mut self, b: ParamBounds) -> ParamBounds {
fn fold_bounds(&mut self, b: GenericBounds) -> GenericBounds {
noop_fold_bounds(b, self)
}
fn fold_param_bound(&mut self, tpb: ParamBound) -> ParamBound {
fn fold_param_bound(&mut self, tpb: GenericBound) -> GenericBound {
noop_fold_param_bound(tpb, self)
}
@@ -676,7 +676,7 @@ pub fn noop_fold_fn_decl<T: Folder>(decl: P<FnDecl>, fld: &mut T) -> P<FnDecl> {
})
}
pub fn noop_fold_param_bound<T>(pb: ParamBound, fld: &mut T) -> ParamBound where T: Folder {
pub fn noop_fold_param_bound<T>(pb: GenericBound, fld: &mut T) -> GenericBound where T: Folder {
match pb {
Trait(ty, modifier) => {
Trait(fld.fold_poly_trait_ref(ty), modifier)
@@ -847,13 +847,13 @@ 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<ParamBounds>, folder: &mut T)
-> Option<ParamBounds> {
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<GenericBounds>, folder: &mut T)
-> Option<GenericBounds> {
b.map(|bounds| folder.fold_bounds(bounds))
}
fn noop_fold_bounds<T: Folder>(bounds: ParamBounds, folder: &mut T)
-> ParamBounds {
fn noop_fold_bounds<T: Folder>(bounds: GenericBounds, folder: &mut T)
-> GenericBounds {
bounds.move_map(|bound| folder.fold_param_bound(bound))
}

View File

@@ -36,7 +36,7 @@ use ast::{VariantData, StructField};
use ast::StrStyle;
use ast::SelfKind;
use ast::{TraitItem, TraitRef, TraitObjectSyntax};
use ast::{Ty, TyKind, TypeBinding, ParamBounds};
use ast::{Ty, TyKind, TypeBinding, GenericBounds};
use ast::{Visibility, VisibilityKind, WhereClause, CrateSugar};
use ast::{UseTree, UseTreeKind};
use ast::{BinOpKind, UnOp};
@@ -4735,7 +4735,7 @@ impl<'a> Parser<'a> {
// LT_BOUND = LIFETIME (e.g. `'a`)
// TY_BOUND = TY_BOUND_NOPAREN | (TY_BOUND_NOPAREN)
// TY_BOUND_NOPAREN = [?] [for<LT_PARAM_DEFS>] SIMPLE_PATH (e.g. `?for<'a: 'b> m::Trait<'a>`)
fn parse_ty_param_bounds_common(&mut self, allow_plus: bool) -> PResult<'a, ParamBounds> {
fn parse_ty_param_bounds_common(&mut self, allow_plus: bool) -> PResult<'a, GenericBounds> {
let mut bounds = Vec::new();
loop {
// This needs to be syncronized with `Token::can_begin_bound`.
@@ -4784,16 +4784,16 @@ impl<'a> Parser<'a> {
return Ok(bounds);
}
fn parse_ty_param_bounds(&mut self) -> PResult<'a, ParamBounds> {
fn parse_ty_param_bounds(&mut self) -> PResult<'a, GenericBounds> {
self.parse_ty_param_bounds_common(true)
}
// Parse bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
// BOUND = LT_BOUND (e.g. `'a`)
fn parse_lt_param_bounds(&mut self) -> ParamBounds {
fn parse_lt_param_bounds(&mut self) -> GenericBounds {
let mut lifetimes = Vec::new();
while self.check_lifetime() {
lifetimes.push(ast::ParamBound::Outlives(self.expect_lifetime()));
lifetimes.push(ast::GenericBound::Outlives(self.expect_lifetime()));
if !self.eat_plus() {
break
@@ -4833,7 +4833,7 @@ impl<'a> Parser<'a> {
}
/// Parses the following grammar:
/// TraitItemAssocTy = Ident ["<"...">"] [":" [ParamBounds]] ["where" ...] ["=" Ty]
/// TraitItemAssocTy = Ident ["<"...">"] [":" [GenericBounds]] ["where" ...] ["=" Ty]
fn parse_trait_item_assoc_ty(&mut self)
-> PResult<'a, (Ident, TraitItemKind, ast::Generics)> {
let ident = self.parse_ident()?;

View File

@@ -292,7 +292,7 @@ pub fn ty_to_string(ty: &ast::Ty) -> String {
to_string(|s| s.print_type(ty))
}
pub fn bounds_to_string(bounds: &[ast::ParamBound]) -> String {
pub fn bounds_to_string(bounds: &[ast::GenericBound]) -> String {
to_string(|s| s.print_type_bounds("", bounds))
}
@@ -1177,7 +1177,7 @@ impl<'a> State<'a> {
fn print_associated_type(&mut self,
ident: ast::Ident,
bounds: Option<&ast::ParamBounds>,
bounds: Option<&ast::GenericBounds>,
ty: Option<&ast::Ty>)
-> io::Result<()> {
self.word_space("type")?;
@@ -2810,7 +2810,7 @@ impl<'a> State<'a> {
pub fn print_type_bounds(&mut self,
prefix: &str,
bounds: &[ast::ParamBound])
bounds: &[ast::GenericBound])
-> io::Result<()> {
if !bounds.is_empty() {
self.s.word(prefix)?;
@@ -2843,7 +2843,7 @@ impl<'a> State<'a> {
self.print_name(lifetime.ident.name)
}
pub fn print_lifetime_bounds(&mut self, lifetime: ast::Lifetime, bounds: &ast::ParamBounds)
pub fn print_lifetime_bounds(&mut self, lifetime: ast::Lifetime, bounds: &ast::GenericBounds)
-> io::Result<()>
{
self.print_lifetime(lifetime)?;
@@ -2854,7 +2854,7 @@ impl<'a> State<'a> {
self.s.word(" + ")?;
}
match bound {
ast::ParamBound::Outlives(lt) => self.print_lifetime(*lt)?,
ast::GenericBound::Outlives(lt) => self.print_lifetime(*lt)?,
_ => panic!(),
}
}

View File

@@ -95,7 +95,7 @@ impl<'ast> Visitor<'ast> for NodeCounter {
self.count += 1;
walk_trait_ref(self, t)
}
fn visit_param_bound(&mut self, bounds: &ParamBound) {
fn visit_param_bound(&mut self, bounds: &GenericBound) {
self.count += 1;
walk_param_bound(self, bounds)
}

View File

@@ -86,7 +86,7 @@ pub trait Visitor<'ast>: Sized {
fn visit_trait_item(&mut self, ti: &'ast TraitItem) { walk_trait_item(self, ti) }
fn visit_impl_item(&mut self, ii: &'ast ImplItem) { walk_impl_item(self, ii) }
fn visit_trait_ref(&mut self, t: &'ast TraitRef) { walk_trait_ref(self, t) }
fn visit_param_bound(&mut self, bounds: &'ast ParamBound) {
fn visit_param_bound(&mut self, bounds: &'ast GenericBound) {
walk_param_bound(self, bounds)
}
fn visit_poly_trait_ref(&mut self, t: &'ast PolyTraitRef, m: &'ast TraitBoundModifier) {
@@ -479,7 +479,7 @@ pub fn walk_global_asm<'a, V: Visitor<'a>>(_: &mut V, _: &'a GlobalAsm) {
// Empty!
}
pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a ParamBound) {
pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericBound) {
match *bound {
Trait(ref typ, ref modifier) => {
visitor.visit_poly_trait_ref(typ, modifier);