Rename TraitTyParamBound to ParamBound::Trait

This commit is contained in:
varkor 2018-06-14 11:25:14 +01:00
parent 8bc3a35576
commit 7de6ed06a5
17 changed files with 57 additions and 64 deletions

View file

@ -733,10 +733,10 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v
pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v ParamBound) { pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v ParamBound) {
match *bound { match *bound {
TraitTyParamBound(ref typ, modifier) => { ParamBound::Trait(ref typ, modifier) => {
visitor.visit_poly_trait_ref(typ, modifier); visitor.visit_poly_trait_ref(typ, modifier);
} }
Outlives(ref lifetime) => visitor.visit_lifetime(lifetime), ParamBound::Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
} }
} }

View file

@ -1108,10 +1108,10 @@ impl<'a> LoweringContext<'a> {
let bounds = bounds let bounds = bounds
.iter() .iter()
.filter_map(|bound| match *bound { .filter_map(|bound| match *bound {
TraitTyParamBound(ref ty, TraitBoundModifier::None) => { Trait(ref ty, TraitBoundModifier::None) => {
Some(self.lower_poly_trait_ref(ty, itctx)) Some(self.lower_poly_trait_ref(ty, itctx))
} }
TraitTyParamBound(_, TraitBoundModifier::Maybe) => None, Trait(_, TraitBoundModifier::Maybe) => None,
Outlives(ref lifetime) => { Outlives(ref lifetime) => {
if lifetime_bound.is_none() { if lifetime_bound.is_none() {
lifetime_bound = Some(self.lower_lifetime(lifetime)); lifetime_bound = Some(self.lower_lifetime(lifetime));
@ -1875,12 +1875,12 @@ impl<'a> LoweringContext<'a> {
itctx: ImplTraitContext, itctx: ImplTraitContext,
) -> hir::ParamBound { ) -> hir::ParamBound {
match *tpb { match *tpb {
TraitTyParamBound(ref ty, modifier) => hir::TraitTyParamBound( ParamBound::Trait(ref ty, modifier) => hir::ParamBound::Trait(
self.lower_poly_trait_ref(ty, itctx), self.lower_poly_trait_ref(ty, itctx),
self.lower_trait_bound_modifier(modifier), self.lower_trait_bound_modifier(modifier),
), ),
Outlives(ref lifetime) => { ParamBound::Outlives(ref lifetime) => {
hir::Outlives(self.lower_lifetime(lifetime)) hir::ParamBound::Outlives(self.lower_lifetime(lifetime))
} }
} }
} }
@ -2010,7 +2010,7 @@ impl<'a> LoweringContext<'a> {
for pred in &generics.where_clause.predicates { for pred in &generics.where_clause.predicates {
if let WherePredicate::BoundPredicate(ref bound_pred) = *pred { if let WherePredicate::BoundPredicate(ref bound_pred) = *pred {
'next_bound: for bound in &bound_pred.bounds { 'next_bound: for bound in &bound_pred.bounds {
if let TraitTyParamBound(_, TraitBoundModifier::Maybe) = *bound { if let ParamBound::Trait(_, TraitBoundModifier::Maybe) = *bound {
let report_error = |this: &mut Self| { let report_error = |this: &mut Self| {
this.diagnostic().span_err( this.diagnostic().span_err(
bound_pred.bounded_ty.span, bound_pred.bounded_ty.span,
@ -2095,7 +2095,7 @@ impl<'a> LoweringContext<'a> {
.filter_map(|bound| match *bound { .filter_map(|bound| match *bound {
// Ignore `?Trait` bounds. // Ignore `?Trait` bounds.
// Tthey were copied into type parameters already. // Tthey were copied into type parameters already.
TraitTyParamBound(_, TraitBoundModifier::Maybe) => None, ParamBound::Trait(_, TraitBoundModifier::Maybe) => None,
_ => Some(this.lower_param_bound( _ => Some(this.lower_param_bound(
bound, bound,
ImplTraitContext::Disallowed, ImplTraitContext::Disallowed,

View file

@ -22,7 +22,6 @@ pub use self::Mutability::*;
pub use self::PrimTy::*; pub use self::PrimTy::*;
pub use self::Stmt_::*; pub use self::Stmt_::*;
pub use self::Ty_::*; pub use self::Ty_::*;
pub use self::ParamBound::*;
pub use self::UnOp::*; pub use self::UnOp::*;
pub use self::UnsafeSource::*; pub use self::UnsafeSource::*;
pub use self::Visibility::{Public, Inherited}; pub use self::Visibility::{Public, Inherited};
@ -445,15 +444,15 @@ pub enum TraitBoundModifier {
/// detects Copy, Send and Sync. /// detects Copy, Send and Sync.
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum ParamBound { pub enum ParamBound {
TraitTyParamBound(PolyTraitRef, TraitBoundModifier), Trait(PolyTraitRef, TraitBoundModifier),
Outlives(Lifetime), Outlives(Lifetime),
} }
impl ParamBound { impl ParamBound {
pub fn span(&self) -> Span { pub fn span(&self) -> Span {
match self { match self {
&TraitTyParamBound(ref t, ..) => t.span, &ParamBound::Trait(ref t, ..) => t.span,
&Outlives(ref l) => l.span, &ParamBound::Outlives(ref l) => l.span,
} }
} }
} }

View file

@ -24,7 +24,7 @@ use syntax::util::parser::{self, AssocOp, Fixity};
use syntax_pos::{self, BytePos, FileName}; use syntax_pos::{self, BytePos, FileName};
use hir; use hir;
use hir::{PatKind, Outlives, TraitTyParamBound, TraitBoundModifier, RangeEnd}; use hir::{PatKind, ParamBound, TraitBoundModifier, RangeEnd};
use hir::{GenericParam, GenericParamKind, GenericArg}; use hir::{GenericParam, GenericParamKind, GenericArg};
use std::cell::Cell; use std::cell::Cell;
@ -740,7 +740,7 @@ impl<'a> State<'a> {
self.print_generic_params(&generics.params)?; self.print_generic_params(&generics.params)?;
let mut real_bounds = Vec::with_capacity(bounds.len()); let mut real_bounds = Vec::with_capacity(bounds.len());
for b in bounds.iter() { for b in bounds.iter() {
if let TraitTyParamBound(ref ptr, hir::TraitBoundModifier::Maybe) = *b { if let ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
self.s.space()?; self.s.space()?;
self.word_space("for ?")?; self.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?; self.print_trait_ref(&ptr.trait_ref)?;
@ -766,7 +766,7 @@ impl<'a> State<'a> {
let mut real_bounds = Vec::with_capacity(bounds.len()); let mut real_bounds = Vec::with_capacity(bounds.len());
// FIXME(durka) this seems to be some quite outdated syntax // FIXME(durka) this seems to be some quite outdated syntax
for b in bounds.iter() { for b in bounds.iter() {
if let TraitTyParamBound(ref ptr, hir::TraitBoundModifier::Maybe) = *b { if let ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
self.s.space()?; self.s.space()?;
self.word_space("for ?")?; self.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?; self.print_trait_ref(&ptr.trait_ref)?;
@ -2086,13 +2086,13 @@ impl<'a> State<'a> {
} }
match bound { match bound {
TraitTyParamBound(tref, modifier) => { ParamBound::Trait(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe { if modifier == &TraitBoundModifier::Maybe {
self.s.word("?")?; self.s.word("?")?;
} }
self.print_poly_trait_ref(tref)?; self.print_poly_trait_ref(tref)?;
} }
Outlives(lt) => { ParamBound::Outlives(lt) => {
self.print_lifetime(lt)?; self.print_lifetime(lt)?;
} }
} }
@ -2121,7 +2121,7 @@ impl<'a> State<'a> {
let mut sep = ":"; let mut sep = ":";
for bound in &param.bounds { for bound in &param.bounds {
match bound { match bound {
hir::ParamBound::Outlives(lt) => { ParamBound::Outlives(lt) => {
self.s.word(sep)?; self.s.word(sep)?;
self.print_lifetime(lt)?; self.print_lifetime(lt)?;
sep = "+"; sep = "+";
@ -2181,7 +2181,7 @@ impl<'a> State<'a> {
for (i, bound) in bounds.iter().enumerate() { for (i, bound) in bounds.iter().enumerate() {
match bound { match bound {
hir::ParamBound::Outlives(lt) => { ParamBound::Outlives(lt) => {
self.print_lifetime(lt)?; self.print_lifetime(lt)?;
} }
_ => bug!(), _ => bug!(),

View file

@ -189,7 +189,7 @@ impl_stable_hash_for!(struct hir::GenericArgs {
}); });
impl_stable_hash_for!(enum hir::ParamBound { impl_stable_hash_for!(enum hir::ParamBound {
TraitTyParamBound(poly_trait_ref, trait_bound_modifier), Trait(poly_trait_ref, trait_bound_modifier),
Outlives(lifetime) Outlives(lifetime)
}); });

View file

@ -1256,7 +1256,7 @@ fn object_lifetime_defaults_for_item(
) -> Vec<ObjectLifetimeDefault> { ) -> Vec<ObjectLifetimeDefault> {
fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::ParamBound]) { fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::ParamBound]) {
for bound in bounds { for bound in bounds {
if let hir::Outlives(ref lifetime) = *bound { if let hir::ParamBound::Outlives(ref lifetime) = *bound {
set.insert(lifetime.name); set.insert(lifetime.name);
} }
} }

View file

@ -101,7 +101,7 @@ impl<'a> AstValidator<'a> {
fn no_questions_in_bounds(&self, bounds: &ParamBounds, where_: &str, is_trait: bool) { fn no_questions_in_bounds(&self, bounds: &ParamBounds, where_: &str, is_trait: bool) {
for bound in bounds { for bound in bounds {
if let TraitTyParamBound(ref poly, TraitBoundModifier::Maybe) = *bound { if let Trait(ref poly, TraitBoundModifier::Maybe) = *bound {
let mut err = self.err_handler().struct_span_err(poly.span, let mut err = self.err_handler().struct_span_err(poly.span,
&format!("`?Trait` is not permitted in {}", where_)); &format!("`?Trait` is not permitted in {}", where_));
if is_trait { if is_trait {
@ -203,7 +203,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
} }
TyKind::ImplTrait(ref bounds) => { TyKind::ImplTrait(ref bounds) => {
if !bounds.iter() if !bounds.iter()
.any(|b| if let TraitTyParamBound(..) = *b { true } else { false }) { .any(|b| if let Trait(..) = *b { true } else { false }) {
self.err_handler().span_err(ty.span, "at least one trait must be specified"); self.err_handler().span_err(ty.span, "at least one trait must be specified");
} }
} }

View file

@ -1039,7 +1039,7 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
fn check_ty_param_bound(&mut self, fn check_ty_param_bound(&mut self,
ty_param_bound: &hir::ParamBound) { ty_param_bound: &hir::ParamBound) {
if let hir::TraitTyParamBound(ref trait_ref, _) = *ty_param_bound { if let hir::ParamBound::Trait(ref trait_ref, _) = *ty_param_bound {
if self.path_is_private_type(&trait_ref.trait_ref.path) { if self.path_is_private_type(&trait_ref.trait_ref.path) {
self.old_error_set.insert(trait_ref.trait_ref.ref_id); self.old_error_set.insert(trait_ref.trait_ref.ref_id);
} }

View file

@ -761,7 +761,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
// super-traits // super-traits
for super_bound in trait_refs.iter() { for super_bound in trait_refs.iter() {
let trait_ref = match *super_bound { let trait_ref = match *super_bound {
ast::TraitTyParamBound(ref trait_ref, _) => trait_ref, ast::Trait(ref trait_ref, _) => trait_ref,
ast::Outlives(..) => { ast::Outlives(..) => {
continue; continue;
} }
@ -1489,7 +1489,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
ast::GenericParamKind::Lifetime { .. } => {} ast::GenericParamKind::Lifetime { .. } => {}
ast::GenericParamKind::Type { ref default, .. } => { ast::GenericParamKind::Type { ref default, .. } => {
for bound in &param.bounds { for bound in &param.bounds {
if let ast::TraitTyParamBound(ref trait_ref, _) = *bound { if let ast::Trait(ref trait_ref, _) = *bound {
self.process_path(trait_ref.trait_ref.ref_id, &trait_ref.trait_ref.path) self.process_path(trait_ref.trait_ref.ref_id, &trait_ref.trait_ref.path)
} }
} }

View file

@ -1257,7 +1257,7 @@ fn is_unsized<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
// Try to find an unbound in bounds. // Try to find an unbound in bounds.
let mut unbound = None; let mut unbound = None;
for ab in ast_bounds { for ab in ast_bounds {
if let &hir::TraitTyParamBound(ref ptr, hir::TraitBoundModifier::Maybe) = ab { if let &hir::ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = ab {
if unbound.is_none() { if unbound.is_none() {
unbound = Some(ptr.trait_ref.clone()); unbound = Some(ptr.trait_ref.clone());
} else { } else {
@ -1482,7 +1482,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
for bound in bound_pred.bounds.iter() { for bound in bound_pred.bounds.iter() {
match bound { match bound {
&hir::ParamBound::TraitTyParamBound(ref poly_trait_ref, _) => { &hir::ParamBound::Trait(ref poly_trait_ref, _) => {
let mut projections = Vec::new(); let mut projections = Vec::new();
let trait_ref = let trait_ref =
@ -1591,22 +1591,16 @@ pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
let mut trait_bounds = vec![]; let mut trait_bounds = vec![];
for ast_bound in ast_bounds { for ast_bound in ast_bounds {
match *ast_bound { match *ast_bound {
hir::TraitTyParamBound(ref b, hir::TraitBoundModifier::None) => { hir::ParamBound::Trait(ref b, hir::TraitBoundModifier::None) => trait_bounds.push(b),
trait_bounds.push(b); hir::ParamBound::Trait(_, hir::TraitBoundModifier::Maybe) => {}
} hir::ParamBound::Outlives(ref l) => region_bounds.push(l),
hir::TraitTyParamBound(_, hir::TraitBoundModifier::Maybe) => {}
hir::Outlives(ref l) => {
region_bounds.push(l);
}
} }
} }
let mut projection_bounds = vec![]; let mut projection_bounds = vec![];
let mut trait_bounds: Vec<_> = trait_bounds.iter().map(|&bound| { let mut trait_bounds: Vec<_> = trait_bounds.iter().map(|&bound| {
astconv.instantiate_poly_trait_ref(bound, astconv.instantiate_poly_trait_ref(bound, param_ty, &mut projection_bounds)
param_ty,
&mut projection_bounds)
}).collect(); }).collect();
let region_bounds = region_bounds.into_iter().map(|r| { let region_bounds = region_bounds.into_iter().map(|r| {
@ -1640,7 +1634,7 @@ fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>,
-> Vec<ty::Predicate<'tcx>> -> Vec<ty::Predicate<'tcx>>
{ {
match *bound { match *bound {
hir::TraitTyParamBound(ref tr, hir::TraitBoundModifier::None) => { hir::ParamBound::Trait(ref tr, hir::TraitBoundModifier::None) => {
let mut projections = Vec::new(); let mut projections = Vec::new();
let pred = astconv.instantiate_poly_trait_ref(tr, let pred = astconv.instantiate_poly_trait_ref(tr,
param_ty, param_ty,
@ -1650,14 +1644,12 @@ fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>,
.chain(Some(pred.to_predicate())) .chain(Some(pred.to_predicate()))
.collect() .collect()
} }
hir::Outlives(ref lifetime) => { hir::ParamBound::Outlives(ref lifetime) => {
let region = astconv.ast_region_to_region(lifetime, None); let region = astconv.ast_region_to_region(lifetime, None);
let pred = ty::Binder::bind(ty::OutlivesPredicate(param_ty, region)); let pred = ty::Binder::bind(ty::OutlivesPredicate(param_ty, region));
vec![ty::Predicate::TypeOutlives(pred)] vec![ty::Predicate::TypeOutlives(pred)]
} }
hir::TraitTyParamBound(_, hir::TraitBoundModifier::Maybe) => { hir::ParamBound::Trait(_, hir::TraitBoundModifier::Maybe) => vec![],
Vec::new()
}
} }
} }

View file

@ -1510,8 +1510,8 @@ impl ParamBound {
impl Clean<ParamBound> for hir::ParamBound { impl Clean<ParamBound> for hir::ParamBound {
fn clean(&self, cx: &DocContext) -> ParamBound { fn clean(&self, cx: &DocContext) -> ParamBound {
match *self { match *self {
hir::Outlives(lt) => Outlives(lt.clean(cx)), hir::ParamBound::Outlives(lt) => Outlives(lt.clean(cx)),
hir::TraitTyParamBound(ref t, modifier) => TraitBound(t.clean(cx), modifier), hir::ParamBound::Trait(ref t, modifier) => TraitBound(t.clean(cx), modifier),
} }
} }
} }
@ -1624,7 +1624,7 @@ impl<'tcx> Clean<Option<Vec<ParamBound>>> for Substs<'tcx> {
fn clean(&self, cx: &DocContext) -> Option<Vec<ParamBound>> { fn clean(&self, cx: &DocContext) -> Option<Vec<ParamBound>> {
let mut v = Vec::new(); let mut v = Vec::new();
v.extend(self.regions().filter_map(|r| r.clean(cx)) v.extend(self.regions().filter_map(|r| r.clean(cx))
.map(Outlives)); .map(ParamBound::Outlives));
v.extend(self.types().map(|t| TraitBound(PolyTrait { v.extend(self.types().map(|t| TraitBound(PolyTrait {
trait_: t.clean(cx), trait_: t.clean(cx),
generic_params: Vec::new(), generic_params: Vec::new(),
@ -3080,7 +3080,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
inline::record_extern_fqn(cx, did, TypeKind::Trait); inline::record_extern_fqn(cx, did, TypeKind::Trait);
let mut typarams = vec![]; let mut typarams = vec![];
reg.clean(cx).map(|b| typarams.push(Outlives(b))); reg.clean(cx).map(|b| typarams.push(ParamBound::Outlives(b)));
for did in obj.auto_traits() { for did in obj.auto_traits() {
let empty = cx.tcx.intern_substs(&[]); let empty = cx.tcx.intern_substs(&[]);
let path = external_path(cx, &cx.tcx.item_name(did).as_str(), let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
@ -3137,7 +3137,9 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
tr tr
} else if let ty::Predicate::TypeOutlives(pred) = *predicate { } else if let ty::Predicate::TypeOutlives(pred) = *predicate {
// these should turn up at the end // these should turn up at the end
pred.skip_binder().1.clean(cx).map(|r| regions.push(Outlives(r))); pred.skip_binder().1.clean(cx).map(|r| {
regions.push(ParamBound::Outlives(r))
});
return None; return None;
} else { } else {
return None; return None;

View file

@ -283,14 +283,14 @@ pub enum TraitBoundModifier {
/// detects Copy, Send and Sync. /// detects Copy, Send and Sync.
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum ParamBound { pub enum ParamBound {
TraitTyParamBound(PolyTraitRef, TraitBoundModifier), Trait(PolyTraitRef, TraitBoundModifier),
Outlives(Lifetime) Outlives(Lifetime)
} }
impl ParamBound { impl ParamBound {
pub fn span(&self) -> Span { pub fn span(&self) -> Span {
match self { match self {
&TraitTyParamBound(ref t, ..) => t.span, &Trait(ref t, ..) => t.span,
&Outlives(ref l) => l.ident.span, &Outlives(ref l) => l.ident.span,
} }
} }
@ -930,7 +930,7 @@ impl Expr {
fn to_bound(&self) -> Option<ParamBound> { fn to_bound(&self) -> Option<ParamBound> {
match &self.node { match &self.node {
ExprKind::Path(None, path) => ExprKind::Path(None, path) =>
Some(TraitTyParamBound(PolyTraitRef::new(Vec::new(), path.clone(), self.span), Some(Trait(PolyTraitRef::new(Vec::new(), path.clone(), self.span),
TraitBoundModifier::None)), TraitBoundModifier::None)),
_ => None, _ => None,
} }

View file

@ -465,7 +465,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::ParamBound {
ast::TraitTyParamBound(self.poly_trait_ref(path.span, path), ast::TraitBoundModifier::None) ast::Trait(self.poly_trait_ref(path.span, path), ast::TraitBoundModifier::None)
} }
fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime { fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime {

View file

@ -678,8 +678,8 @@ 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: ParamBound, fld: &mut T) -> ParamBound where T: Folder {
match pb { match pb {
TraitTyParamBound(ty, modifier) => { Trait(ty, modifier) => {
TraitTyParamBound(fld.fold_poly_trait_ref(ty), modifier) Trait(fld.fold_poly_trait_ref(ty), modifier)
} }
Outlives(lifetime) => Outlives(noop_fold_lifetime(lifetime, fld)), Outlives(lifetime) => Outlives(noop_fold_lifetime(lifetime, fld)),
} }

View file

@ -10,7 +10,7 @@
use rustc_target::spec::abi::{self, Abi}; use rustc_target::spec::abi::{self, Abi};
use ast::{AngleBracketedArgs, ParenthesizedArgData, AttrStyle, BareFnTy}; use ast::{AngleBracketedArgs, ParenthesizedArgData, AttrStyle, BareFnTy};
use ast::{Outlives, TraitTyParamBound, TraitBoundModifier}; use ast::{Outlives, Trait, TraitBoundModifier};
use ast::Unsafety; use ast::Unsafety;
use ast::{Mod, AnonConst, Arg, Arm, Attribute, BindingMode, TraitItemKind}; use ast::{Mod, AnonConst, Arg, Arm, Attribute, BindingMode, TraitItemKind};
use ast::Block; use ast::Block;
@ -1444,7 +1444,7 @@ impl<'a> Parser<'a> {
TyKind::TraitObject(ref bounds, TraitObjectSyntax::None) TyKind::TraitObject(ref bounds, TraitObjectSyntax::None)
if maybe_bounds && bounds.len() == 1 && !trailing_plus => { if maybe_bounds && bounds.len() == 1 && !trailing_plus => {
let path = match bounds[0] { let path = match bounds[0] {
TraitTyParamBound(ref pt, ..) => pt.trait_ref.path.clone(), Trait(ref pt, ..) => pt.trait_ref.path.clone(),
_ => self.bug("unexpected lifetime bound"), _ => self.bug("unexpected lifetime bound"),
}; };
self.parse_remaining_bounds(Vec::new(), path, lo, true)? 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, fn parse_remaining_bounds(&mut self, generic_params: Vec<GenericParam>, path: ast::Path,
lo: Span, parse_plus: bool) -> PResult<'a, TyKind> { lo: Span, parse_plus: bool) -> PResult<'a, TyKind> {
let poly_trait_ref = PolyTraitRef::new(generic_params, path, lo.to(self.prev_span)); let poly_trait_ref = PolyTraitRef::new(generic_params, path, lo.to(self.prev_span));
let mut bounds = vec![TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)]; let mut bounds = vec![Trait(poly_trait_ref, TraitBoundModifier::None)];
if parse_plus { if parse_plus {
self.eat_plus(); // `+`, or `+=` gets split and `+` is discarded self.eat_plus(); // `+`, or `+=` gets split and `+` is discarded
bounds.append(&mut self.parse_ty_param_bounds()?); bounds.append(&mut self.parse_ty_param_bounds()?);
@ -4770,7 +4770,7 @@ impl<'a> Parser<'a> {
} else { } else {
TraitBoundModifier::None TraitBoundModifier::None
}; };
bounds.push(TraitTyParamBound(poly_trait, modifier)); bounds.push(Trait(poly_trait, modifier));
} }
} else { } else {
break break

View file

@ -12,7 +12,7 @@ pub use self::AnnNode::*;
use rustc_target::spec::abi::{self, Abi}; use rustc_target::spec::abi::{self, Abi};
use ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax}; use ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax};
use ast::{SelfKind, Outlives, TraitTyParamBound, TraitBoundModifier}; use ast::{SelfKind, Outlives, Trait, TraitBoundModifier};
use ast::{Attribute, MacDelimiter, GenericArg}; use ast::{Attribute, MacDelimiter, GenericArg};
use util::parser::{self, AssocOp, Fixity}; use util::parser::{self, AssocOp, Fixity};
use attr; use attr;
@ -1364,7 +1364,7 @@ impl<'a> State<'a> {
self.print_generic_params(&generics.params)?; self.print_generic_params(&generics.params)?;
let mut real_bounds = Vec::with_capacity(bounds.len()); let mut real_bounds = Vec::with_capacity(bounds.len());
for b in bounds.iter() { for b in bounds.iter() {
if let TraitTyParamBound(ref ptr, ast::TraitBoundModifier::Maybe) = *b { if let Trait(ref ptr, ast::TraitBoundModifier::Maybe) = *b {
self.s.space()?; self.s.space()?;
self.word_space("for ?")?; self.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?; self.print_trait_ref(&ptr.trait_ref)?;
@ -1390,7 +1390,7 @@ impl<'a> State<'a> {
let mut real_bounds = Vec::with_capacity(bounds.len()); let mut real_bounds = Vec::with_capacity(bounds.len());
// FIXME(durka) this seems to be some quite outdated syntax // FIXME(durka) this seems to be some quite outdated syntax
for b in bounds.iter() { for b in bounds.iter() {
if let TraitTyParamBound(ref ptr, ast::TraitBoundModifier::Maybe) = *b { if let Trait(ref ptr, ast::TraitBoundModifier::Maybe) = *b {
self.s.space()?; self.s.space()?;
self.word_space("for ?")?; self.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?; self.print_trait_ref(&ptr.trait_ref)?;
@ -2826,7 +2826,7 @@ impl<'a> State<'a> {
} }
match bound { match bound {
TraitTyParamBound(tref, modifier) => { Trait(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe { if modifier == &TraitBoundModifier::Maybe {
self.s.word("?")?; self.s.word("?")?;
} }

View file

@ -481,7 +481,7 @@ 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 ParamBound) { pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a ParamBound) {
match *bound { match *bound {
TraitTyParamBound(ref typ, ref modifier) => { Trait(ref typ, ref modifier) => {
visitor.visit_poly_trait_ref(typ, modifier); visitor.visit_poly_trait_ref(typ, modifier);
} }
Outlives(ref lifetime) => { Outlives(ref lifetime) => {