pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v ParamBound) {
match *bound {
- TraitTyParamBound(ref typ, modifier) => {
+ ParamBound::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),
}
}
let bounds = bounds
.iter()
.filter_map(|bound| match *bound {
- TraitTyParamBound(ref ty, TraitBoundModifier::None) => {
+ Trait(ref ty, TraitBoundModifier::None) => {
Some(self.lower_poly_trait_ref(ty, itctx))
}
- TraitTyParamBound(_, TraitBoundModifier::Maybe) => None,
+ Trait(_, TraitBoundModifier::Maybe) => None,
Outlives(ref lifetime) => {
if lifetime_bound.is_none() {
lifetime_bound = Some(self.lower_lifetime(lifetime));
itctx: ImplTraitContext,
) -> hir::ParamBound {
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_trait_bound_modifier(modifier),
),
- Outlives(ref lifetime) => {
- hir::Outlives(self.lower_lifetime(lifetime))
+ ParamBound::Outlives(ref lifetime) => {
+ hir::ParamBound::Outlives(self.lower_lifetime(lifetime))
}
}
}
for pred in &generics.where_clause.predicates {
if let WherePredicate::BoundPredicate(ref bound_pred) = *pred {
'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| {
this.diagnostic().span_err(
bound_pred.bounded_ty.span,
.filter_map(|bound| match *bound {
// Ignore `?Trait` bounds.
// Tthey were copied into type parameters already.
- TraitTyParamBound(_, TraitBoundModifier::Maybe) => None,
+ ParamBound::Trait(_, TraitBoundModifier::Maybe) => None,
_ => Some(this.lower_param_bound(
bound,
ImplTraitContext::Disallowed,
pub use self::PrimTy::*;
pub use self::Stmt_::*;
pub use self::Ty_::*;
-pub use self::ParamBound::*;
pub use self::UnOp::*;
pub use self::UnsafeSource::*;
pub use self::Visibility::{Public, Inherited};
/// detects Copy, Send and Sync.
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum ParamBound {
- TraitTyParamBound(PolyTraitRef, TraitBoundModifier),
+ Trait(PolyTraitRef, TraitBoundModifier),
Outlives(Lifetime),
}
impl ParamBound {
pub fn span(&self) -> Span {
match self {
- &TraitTyParamBound(ref t, ..) => t.span,
- &Outlives(ref l) => l.span,
+ &ParamBound::Trait(ref t, ..) => t.span,
+ &ParamBound::Outlives(ref l) => l.span,
}
}
}
use syntax_pos::{self, BytePos, FileName};
use hir;
-use hir::{PatKind, Outlives, TraitTyParamBound, TraitBoundModifier, RangeEnd};
+use hir::{PatKind, ParamBound, TraitBoundModifier, RangeEnd};
use hir::{GenericParam, GenericParamKind, GenericArg};
use std::cell::Cell;
self.print_generic_params(&generics.params)?;
let mut real_bounds = Vec::with_capacity(bounds.len());
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.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?;
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 TraitTyParamBound(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
+ if let ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
self.s.space()?;
self.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?;
}
match bound {
- TraitTyParamBound(tref, modifier) => {
+ ParamBound::Trait(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe {
self.s.word("?")?;
}
self.print_poly_trait_ref(tref)?;
}
- Outlives(lt) => {
+ ParamBound::Outlives(lt) => {
self.print_lifetime(lt)?;
}
}
let mut sep = ":";
for bound in ¶m.bounds {
match bound {
- hir::ParamBound::Outlives(lt) => {
+ ParamBound::Outlives(lt) => {
self.s.word(sep)?;
self.print_lifetime(lt)?;
sep = "+";
for (i, bound) in bounds.iter().enumerate() {
match bound {
- hir::ParamBound::Outlives(lt) => {
+ ParamBound::Outlives(lt) => {
self.print_lifetime(lt)?;
}
_ => bug!(),
});
impl_stable_hash_for!(enum hir::ParamBound {
- TraitTyParamBound(poly_trait_ref, trait_bound_modifier),
+ Trait(poly_trait_ref, trait_bound_modifier),
Outlives(lifetime)
});
) -> Vec<ObjectLifetimeDefault> {
fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::ParamBound]) {
for bound in bounds {
- if let hir::Outlives(ref lifetime) = *bound {
+ if let hir::ParamBound::Outlives(ref lifetime) = *bound {
set.insert(lifetime.name);
}
}
fn no_questions_in_bounds(&self, bounds: &ParamBounds, where_: &str, is_trait: bool) {
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,
&format!("`?Trait` is not permitted in {}", where_));
if is_trait {
}
TyKind::ImplTrait(ref bounds) => {
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");
}
}
fn check_ty_param_bound(&mut self,
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) {
self.old_error_set.insert(trait_ref.trait_ref.ref_id);
}
// super-traits
for super_bound in trait_refs.iter() {
let trait_ref = match *super_bound {
- ast::TraitTyParamBound(ref trait_ref, _) => trait_ref,
+ ast::Trait(ref trait_ref, _) => trait_ref,
ast::Outlives(..) => {
continue;
}
ast::GenericParamKind::Lifetime { .. } => {}
ast::GenericParamKind::Type { ref default, .. } => {
for bound in ¶m.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)
}
}
// Try to find an unbound in bounds.
let mut unbound = None;
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() {
unbound = Some(ptr.trait_ref.clone());
} else {
for bound in bound_pred.bounds.iter() {
match bound {
- &hir::ParamBound::TraitTyParamBound(ref poly_trait_ref, _) => {
+ &hir::ParamBound::Trait(ref poly_trait_ref, _) => {
let mut projections = Vec::new();
let trait_ref =
let mut trait_bounds = vec![];
for ast_bound in ast_bounds {
match *ast_bound {
- hir::TraitTyParamBound(ref b, hir::TraitBoundModifier::None) => {
- trait_bounds.push(b);
- }
- hir::TraitTyParamBound(_, hir::TraitBoundModifier::Maybe) => {}
- hir::Outlives(ref l) => {
- region_bounds.push(l);
- }
+ hir::ParamBound::Trait(ref b, hir::TraitBoundModifier::None) => trait_bounds.push(b),
+ hir::ParamBound::Trait(_, hir::TraitBoundModifier::Maybe) => {}
+ hir::ParamBound::Outlives(ref l) => region_bounds.push(l),
}
}
let mut projection_bounds = vec![];
let mut trait_bounds: Vec<_> = trait_bounds.iter().map(|&bound| {
- astconv.instantiate_poly_trait_ref(bound,
- param_ty,
- &mut projection_bounds)
+ astconv.instantiate_poly_trait_ref(bound, param_ty, &mut projection_bounds)
}).collect();
let region_bounds = region_bounds.into_iter().map(|r| {
-> Vec<ty::Predicate<'tcx>>
{
match *bound {
- hir::TraitTyParamBound(ref tr, hir::TraitBoundModifier::None) => {
+ hir::ParamBound::Trait(ref tr, hir::TraitBoundModifier::None) => {
let mut projections = Vec::new();
let pred = astconv.instantiate_poly_trait_ref(tr,
param_ty,
.chain(Some(pred.to_predicate()))
.collect()
}
- hir::Outlives(ref lifetime) => {
+ hir::ParamBound::Outlives(ref lifetime) => {
let region = astconv.ast_region_to_region(lifetime, None);
let pred = ty::Binder::bind(ty::OutlivesPredicate(param_ty, region));
vec![ty::Predicate::TypeOutlives(pred)]
}
- hir::TraitTyParamBound(_, hir::TraitBoundModifier::Maybe) => {
- Vec::new()
- }
+ hir::ParamBound::Trait(_, hir::TraitBoundModifier::Maybe) => vec![],
}
}
impl Clean<ParamBound> for hir::ParamBound {
fn clean(&self, cx: &DocContext) -> ParamBound {
match *self {
- hir::Outlives(lt) => Outlives(lt.clean(cx)),
- hir::TraitTyParamBound(ref t, modifier) => TraitBound(t.clean(cx), modifier),
+ hir::ParamBound::Outlives(lt) => Outlives(lt.clean(cx)),
+ hir::ParamBound::Trait(ref t, modifier) => TraitBound(t.clean(cx), modifier),
}
}
}
fn clean(&self, cx: &DocContext) -> Option<Vec<ParamBound>> {
let mut v = Vec::new();
v.extend(self.regions().filter_map(|r| r.clean(cx))
- .map(Outlives));
+ .map(ParamBound::Outlives));
v.extend(self.types().map(|t| TraitBound(PolyTrait {
trait_: t.clean(cx),
generic_params: Vec::new(),
inline::record_extern_fqn(cx, did, TypeKind::Trait);
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() {
let empty = cx.tcx.intern_substs(&[]);
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
tr
} else if let ty::Predicate::TypeOutlives(pred) = *predicate {
// 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;
} else {
return None;
/// detects Copy, Send and Sync.
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum ParamBound {
- TraitTyParamBound(PolyTraitRef, TraitBoundModifier),
+ Trait(PolyTraitRef, TraitBoundModifier),
Outlives(Lifetime)
}
impl ParamBound {
pub fn span(&self) -> Span {
match self {
- &TraitTyParamBound(ref t, ..) => t.span,
+ &Trait(ref t, ..) => t.span,
&Outlives(ref l) => l.ident.span,
}
}
fn to_bound(&self) -> Option<ParamBound> {
match &self.node {
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)),
_ => None,
}
}
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 {
pub fn noop_fold_param_bound<T>(pb: ParamBound, fld: &mut T) -> ParamBound where T: Folder {
match pb {
- TraitTyParamBound(ty, modifier) => {
- TraitTyParamBound(fld.fold_poly_trait_ref(ty), modifier)
+ Trait(ty, modifier) => {
+ Trait(fld.fold_poly_trait_ref(ty), modifier)
}
Outlives(lifetime) => Outlives(noop_fold_lifetime(lifetime, fld)),
}
use rustc_target::spec::abi::{self, Abi};
use ast::{AngleBracketedArgs, ParenthesizedArgData, AttrStyle, BareFnTy};
-use ast::{Outlives, TraitTyParamBound, TraitBoundModifier};
+use ast::{Outlives, Trait, TraitBoundModifier};
use ast::Unsafety;
use ast::{Mod, AnonConst, Arg, Arm, Attribute, BindingMode, TraitItemKind};
use ast::Block;
TyKind::TraitObject(ref bounds, TraitObjectSyntax::None)
if maybe_bounds && bounds.len() == 1 && !trailing_plus => {
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.parse_remaining_bounds(Vec::new(), path, lo, true)?
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![TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)];
+ let mut bounds = vec![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()?);
} else {
TraitBoundModifier::None
};
- bounds.push(TraitTyParamBound(poly_trait, modifier));
+ bounds.push(Trait(poly_trait, modifier));
}
} else {
break
use rustc_target::spec::abi::{self, Abi};
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 util::parser::{self, AssocOp, Fixity};
use attr;
self.print_generic_params(&generics.params)?;
let mut real_bounds = Vec::with_capacity(bounds.len());
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.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?;
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 TraitTyParamBound(ref ptr, ast::TraitBoundModifier::Maybe) = *b {
+ if let Trait(ref ptr, ast::TraitBoundModifier::Maybe) = *b {
self.s.space()?;
self.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?;
}
match bound {
- TraitTyParamBound(tref, modifier) => {
+ Trait(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe {
self.s.word("?")?;
}
pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a ParamBound) {
match *bound {
- TraitTyParamBound(ref typ, ref modifier) => {
+ Trait(ref typ, ref modifier) => {
visitor.visit_poly_trait_ref(typ, modifier);
}
Outlives(ref lifetime) => {