1
Fork 0

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

@ -314,7 +314,7 @@ pub trait Visitor<'v> : Sized {
fn visit_trait_ref(&mut self, t: &'v TraitRef) {
walk_trait_ref(self, t)
}
fn visit_param_bound(&mut self, bounds: &'v ParamBound) {
fn visit_param_bound(&mut self, bounds: &'v GenericBound) {
walk_param_bound(self, bounds)
}
fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: TraitBoundModifier) {
@ -731,12 +731,12 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v
walk_list!(visitor, visit_attribute, &foreign_item.attrs);
}
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 GenericBound) {
match *bound {
ParamBound::Trait(ref typ, modifier) => {
GenericBound::Trait(ref typ, modifier) => {
visitor.visit_poly_trait_ref(typ, modifier);
}
ParamBound::Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
GenericBound::Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
}
}

View file

@ -1285,7 +1285,7 @@ impl<'a> LoweringContext<'a> {
&mut self,
exist_ty_id: NodeId,
parent_index: DefIndex,
bounds: &hir::ParamBounds,
bounds: &hir::GenericBounds,
) -> (HirVec<hir::Lifetime>, HirVec<hir::GenericParam>) {
// This visitor walks over impl trait bounds and creates defs for all lifetimes which
// appear in the bounds, excluding lifetimes that are created within the bounds.
@ -1873,16 +1873,16 @@ impl<'a> LoweringContext<'a> {
fn lower_param_bound(
&mut self,
tpb: &ParamBound,
tpb: &GenericBound,
itctx: ImplTraitContext,
) -> hir::ParamBound {
) -> hir::GenericBound {
match *tpb {
ParamBound::Trait(ref ty, modifier) => hir::ParamBound::Trait(
GenericBound::Trait(ref ty, modifier) => hir::GenericBound::Trait(
self.lower_poly_trait_ref(ty, itctx),
self.lower_trait_bound_modifier(modifier),
),
ParamBound::Outlives(ref lifetime) => {
hir::ParamBound::Outlives(self.lower_lifetime(lifetime))
GenericBound::Outlives(ref lifetime) => {
hir::GenericBound::Outlives(self.lower_lifetime(lifetime))
}
}
}
@ -1925,7 +1925,7 @@ impl<'a> LoweringContext<'a> {
fn lower_generic_params(
&mut self,
params: &Vec<GenericParam>,
add_bounds: &NodeMap<Vec<ParamBound>>,
add_bounds: &NodeMap<Vec<GenericBound>>,
itctx: ImplTraitContext,
) -> hir::HirVec<hir::GenericParam> {
params.iter().map(|param| self.lower_generic_param(param, add_bounds, itctx)).collect()
@ -1933,7 +1933,7 @@ impl<'a> LoweringContext<'a> {
fn lower_generic_param(&mut self,
param: &GenericParam,
add_bounds: &NodeMap<Vec<ParamBound>>,
add_bounds: &NodeMap<Vec<GenericBound>>,
itctx: ImplTraitContext)
-> hir::GenericParam {
let mut bounds = self.lower_param_bounds(&param.bounds, itctx);
@ -2013,7 +2013,7 @@ impl<'a> LoweringContext<'a> {
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 ParamBound::Trait(_, TraitBoundModifier::Maybe) = *bound {
if let GenericBound::Trait(_, TraitBoundModifier::Maybe) = *bound {
let report_error = |this: &mut Self| {
this.diagnostic().span_err(
bound_pred.bounded_ty.span,
@ -2098,7 +2098,7 @@ impl<'a> LoweringContext<'a> {
.filter_map(|bound| match *bound {
// Ignore `?Trait` bounds.
// Tthey were copied into type parameters already.
ParamBound::Trait(_, TraitBoundModifier::Maybe) => None,
GenericBound::Trait(_, TraitBoundModifier::Maybe) => None,
_ => Some(this.lower_param_bound(
bound,
ImplTraitContext::Disallowed,
@ -2217,8 +2217,8 @@ impl<'a> LoweringContext<'a> {
}
}
fn lower_param_bounds(&mut self, bounds: &[ParamBound], itctx: ImplTraitContext)
-> hir::ParamBounds {
fn lower_param_bounds(&mut self, bounds: &[GenericBound], itctx: ImplTraitContext)
-> hir::GenericBounds {
bounds.iter().map(|bound| self.lower_param_bound(bound, itctx)).collect()
}

View file

@ -443,21 +443,21 @@ 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 {
&ParamBound::Trait(ref t, ..) => t.span,
&ParamBound::Outlives(ref l) => l.span,
&GenericBound::Trait(ref t, ..) => t.span,
&GenericBound::Outlives(ref l) => l.span,
}
}
}
pub type ParamBounds = HirVec<ParamBound>;
pub type GenericBounds = HirVec<GenericBound>;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum GenericParamKind {
@ -479,7 +479,7 @@ pub struct GenericParam {
pub id: NodeId,
pub name: ParamName,
pub attrs: HirVec<Attribute>,
pub bounds: ParamBounds,
pub bounds: GenericBounds,
pub span: Span,
pub pure_wrt_drop: bool,
@ -588,7 +588,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, e.g. `'a: 'b+'c`
@ -596,7 +596,7 @@ pub struct WhereBoundPredicate {
pub struct WhereRegionPredicate {
pub span: Span,
pub lifetime: Lifetime,
pub bounds: ParamBounds,
pub bounds: GenericBounds,
}
/// An equality predicate (unsupported), e.g. `T=int`
@ -1555,7 +1555,7 @@ pub enum TraitItemKind {
Method(MethodSig, TraitMethod),
/// An associated type with (possibly empty) bounds and optional concrete
/// type
Type(ParamBounds, Option<P<Ty>>),
Type(GenericBounds, Option<P<Ty>>),
}
// The bodies for items are stored "out of line", in a separate
@ -1640,7 +1640,7 @@ pub struct BareFnTy {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct ExistTy {
pub generics: Generics,
pub bounds: ParamBounds,
pub bounds: GenericBounds,
pub impl_trait_fn: Option<DefId>,
}
@ -2049,9 +2049,9 @@ pub enum Item_ {
/// A union definition, e.g. `union Foo<A, B> {x: A, y: B}`
ItemUnion(VariantData, Generics),
/// Represents a Trait Declaration
ItemTrait(IsAuto, Unsafety, Generics, ParamBounds, HirVec<TraitItemRef>),
ItemTrait(IsAuto, Unsafety, Generics, GenericBounds, HirVec<TraitItemRef>),
/// Represents a Trait Alias Declaration
ItemTraitAlias(Generics, ParamBounds),
ItemTraitAlias(Generics, GenericBounds),
/// An implementation, eg `impl<A> Trait for Foo { .. }`
ItemImpl(Unsafety,

View file

@ -24,7 +24,7 @@ use syntax::util::parser::{self, AssocOp, Fixity};
use syntax_pos::{self, BytePos, FileName};
use hir;
use hir::{PatKind, ParamBound, TraitBoundModifier, RangeEnd};
use hir::{PatKind, GenericBound, TraitBoundModifier, RangeEnd};
use hir::{GenericParam, GenericParamKind, GenericArg};
use std::cell::Cell;
@ -514,7 +514,7 @@ impl<'a> State<'a> {
fn print_associated_type(&mut self,
name: ast::Name,
bounds: Option<&hir::ParamBounds>,
bounds: Option<&hir::GenericBounds>,
ty: Option<&hir::Ty>)
-> io::Result<()> {
self.word_space("type")?;
@ -740,7 +740,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 ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
if let GenericBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
self.s.space()?;
self.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?;
@ -766,7 +766,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 ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
if let GenericBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
self.s.space()?;
self.word_space("for ?")?;
self.print_trait_ref(&ptr.trait_ref)?;
@ -2071,7 +2071,7 @@ impl<'a> State<'a> {
}
}
pub fn print_bounds(&mut self, prefix: &str, bounds: &[hir::ParamBound]) -> io::Result<()> {
pub fn print_bounds(&mut self, prefix: &str, bounds: &[hir::GenericBound]) -> io::Result<()> {
if !bounds.is_empty() {
self.s.word(prefix)?;
let mut first = true;
@ -2086,13 +2086,13 @@ impl<'a> State<'a> {
}
match bound {
ParamBound::Trait(tref, modifier) => {
GenericBound::Trait(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe {
self.s.word("?")?;
}
self.print_poly_trait_ref(tref)?;
}
ParamBound::Outlives(lt) => {
GenericBound::Outlives(lt) => {
self.print_lifetime(lt)?;
}
}
@ -2121,7 +2121,7 @@ impl<'a> State<'a> {
let mut sep = ":";
for bound in &param.bounds {
match bound {
ParamBound::Outlives(lt) => {
GenericBound::Outlives(lt) => {
self.s.word(sep)?;
self.print_lifetime(lt)?;
sep = "+";
@ -2181,7 +2181,7 @@ impl<'a> State<'a> {
for (i, bound) in bounds.iter().enumerate() {
match bound {
ParamBound::Outlives(lt) => {
GenericBound::Outlives(lt) => {
self.print_lifetime(lt)?;
}
_ => bug!(),

View file

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

View file

@ -1250,9 +1250,9 @@ fn object_lifetime_defaults_for_item(
tcx: TyCtxt<'_, '_, '_>,
generics: &hir::Generics,
) -> Vec<ObjectLifetimeDefault> {
fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::ParamBound]) {
fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::GenericBound]) {
for bound in bounds {
if let hir::ParamBound::Outlives(ref lifetime) = *bound {
if let hir::GenericBound::Outlives(ref lifetime) = *bound {
set.insert(lifetime.name);
}
}
@ -2280,7 +2280,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
for bound in &lifetime_i.bounds {
match bound {
hir::ParamBound::Outlives(lt) => match lt.name {
hir::GenericBound::Outlives(lt) => match lt.name {
hir::LifetimeName::Underscore => {
let mut err = struct_span_err!(
self.tcx.sess,

View file

@ -99,7 +99,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: &GenericBounds, where_: &str, is_trait: bool) {
for bound in bounds {
if let Trait(ref poly, TraitBoundModifier::Maybe) = *bound {
let mut err = self.err_handler().struct_span_err(poly.span,

View file

@ -203,8 +203,8 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
hir_visit::walk_impl_item(self, ii)
}
fn visit_param_bound(&mut self, bounds: &'v hir::ParamBound) {
self.record("ParamBound", Id::None, bounds);
fn visit_param_bound(&mut self, bounds: &'v hir::GenericBound) {
self.record("GenericBound", Id::None, bounds);
hir_visit::walk_param_bound(self, bounds)
}
@ -322,8 +322,8 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
ast_visit::walk_impl_item(self, ii)
}
fn visit_param_bound(&mut self, bounds: &'v ast::ParamBound) {
self.record("ParamBound", Id::None, bounds);
fn visit_param_bound(&mut self, bounds: &'v ast::GenericBound) {
self.record("GenericBound", Id::None, bounds);
ast_visit::walk_param_bound(self, bounds)
}

View file

@ -1038,8 +1038,8 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
}
fn check_ty_param_bound(&mut self,
ty_param_bound: &hir::ParamBound) {
if let hir::ParamBound::Trait(ref trait_ref, _) = *ty_param_bound {
ty_param_bound: &hir::GenericBound) {
if let hir::GenericBound::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);
}

View file

@ -718,7 +718,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
&mut self,
item: &'l ast::Item,
generics: &'l ast::Generics,
trait_refs: &'l ast::ParamBounds,
trait_refs: &'l ast::GenericBounds,
methods: &'l [ast::TraitItem],
) {
let name = item.ident.to_string();

View file

@ -104,7 +104,7 @@ pub fn assoc_const_signature(
pub fn assoc_type_signature(
id: NodeId,
ident: ast::Ident,
bounds: Option<&ast::ParamBounds>,
bounds: Option<&ast::GenericBounds>,
default: Option<&ast::Ty>,
scx: &SaveContext,
) -> Option<Signature> {
@ -629,7 +629,7 @@ impl Sig for ast::Generics {
ast::GenericParamKind::Lifetime { .. } => {
let bounds = param.bounds.iter()
.map(|bound| match bound {
ast::ParamBound::Outlives(lt) => lt.ident.to_string(),
ast::GenericBound::Outlives(lt) => lt.ident.to_string(),
_ => panic!(),
})
.collect::<Vec<_>>()
@ -841,7 +841,7 @@ fn name_and_generics(
fn make_assoc_type_signature(
id: NodeId,
ident: ast::Ident,
bounds: Option<&ast::ParamBounds>,
bounds: Option<&ast::GenericBounds>,
default: Option<&ast::Ty>,
scx: &SaveContext,
) -> Result {

View file

@ -1249,7 +1249,7 @@ fn impl_polarity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Is it marked with ?Sized
fn is_unsized<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
ast_bounds: &[hir::ParamBound],
ast_bounds: &[hir::GenericBound],
span: Span) -> bool
{
let tcx = astconv.tcx();
@ -1257,7 +1257,7 @@ fn is_unsized<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
// Try to find an unbound in bounds.
let mut unbound = None;
for ab in ast_bounds {
if let &hir::ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = ab {
if let &hir::GenericBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = ab {
if unbound.is_none() {
unbound = Some(ptr.trait_ref.clone());
} else {
@ -1444,7 +1444,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
match param.kind {
GenericParamKind::Lifetime { .. } => {
param.bounds.iter().for_each(|bound| match bound {
hir::ParamBound::Outlives(lt) => {
hir::GenericBound::Outlives(lt) => {
let bound = AstConv::ast_region_to_region(&icx, &lt, None);
let outlives = ty::Binder::bind(ty::OutlivesPredicate(region, bound));
predicates.push(outlives.to_predicate());
@ -1482,7 +1482,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
for bound in bound_pred.bounds.iter() {
match bound {
&hir::ParamBound::Trait(ref poly_trait_ref, _) => {
&hir::GenericBound::Trait(ref poly_trait_ref, _) => {
let mut projections = Vec::new();
let trait_ref =
@ -1498,7 +1498,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
&hir::ParamBound::Outlives(ref lifetime) => {
&hir::GenericBound::Outlives(ref lifetime) => {
let region = AstConv::ast_region_to_region(&icx,
lifetime,
None);
@ -1513,7 +1513,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let r1 = AstConv::ast_region_to_region(&icx, &region_pred.lifetime, None);
for bound in &region_pred.bounds {
let r2 = match bound {
hir::ParamBound::Outlives(lt) => {
hir::GenericBound::Outlives(lt) => {
AstConv::ast_region_to_region(&icx, lt, None)
}
_ => bug!(),
@ -1582,7 +1582,7 @@ pub enum SizedByDefault { Yes, No, }
/// built-in trait (formerly known as kind): Send.
pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
param_ty: Ty<'tcx>,
ast_bounds: &[hir::ParamBound],
ast_bounds: &[hir::GenericBound],
sized_by_default: SizedByDefault,
span: Span)
-> Bounds<'tcx>
@ -1591,9 +1591,9 @@ pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
let mut trait_bounds = vec![];
for ast_bound in ast_bounds {
match *ast_bound {
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),
hir::GenericBound::Trait(ref b, hir::TraitBoundModifier::None) => trait_bounds.push(b),
hir::GenericBound::Trait(_, hir::TraitBoundModifier::Maybe) => {}
hir::GenericBound::Outlives(ref l) => region_bounds.push(l),
}
}
@ -1623,18 +1623,18 @@ pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
}
}
/// Converts a specific ParamBound from the AST into a set of
/// Converts a specific GenericBound from the AST into a set of
/// predicates that apply to the self-type. A vector is returned
/// because this can be anywhere from 0 predicates (`T:?Sized` adds no
/// predicates) to 1 (`T:Foo`) to many (`T:Bar<X=i32>` adds `T:Bar`
/// and `<T as Bar>::X == i32`).
fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>,
param_ty: Ty<'tcx>,
bound: &hir::ParamBound)
bound: &hir::GenericBound)
-> Vec<ty::Predicate<'tcx>>
{
match *bound {
hir::ParamBound::Trait(ref tr, hir::TraitBoundModifier::None) => {
hir::GenericBound::Trait(ref tr, hir::TraitBoundModifier::None) => {
let mut projections = Vec::new();
let pred = astconv.instantiate_poly_trait_ref(tr,
param_ty,
@ -1644,12 +1644,12 @@ fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>,
.chain(Some(pred.to_predicate()))
.collect()
}
hir::ParamBound::Outlives(ref lifetime) => {
hir::GenericBound::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::ParamBound::Trait(_, hir::TraitBoundModifier::Maybe) => vec![],
hir::GenericBound::Trait(_, hir::TraitBoundModifier::Maybe) => vec![],
}
}

View file

@ -486,8 +486,8 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
.iter()
.flat_map(|(name, lifetime)| {
let empty = Vec::new();
let bounds: FxHashSet<ParamBound> = finished.get(name).unwrap_or(&empty).iter()
.map(|region| ParamBound::Outlives(self.get_lifetime(region, names_map)))
let bounds: FxHashSet<GenericBound> = finished.get(name).unwrap_or(&empty).iter()
.map(|region| GenericBound::Outlives(self.get_lifetime(region, names_map)))
.collect();
if bounds.is_empty() {
@ -533,9 +533,9 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
fn make_final_bounds<'b, 'c, 'cx>(
&self,
ty_to_bounds: FxHashMap<Type, FxHashSet<ParamBound>>,
ty_to_bounds: FxHashMap<Type, FxHashSet<GenericBound>>,
ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)>,
lifetime_to_bounds: FxHashMap<Lifetime, FxHashSet<ParamBound>>,
lifetime_to_bounds: FxHashMap<Lifetime, FxHashSet<GenericBound>>,
) -> Vec<WherePredicate> {
ty_to_bounds
.into_iter()
@ -586,7 +586,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
}
_ => panic!("Unexpected data: {:?}, {:?}", ty, data),
};
bounds.insert(ParamBound::TraitBound(
bounds.insert(GenericBound::TraitBound(
PolyTrait {
trait_: new_ty,
generic_params: poly_trait.generic_params,
@ -729,7 +729,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
// later
let is_fn = match &mut b {
&mut ParamBound::TraitBound(ref mut p, _) => {
&mut GenericBound::TraitBound(ref mut p, _) => {
// Insert regions into the for_generics hash map first, to ensure
// that we don't end up with duplicate bounds (e.g. for<'b, 'b>)
for_generics.extend(p.generic_params.clone());
@ -823,7 +823,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
.entry(*ty.clone())
.or_insert_with(|| FxHashSet());
bounds.insert(ParamBound::TraitBound(
bounds.insert(GenericBound::TraitBound(
PolyTrait {
trait_: Type::ResolvedPath {
path: new_trait_path,
@ -840,7 +840,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
// that we don't see a
// duplicate bound like `T: Iterator + Iterator<Item=u8>`
// on the docs page.
bounds.remove(&ParamBound::TraitBound(
bounds.remove(&GenericBound::TraitBound(
PolyTrait {
trait_: *trait_.clone(),
generic_params: Vec::new(),
@ -874,7 +874,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
default.take();
let generic_ty = Type::Generic(param.name.clone());
if !has_sized.contains(&generic_ty) {
bounds.insert(0, ParamBound::maybe_sized(self.cx));
bounds.insert(0, GenericBound::maybe_sized(self.cx));
}
}
GenericParamDefKind::Lifetime => {}
@ -908,7 +908,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
// both for visual consistency between 'rustdoc' runs, and to
// make writing tests much easier
#[inline]
fn sort_where_bounds(&self, mut bounds: &mut Vec<ParamBound>) {
fn sort_where_bounds(&self, mut bounds: &mut Vec<GenericBound>) {
// We should never have identical bounds - and if we do,
// they're visually identical as well. Therefore, using
// an unstable sort is fine.
@ -928,7 +928,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
// to end users, it makes writing tests much more difficult, as predicates
// can appear in any order in the final result.
//
// To solve this problem, we sort WherePredicates and ParamBounds
// To solve this problem, we sort WherePredicates and GenericBounds
// by their Debug string. The thing to keep in mind is that we don't really
// care what the final order is - we're synthesizing an impl or bound
// ourselves, so any order can be considered equally valid. By sorting the
@ -938,7 +938,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
// Using the Debug impementation for sorting prevents us from needing to
// write quite a bit of almost entirely useless code (e.g. how should two
// Types be sorted relative to each other). It also allows us to solve the
// problem for both WherePredicates and ParamBounds at the same time. This
// problem for both WherePredicates and GenericBounds at the same time. This
// approach is probably somewhat slower, but the small number of items
// involved (impls rarely have more than a few bounds) means that it
// shouldn't matter in practice.

View file

@ -474,7 +474,7 @@ fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean:
} if *s == "Self" => {
bounds.retain(|bound| {
match *bound {
clean::ParamBound::TraitBound(clean::PolyTrait {
clean::GenericBound::TraitBound(clean::PolyTrait {
trait_: clean::ResolvedPath { did, .. },
..
}, _) => did != trait_did,
@ -505,7 +505,7 @@ fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean:
/// the metadata for a crate, so we want to separate those out and create a new
/// list of explicit supertrait bounds to render nicely.
fn separate_supertrait_bounds(mut g: clean::Generics)
-> (clean::Generics, Vec<clean::ParamBound>) {
-> (clean::Generics, Vec<clean::GenericBound>) {
let mut ty_bounds = Vec::new();
g.where_predicates.retain(|pred| {
match *pred {

View file

@ -14,7 +14,7 @@
pub use self::Type::*;
pub use self::Mutability::*;
pub use self::ItemEnum::*;
pub use self::ParamBound::*;
pub use self::GenericBound::*;
pub use self::SelfTy::*;
pub use self::FunctionRetTy::*;
pub use self::Visibility::{Public, Inherited};
@ -532,7 +532,7 @@ pub enum ItemEnum {
MacroItem(Macro),
PrimitiveItem(PrimitiveType),
AssociatedConstItem(Type, Option<String>),
AssociatedTypeItem(Vec<ParamBound>, Option<Type>),
AssociatedTypeItem(Vec<GenericBound>, Option<Type>),
/// An item that has been stripped by a rustdoc pass
StrippedItem(Box<ItemEnum>),
KeywordItem(String),
@ -1458,13 +1458,13 @@ impl Clean<Attributes> for [ast::Attribute] {
}
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
pub enum ParamBound {
pub enum GenericBound {
TraitBound(PolyTrait, hir::TraitBoundModifier),
Outlives(Lifetime),
}
impl ParamBound {
fn maybe_sized(cx: &DocContext) -> ParamBound {
impl GenericBound {
fn maybe_sized(cx: &DocContext) -> GenericBound {
let did = cx.tcx.require_lang_item(lang_items::SizedTraitLangItem);
let empty = cx.tcx.intern_substs(&[]);
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
@ -1483,7 +1483,7 @@ impl ParamBound {
fn is_sized_bound(&self, cx: &DocContext) -> bool {
use rustc::hir::TraitBoundModifier as TBM;
if let ParamBound::TraitBound(PolyTrait { ref trait_, .. }, TBM::None) = *self {
if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, TBM::None) = *self {
if trait_.def_id() == cx.tcx.lang_items().sized_trait() {
return true;
}
@ -1492,7 +1492,7 @@ impl ParamBound {
}
fn get_poly_trait(&self) -> Option<PolyTrait> {
if let ParamBound::TraitBound(ref p, _) = *self {
if let GenericBound::TraitBound(ref p, _) = *self {
return Some(p.clone())
}
None
@ -1500,18 +1500,18 @@ impl ParamBound {
fn get_trait_type(&self) -> Option<Type> {
if let ParamBound::TraitBound(PolyTrait { ref trait_, .. }, _) = *self {
if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, _) = *self {
return Some(trait_.clone());
}
None
}
}
impl Clean<ParamBound> for hir::ParamBound {
fn clean(&self, cx: &DocContext) -> ParamBound {
impl Clean<GenericBound> for hir::GenericBound {
fn clean(&self, cx: &DocContext) -> GenericBound {
match *self {
hir::ParamBound::Outlives(lt) => Outlives(lt.clean(cx)),
hir::ParamBound::Trait(ref t, modifier) => TraitBound(t.clean(cx), modifier),
hir::GenericBound::Outlives(lt) => Outlives(lt.clean(cx)),
hir::GenericBound::Trait(ref t, modifier) => TraitBound(t.clean(cx), modifier),
}
}
}
@ -1570,8 +1570,8 @@ fn external_path(cx: &DocContext, name: &str, trait_did: Option<DefId>, has_self
}
}
impl<'a, 'tcx> Clean<ParamBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>) {
fn clean(&self, cx: &DocContext) -> ParamBound {
impl<'a, 'tcx> Clean<GenericBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>) {
fn clean(&self, cx: &DocContext) -> GenericBound {
let (trait_ref, ref bounds) = *self;
inline::record_extern_fqn(cx, trait_ref.def_id, TypeKind::Trait);
let path = external_path(cx, &cx.tcx.item_name(trait_ref.def_id).as_str(),
@ -1614,17 +1614,17 @@ impl<'a, 'tcx> Clean<ParamBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>)
}
}
impl<'tcx> Clean<ParamBound> for ty::TraitRef<'tcx> {
fn clean(&self, cx: &DocContext) -> ParamBound {
impl<'tcx> Clean<GenericBound> for ty::TraitRef<'tcx> {
fn clean(&self, cx: &DocContext) -> GenericBound {
(self, vec![]).clean(cx)
}
}
impl<'tcx> Clean<Option<Vec<ParamBound>>> for Substs<'tcx> {
fn clean(&self, cx: &DocContext) -> Option<Vec<ParamBound>> {
impl<'tcx> Clean<Option<Vec<GenericBound>>> for Substs<'tcx> {
fn clean(&self, cx: &DocContext) -> Option<Vec<GenericBound>> {
let mut v = Vec::new();
v.extend(self.regions().filter_map(|r| r.clean(cx))
.map(ParamBound::Outlives));
.map(GenericBound::Outlives));
v.extend(self.types().map(|t| TraitBound(PolyTrait {
trait_: t.clean(cx),
generic_params: Vec::new(),
@ -1674,7 +1674,7 @@ impl Clean<Lifetime> for hir::GenericParam {
hir::GenericParamKind::Lifetime { .. } => {
if self.bounds.len() > 0 {
let mut bounds = self.bounds.iter().map(|bound| match bound {
hir::ParamBound::Outlives(lt) => lt,
hir::GenericBound::Outlives(lt) => lt,
_ => panic!(),
});
let name = bounds.next().unwrap().name.name();
@ -1720,8 +1720,8 @@ impl Clean<Option<Lifetime>> for ty::RegionKind {
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
pub enum WherePredicate {
BoundPredicate { ty: Type, bounds: Vec<ParamBound> },
RegionPredicate { lifetime: Lifetime, bounds: Vec<ParamBound> },
BoundPredicate { ty: Type, bounds: Vec<GenericBound> },
RegionPredicate { lifetime: Lifetime, bounds: Vec<GenericBound> },
EqPredicate { lhs: Type, rhs: Type },
}
@ -1791,7 +1791,7 @@ impl<'tcx> Clean<WherePredicate> for ty::OutlivesPredicate<ty::Region<'tcx>, ty:
let ty::OutlivesPredicate(ref a, ref b) = *self;
WherePredicate::RegionPredicate {
lifetime: a.clean(cx).unwrap(),
bounds: vec![ParamBound::Outlives(b.clean(cx).unwrap())]
bounds: vec![GenericBound::Outlives(b.clean(cx).unwrap())]
}
}
}
@ -1802,7 +1802,7 @@ impl<'tcx> Clean<WherePredicate> for ty::OutlivesPredicate<Ty<'tcx>, ty::Region<
WherePredicate::BoundPredicate {
ty: ty.clean(cx),
bounds: vec![ParamBound::Outlives(lt.clean(cx).unwrap())]
bounds: vec![GenericBound::Outlives(lt.clean(cx).unwrap())]
}
}
}
@ -1819,8 +1819,8 @@ impl<'tcx> Clean<WherePredicate> for ty::ProjectionPredicate<'tcx> {
impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
fn clean(&self, cx: &DocContext) -> Type {
let trait_ = match self.trait_ref(cx.tcx).clean(cx) {
ParamBound::TraitBound(t, _) => t.trait_,
ParamBound::Outlives(_) => panic!("cleaning a trait got a lifetime"),
GenericBound::TraitBound(t, _) => t.trait_,
GenericBound::Outlives(_) => panic!("cleaning a trait got a lifetime"),
};
Type::QPath {
name: cx.tcx.associated_item(self.item_def_id).name.clean(cx),
@ -1835,7 +1835,7 @@ pub enum GenericParamDefKind {
Lifetime,
Type {
did: DefId,
bounds: Vec<ParamBound>,
bounds: Vec<GenericBound>,
default: Option<Type>,
synthetic: Option<hir::SyntheticTyParamKind>,
},
@ -1893,7 +1893,7 @@ impl Clean<GenericParamDef> for hir::GenericParam {
hir::GenericParamKind::Lifetime { .. } => {
let name = if self.bounds.len() > 0 {
let mut bounds = self.bounds.iter().map(|bound| match bound {
hir::ParamBound::Outlives(lt) => lt,
hir::GenericBound::Outlives(lt) => lt,
_ => panic!(),
});
let name = bounds.next().unwrap().name.name();
@ -2049,7 +2049,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
if !sized_params.contains(&tp.name) {
where_predicates.push(WP::BoundPredicate {
ty: Type::Generic(tp.name.clone()),
bounds: vec![ParamBound::maybe_sized(cx)],
bounds: vec![GenericBound::maybe_sized(cx)],
})
}
}
@ -2290,7 +2290,7 @@ pub struct Trait {
pub unsafety: hir::Unsafety,
pub items: Vec<Item>,
pub generics: Generics,
pub bounds: Vec<ParamBound>,
pub bounds: Vec<GenericBound>,
pub is_spotlight: bool,
pub is_auto: bool,
}
@ -2512,7 +2512,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
// at the end.
match bounds.iter().position(|b| b.is_sized_bound(cx)) {
Some(i) => { bounds.remove(i); }
None => bounds.push(ParamBound::maybe_sized(cx)),
None => bounds.push(GenericBound::maybe_sized(cx)),
}
let ty = if self.defaultness.has_value() {
@ -2567,7 +2567,7 @@ pub enum Type {
/// structs/enums/traits (most that'd be an hir::TyPath)
ResolvedPath {
path: Path,
typarams: Option<Vec<ParamBound>>,
typarams: Option<Vec<GenericBound>>,
did: DefId,
/// true if is a `T::Name` path for associated types
is_generic: bool,
@ -2603,7 +2603,7 @@ pub enum Type {
Infer,
// impl TraitA+TraitB
ImplTrait(Vec<ParamBound>),
ImplTrait(Vec<GenericBound>),
}
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Copy, Debug)]
@ -2977,7 +2977,7 @@ impl Clean<Type> for hir::Ty {
TyTraitObject(ref bounds, ref lifetime) => {
match bounds[0].clean(cx).trait_ {
ResolvedPath { path, typarams: None, did, is_generic } => {
let mut bounds: Vec<self::ParamBound> = bounds[1..].iter().map(|bound| {
let mut bounds: Vec<self::GenericBound> = bounds[1..].iter().map(|bound| {
TraitBound(bound.clean(cx), hir::TraitBoundModifier::None)
}).collect();
if !lifetime.is_elided() {
@ -3080,7 +3080,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
inline::record_extern_fqn(cx, did, TypeKind::Trait);
let mut typarams = vec![];
reg.clean(cx).map(|b| typarams.push(ParamBound::Outlives(b)));
reg.clean(cx).map(|b| typarams.push(GenericBound::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(),
@ -3138,7 +3138,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
} 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(ParamBound::Outlives(r))
regions.push(GenericBound::Outlives(r))
});
return None;
} else {
@ -3173,7 +3173,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
}).collect::<Vec<_>>();
bounds.extend(regions);
if !has_sized && !bounds.is_empty() {
bounds.insert(0, ParamBound::maybe_sized(cx));
bounds.insert(0, GenericBound::maybe_sized(cx));
}
ImplTrait(bounds)
}
@ -4469,11 +4469,11 @@ impl AutoTraitResult {
}
}
impl From<ParamBound> for SimpleBound {
fn from(bound: ParamBound) -> Self {
impl From<GenericBound> for SimpleBound {
fn from(bound: GenericBound) -> Self {
match bound.clone() {
ParamBound::Outlives(l) => SimpleBound::Outlives(l),
ParamBound::TraitBound(t, mod_) => match t.trait_ {
GenericBound::Outlives(l) => SimpleBound::Outlives(l),
GenericBound::TraitBound(t, mod_) => match t.trait_ {
Type::ResolvedPath { path, typarams, .. } => {
SimpleBound::TraitBound(path.segments,
typarams

View file

@ -147,7 +147,7 @@ pub fn ty_params(mut params: Vec<clean::GenericParamDef>) -> Vec<clean::GenericP
params
}
fn ty_bounds(bounds: Vec<clean::ParamBound>) -> Vec<clean::ParamBound> {
fn ty_bounds(bounds: Vec<clean::GenericBound>) -> Vec<clean::GenericBound> {
bounds
}

View file

@ -77,7 +77,7 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a> {
/// Table node id of lifetime parameter definition -> substituted lifetime
pub lt_substs: RefCell<FxHashMap<DefId, clean::Lifetime>>,
/// Table DefId of `impl Trait` in argument position -> bounds
pub impl_trait_bounds: RefCell<FxHashMap<DefId, Vec<clean::ParamBound>>>,
pub impl_trait_bounds: RefCell<FxHashMap<DefId, Vec<clean::GenericBound>>>,
pub send_trait: Option<DefId>,
pub fake_def_ids: RefCell<FxHashMap<CrateNum, DefId>>,
pub all_fake_def_ids: RefCell<FxHashSet<DefId>>,

View file

@ -201,7 +201,7 @@ pub struct Trait {
pub name: Name,
pub items: hir::HirVec<hir::TraitItem>,
pub generics: hir::Generics,
pub bounds: hir::HirVec<hir::ParamBound>,
pub bounds: hir::HirVec<hir::GenericBound>,
pub attrs: hir::HirVec<ast::Attribute>,
pub id: ast::NodeId,
pub whence: Span,

View file

@ -46,7 +46,7 @@ pub struct MutableSpace(pub clean::Mutability);
#[derive(Copy, Clone)]
pub struct RawMutableSpace(pub clean::Mutability);
/// Wrapper struct for emitting type parameter bounds.
pub struct ParamBounds<'a>(pub &'a [clean::ParamBound]);
pub struct GenericBounds<'a>(pub &'a [clean::GenericBound]);
/// Wrapper struct for emitting a comma-separated list of items
pub struct CommaSep<'a, T: 'a>(pub &'a [T]);
pub struct AbiSpace(pub Abi);
@ -104,9 +104,9 @@ impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
}
}
impl<'a> fmt::Display for ParamBounds<'a> {
impl<'a> fmt::Display for GenericBounds<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let &ParamBounds(bounds) = self;
let &GenericBounds(bounds) = self;
for (i, bound) in bounds.iter().enumerate() {
if i > 0 {
f.write_str(" + ")?;
@ -126,9 +126,9 @@ impl fmt::Display for clean::GenericParamDef {
if !bounds.is_empty() {
if f.alternate() {
write!(f, ": {:#}", ParamBounds(bounds))?;
write!(f, ": {:#}", GenericBounds(bounds))?;
} else {
write!(f, ":&nbsp;{}", ParamBounds(bounds))?;
write!(f, ":&nbsp;{}", GenericBounds(bounds))?;
}
}
@ -190,9 +190,9 @@ impl<'a> fmt::Display for WhereClause<'a> {
&clean::WherePredicate::BoundPredicate { ref ty, ref bounds } => {
let bounds = bounds;
if f.alternate() {
clause.push_str(&format!("{:#}: {:#}", ty, ParamBounds(bounds)));
clause.push_str(&format!("{:#}: {:#}", ty, GenericBounds(bounds)));
} else {
clause.push_str(&format!("{}: {}", ty, ParamBounds(bounds)));
clause.push_str(&format!("{}: {}", ty, GenericBounds(bounds)));
}
}
&clean::WherePredicate::RegionPredicate { ref lifetime,
@ -267,7 +267,7 @@ impl fmt::Display for clean::PolyTrait {
}
}
impl fmt::Display for clean::ParamBound {
impl fmt::Display for clean::GenericBound {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
clean::Outlives(ref lt) => {
@ -512,7 +512,7 @@ fn primitive_link(f: &mut fmt::Formatter,
/// Helper to render type parameters
fn tybounds(w: &mut fmt::Formatter,
typarams: &Option<Vec<clean::ParamBound>>) -> fmt::Result {
typarams: &Option<Vec<clean::GenericBound>>) -> fmt::Result {
match *typarams {
Some(ref params) => {
for param in params {
@ -667,7 +667,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
}
}
clean::ImplTrait(ref bounds) => {
write!(f, "impl {}", ParamBounds(bounds))
write!(f, "impl {}", GenericBounds(bounds))
}
clean::QPath { ref name, ref self_type, ref trait_ } => {
let should_show_cast = match *trait_ {

View file

@ -69,7 +69,7 @@ use doctree;
use fold::DocFolder;
use html::escape::Escape;
use html::format::{ConstnessSpace};
use html::format::{ParamBounds, WhereClause, href, AbiSpace};
use html::format::{GenericBounds, WhereClause, href, AbiSpace};
use html::format::{VisSpace, Method, UnsafetySpace, MutableSpace};
use html::format::fmt_impl_for_trait_page;
use html::item_type::ItemType;
@ -2960,14 +2960,14 @@ fn assoc_const(w: &mut fmt::Formatter,
}
fn assoc_type<W: fmt::Write>(w: &mut W, it: &clean::Item,
bounds: &Vec<clean::ParamBound>,
bounds: &Vec<clean::GenericBound>,
default: Option<&clean::Type>,
link: AssocItemLink) -> fmt::Result {
write!(w, "type <a href='{}' class=\"type\">{}</a>",
naive_assoc_href(it, link),
it.name.as_ref().unwrap())?;
if !bounds.is_empty() {
write!(w, ": {}", ParamBounds(bounds))?
write!(w, ": {}", GenericBounds(bounds))?
}
if let Some(default) = default {
write!(w, " = {}", default)?;

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);

View file

@ -553,7 +553,7 @@ impl<'a> TraitDef<'a> {
GenericParamKind::Lifetime { .. } => param.clone(),
GenericParamKind::Type { .. } => {
// I don't think this can be moved out of the loop, since
// a ParamBound requires an ast id
// a GenericBound requires an ast id
let mut bounds: Vec<_> =
// extra restrictions on the generics parameters to the
// type being derived upon

View file

@ -261,7 +261,7 @@ impl<'a> LifetimeBounds<'a> {
.iter()
.map(|&(lt, ref bounds)| {
let bounds = bounds.iter()
.map(|b| ast::ParamBound::Outlives(cx.lifetime(span, Ident::from_str(b))));
.map(|b| ast::GenericBound::Outlives(cx.lifetime(span, Ident::from_str(b))));
cx.lifetime_def(span, Ident::from_str(lt), vec![], bounds.collect())
})
.chain(self.bounds