diff options
| author | varkor <github@varkor.com> | 2018-06-14 12:23:46 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-06-20 12:23:46 +0100 |
| commit | 95f1866a4df85e815886901a7b64d8dd64709872 (patch) | |
| tree | bdbf856debaa41d7b8efd222db486fc09a4e93fd /src/libsyntax | |
| parent | c5f16e0e180f4f76187e55aecb5913a1cf7fab2a (diff) | |
| download | rust-95f1866a4df85e815886901a7b64d8dd64709872.tar.gz rust-95f1866a4df85e815886901a7b64d8dd64709872.zip | |
Make GenericBound explicit
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 8 |
6 files changed, 23 insertions, 25 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 9dc13fab2d6..76d19ce0ac5 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,6 @@ // The Rust abstract syntax tree. -pub use self::GenericBound::*; pub use self::UnsafeSource::*; pub use self::GenericArgs::*; pub use symbol::{Ident, Symbol as Name}; @@ -290,8 +289,8 @@ pub enum GenericBound { impl GenericBound { pub fn span(&self) -> Span { match self { - &Trait(ref t, ..) => t.span, - &Outlives(ref l) => l.ident.span, + &GenericBound::Trait(ref t, ..) => t.span, + &GenericBound::Outlives(ref l) => l.ident.span, } } } @@ -930,8 +929,8 @@ impl Expr { fn to_bound(&self) -> Option<GenericBound> { match &self.node { ExprKind::Path(None, path) => - Some(Trait(PolyTraitRef::new(Vec::new(), path.clone(), self.span), - TraitBoundModifier::None)), + Some(GenericBound::Trait(PolyTraitRef::new(Vec::new(), path.clone(), self.span), + TraitBoundModifier::None)), _ => None, } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 9de6e14fbeb..40d45306149 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -465,7 +465,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn ty_param_bound(&self, path: ast::Path) -> ast::GenericBound { - ast::Trait(self.poly_trait_ref(path.span, path), ast::TraitBoundModifier::None) + ast::GenericBound::Trait(self.poly_trait_ref(path.span, path), + ast::TraitBoundModifier::None) } fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 5db5d0781ea..03668cc279a 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -678,10 +678,12 @@ pub fn noop_fold_fn_decl<T: Folder>(decl: P<FnDecl>, fld: &mut T) -> P<FnDecl> { 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) + GenericBound::Trait(ty, modifier) => { + GenericBound::Trait(fld.fold_poly_trait_ref(ty), modifier) + } + GenericBound::Outlives(lifetime) => { + GenericBound::Outlives(noop_fold_lifetime(lifetime, fld)) } - Outlives(lifetime) => Outlives(noop_fold_lifetime(lifetime, fld)), } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8588f4c492f..675849c8a5c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -10,7 +10,7 @@ use rustc_target::spec::abi::{self, Abi}; use ast::{AngleBracketedArgs, ParenthesizedArgData, AttrStyle, BareFnTy}; -use ast::{Outlives, Trait, TraitBoundModifier}; +use ast::{GenericBound, TraitBoundModifier}; use ast::Unsafety; use ast::{Mod, AnonConst, Arg, Arm, Attribute, BindingMode, TraitItemKind}; use ast::Block; @@ -1444,7 +1444,7 @@ impl<'a> Parser<'a> { TyKind::TraitObject(ref bounds, TraitObjectSyntax::None) if maybe_bounds && bounds.len() == 1 && !trailing_plus => { let path = match bounds[0] { - Trait(ref pt, ..) => pt.trait_ref.path.clone(), + GenericBound::Trait(ref pt, ..) => pt.trait_ref.path.clone(), _ => self.bug("unexpected lifetime bound"), }; self.parse_remaining_bounds(Vec::new(), path, lo, true)? @@ -1566,7 +1566,7 @@ impl<'a> Parser<'a> { fn parse_remaining_bounds(&mut self, generic_params: Vec<GenericParam>, 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![Trait(poly_trait_ref, TraitBoundModifier::None)]; + let mut bounds = vec![GenericBound::Trait(poly_trait_ref, TraitBoundModifier::None)]; if parse_plus { self.eat_plus(); // `+`, or `+=` gets split and `+` is discarded bounds.append(&mut self.parse_ty_param_bounds()?); @@ -4752,7 +4752,7 @@ impl<'a> Parser<'a> { self.span_err(question_span, "`?` may only modify trait bounds, not lifetime bounds"); } - bounds.push(Outlives(self.expect_lifetime())); + bounds.push(GenericBound::Outlives(self.expect_lifetime())); if has_parens { self.expect(&token::CloseDelim(token::Paren))?; self.span_err(self.prev_span, @@ -4770,7 +4770,7 @@ impl<'a> Parser<'a> { } else { TraitBoundModifier::None }; - bounds.push(Trait(poly_trait, modifier)); + bounds.push(GenericBound::Trait(poly_trait, modifier)); } } else { break diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 1e0b107ef6e..7a55919f422 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -12,7 +12,7 @@ pub use self::AnnNode::*; use rustc_target::spec::abi::{self, Abi}; use ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax}; -use ast::{SelfKind, Outlives, Trait, TraitBoundModifier}; +use ast::{SelfKind, GenericBound, TraitBoundModifier}; use ast::{Attribute, MacDelimiter, GenericArg}; use util::parser::{self, AssocOp, Fixity}; use attr; @@ -1364,7 +1364,7 @@ impl<'a> State<'a> { self.print_generic_params(&generics.params)?; let mut real_bounds = Vec::with_capacity(bounds.len()); for b in bounds.iter() { - if let Trait(ref ptr, ast::TraitBoundModifier::Maybe) = *b { + if let GenericBound::Trait(ref ptr, ast::TraitBoundModifier::Maybe) = *b { self.s.space()?; self.word_space("for ?")?; self.print_trait_ref(&ptr.trait_ref)?; @@ -1390,7 +1390,7 @@ impl<'a> State<'a> { let mut real_bounds = Vec::with_capacity(bounds.len()); // FIXME(durka) this seems to be some quite outdated syntax for b in bounds.iter() { - if let Trait(ref ptr, ast::TraitBoundModifier::Maybe) = *b { + if let GenericBound::Trait(ref ptr, ast::TraitBoundModifier::Maybe) = *b { self.s.space()?; self.word_space("for ?")?; self.print_trait_ref(&ptr.trait_ref)?; @@ -2826,13 +2826,13 @@ impl<'a> State<'a> { } match bound { - Trait(tref, modifier) => { + GenericBound::Trait(tref, modifier) => { if modifier == &TraitBoundModifier::Maybe { self.s.word("?")?; } self.print_poly_trait_ref(tref)?; } - Outlives(lt) => self.print_lifetime(*lt)?, + GenericBound::Outlives(lt) => self.print_lifetime(*lt)?, } } } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 71b606f08a5..5476a3f0d2a 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -481,12 +481,8 @@ pub fn walk_global_asm<'a, V: Visitor<'a>>(_: &mut V, _: &'a GlobalAsm) { 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); - } - Outlives(ref lifetime) => { - visitor.visit_lifetime(lifetime); - } + GenericBound::Trait(ref typ, ref modifier) => visitor.visit_poly_trait_ref(typ, modifier), + GenericBound::Outlives(ref lifetime) => visitor.visit_lifetime(lifetime), } } |
