From c5f16e0e180f4f76187e55aecb5913a1cf7fab2a Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Jun 2018 12:08:58 +0100 Subject: [PATCH] Rename ParamBound(s) to GenericBound(s) --- src/librustc/hir/intravisit.rs | 8 +-- src/librustc/hir/lowering.rs | 24 +++---- src/librustc/hir/mod.rs | 24 +++---- src/librustc/hir/print.rs | 18 ++--- src/librustc/ich/impls_hir.rs | 2 +- src/librustc/middle/resolve_lifetime.rs | 6 +- src/librustc_passes/ast_validation.rs | 2 +- src/librustc_passes/hir_stats.rs | 8 +-- src/librustc_privacy/lib.rs | 4 +- src/librustc_save_analysis/dump_visitor.rs | 2 +- src/librustc_save_analysis/sig.rs | 6 +- src/librustc_typeck/collect.rs | 30 ++++---- src/librustdoc/clean/auto_trait.rs | 24 +++---- src/librustdoc/clean/inline.rs | 4 +- src/librustdoc/clean/mod.rs | 82 +++++++++++----------- src/librustdoc/clean/simplify.rs | 2 +- src/librustdoc/core.rs | 2 +- src/librustdoc/doctree.rs | 2 +- src/librustdoc/html/format.rs | 20 +++--- src/librustdoc/html/render.rs | 6 +- src/libsyntax/ast.rs | 26 +++---- src/libsyntax/ext/build.rs | 12 ++-- src/libsyntax/fold.rs | 16 ++--- src/libsyntax/parse/parser.rs | 12 ++-- src/libsyntax/print/pprust.rs | 10 +-- src/libsyntax/util/node_count.rs | 2 +- src/libsyntax/visit.rs | 4 +- src/libsyntax_ext/deriving/generic/mod.rs | 2 +- src/libsyntax_ext/deriving/generic/ty.rs | 2 +- 29 files changed, 181 insertions(+), 181 deletions(-) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index a778ea12552..e49a5e4ee6a 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -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), } } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index aec94d60f94..b725432eb5c 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1285,7 +1285,7 @@ impl<'a> LoweringContext<'a> { &mut self, exist_ty_id: NodeId, parent_index: DefIndex, - bounds: &hir::ParamBounds, + bounds: &hir::GenericBounds, ) -> (HirVec, HirVec) { // 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, - add_bounds: &NodeMap>, + add_bounds: &NodeMap>, itctx: ImplTraitContext, ) -> hir::HirVec { 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>, + add_bounds: &NodeMap>, itctx: ImplTraitContext) -> hir::GenericParam { let mut bounds = self.lower_param_bounds(¶m.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() } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 63b4614ef5d..f6876113c11 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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; +pub type GenericBounds = HirVec; #[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, - 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, /// 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>), + Type(GenericBounds, Option>), } // 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, } @@ -2049,9 +2049,9 @@ pub enum Item_ { /// A union definition, e.g. `union Foo {x: A, y: B}` ItemUnion(VariantData, Generics), /// Represents a Trait Declaration - ItemTrait(IsAuto, Unsafety, Generics, ParamBounds, HirVec), + ItemTrait(IsAuto, Unsafety, Generics, GenericBounds, HirVec), /// Represents a Trait Alias Declaration - ItemTraitAlias(Generics, ParamBounds), + ItemTraitAlias(Generics, GenericBounds), /// An implementation, eg `impl Trait for Foo { .. }` ItemImpl(Unsafety, diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index b6fd1362554..229a4da465a 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -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 ¶m.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!(), diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index fbe2fdae877..882194ae64e 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -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) }); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 178b9b1f45a..091662966ea 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -1250,9 +1250,9 @@ fn object_lifetime_defaults_for_item( tcx: TyCtxt<'_, '_, '_>, generics: &hir::Generics, ) -> Vec { - fn add_bounds(set: &mut Set1, bounds: &[hir::ParamBound]) { + fn add_bounds(set: &mut Set1, 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, diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index bdfe1d50e26..4f04ad89698 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -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, diff --git a/src/librustc_passes/hir_stats.rs b/src/librustc_passes/hir_stats.rs index 879adebf7ea..e7b2869dfe6 100644 --- a/src/librustc_passes/hir_stats.rs +++ b/src/librustc_passes/hir_stats.rs @@ -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) } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 68b5a925ef3..809f5a06952 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -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); } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 1373ee94587..0f0f3f6e789 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -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(); diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 58e2e9b2258..7f2f0b0c837 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -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 { @@ -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::>() @@ -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 { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 6e154819c4c..7a4fbc73c2e 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -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, <, 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, ®ion_pred.lifetime, None); for bound in ®ion_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` adds `T:Bar` /// and `::X == i32`). fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>, param_ty: Ty<'tcx>, - bound: &hir::ParamBound) + bound: &hir::GenericBound) -> Vec> { 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![], } } diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 0874e921f41..5c09da90491 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -486,8 +486,8 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { .iter() .flat_map(|(name, lifetime)| { let empty = Vec::new(); - let bounds: FxHashSet = finished.get(name).unwrap_or(&empty).iter() - .map(|region| ParamBound::Outlives(self.get_lifetime(region, names_map))) + let bounds: FxHashSet = 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>, + ty_to_bounds: FxHashMap>, ty_to_fn: FxHashMap, Option)>, - lifetime_to_bounds: FxHashMap>, + lifetime_to_bounds: FxHashMap>, ) -> Vec { 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` // 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) { + fn sort_where_bounds(&self, mut bounds: &mut Vec) { // 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. diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index c85178961c1..f3a833bad8f 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -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::Generics, Vec) { let mut ty_bounds = Vec::new(); g.where_predicates.retain(|pred| { match *pred { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7f9500d21f0..031a948fe80 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -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), - AssociatedTypeItem(Vec, Option), + AssociatedTypeItem(Vec, Option), /// An item that has been stripped by a rustdoc pass StrippedItem(Box), KeywordItem(String), @@ -1458,13 +1458,13 @@ impl Clean 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 { - 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 { - if let ParamBound::TraitBound(PolyTrait { ref trait_, .. }, _) = *self { + if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, _) = *self { return Some(trait_.clone()); } None } } -impl Clean for hir::ParamBound { - fn clean(&self, cx: &DocContext) -> ParamBound { +impl Clean 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, has_self } } -impl<'a, 'tcx> Clean for (&'a ty::TraitRef<'tcx>, Vec) { - fn clean(&self, cx: &DocContext) -> ParamBound { +impl<'a, 'tcx> Clean for (&'a ty::TraitRef<'tcx>, Vec) { + 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 for (&'a ty::TraitRef<'tcx>, Vec) } } -impl<'tcx> Clean for ty::TraitRef<'tcx> { - fn clean(&self, cx: &DocContext) -> ParamBound { +impl<'tcx> Clean for ty::TraitRef<'tcx> { + fn clean(&self, cx: &DocContext) -> GenericBound { (self, vec![]).clean(cx) } } -impl<'tcx> Clean>> for Substs<'tcx> { - fn clean(&self, cx: &DocContext) -> Option> { +impl<'tcx> Clean>> for Substs<'tcx> { + fn clean(&self, cx: &DocContext) -> Option> { 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 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> for ty::RegionKind { #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)] pub enum WherePredicate { - BoundPredicate { ty: Type, bounds: Vec }, - RegionPredicate { lifetime: Lifetime, bounds: Vec }, + BoundPredicate { ty: Type, bounds: Vec }, + RegionPredicate { lifetime: Lifetime, bounds: Vec }, EqPredicate { lhs: Type, rhs: Type }, } @@ -1791,7 +1791,7 @@ impl<'tcx> Clean for ty::OutlivesPredicate, 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 for ty::OutlivesPredicate, 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 for ty::ProjectionPredicate<'tcx> { impl<'tcx> Clean 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, + bounds: Vec, default: Option, synthetic: Option, }, @@ -1893,7 +1893,7 @@ impl Clean 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 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, pub generics: Generics, - pub bounds: Vec, + pub bounds: Vec, pub is_spotlight: bool, pub is_auto: bool, } @@ -2512,7 +2512,7 @@ impl<'tcx> Clean 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>, + typarams: Option>, 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), + ImplTrait(Vec), } #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Copy, Debug)] @@ -2977,7 +2977,7 @@ impl Clean 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 = bounds[1..].iter().map(|bound| { + let mut bounds: Vec = bounds[1..].iter().map(|bound| { TraitBound(bound.clean(cx), hir::TraitBoundModifier::None) }).collect(); if !lifetime.is_elided() { @@ -3080,7 +3080,7 @@ impl<'tcx> Clean 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 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 for Ty<'tcx> { }).collect::>(); 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 for SimpleBound { - fn from(bound: ParamBound) -> Self { +impl From 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 diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index c7477645d6a..a54eb64443b 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -147,7 +147,7 @@ pub fn ty_params(mut params: Vec) -> Vec) -> Vec { +fn ty_bounds(bounds: Vec) -> Vec { bounds } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 7147e13805f..53ebb3a12f5 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -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>, /// Table DefId of `impl Trait` in argument position -> bounds - pub impl_trait_bounds: RefCell>>, + pub impl_trait_bounds: RefCell>>, pub send_trait: Option, pub fake_def_ids: RefCell>, pub all_fake_def_ids: RefCell>, diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index 542d753c4f0..16d14bc56d6 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -201,7 +201,7 @@ pub struct Trait { pub name: Name, pub items: hir::HirVec, pub generics: hir::Generics, - pub bounds: hir::HirVec, + pub bounds: hir::HirVec, pub attrs: hir::HirVec, pub id: ast::NodeId, pub whence: Span, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index bd9194a8669..987821d2e30 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -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, ": {}", ParamBounds(bounds))?; + write!(f, ": {}", 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>) -> fmt::Result { + typarams: &Option>) -> 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_ { diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 21724c2d730..180591b3532 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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: &mut W, it: &clean::Item, - bounds: &Vec, + bounds: &Vec, default: Option<&clean::Type>, link: AssocItemLink) -> fmt::Result { write!(w, "type {}", 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)?; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 6fe90025ff8..9dc13fab2d6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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; +pub type GenericBounds = Vec; #[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, - pub bounds: ParamBounds, + pub bounds: GenericBounds, pub kind: GenericParamKind, } @@ -381,7 +381,7 @@ pub struct WhereBoundPredicate { /// The type being bounded pub bounded_ty: P, /// 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 { + fn to_bound(&self) -> Option { 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, Option>), Method(MethodSig, Option>), - Type(ParamBounds, Option>), + Type(GenericBounds, Option>), Macro(Mac), } @@ -1537,10 +1537,10 @@ pub enum TyKind { Path(Option, 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), /// Unused for now @@ -2061,11 +2061,11 @@ pub enum ItemKind { /// A Trait declaration (`trait` or `pub trait`). /// /// E.g. `trait Foo { .. }`, `trait Foo { .. }` or `auto trait Foo {}` - Trait(IsAuto, Unsafety, Generics, ParamBounds, Vec), + Trait(IsAuto, Unsafety, Generics, GenericBounds, Vec), /// Trait alias /// /// E.g. `trait Foo = Bar + Quux;` - TraitAlias(Generics, ParamBounds), + TraitAlias(Generics, GenericBounds), /// An implementation. /// /// E.g. `impl Foo { .. }` or `impl Trait for Foo { .. }` diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 28bfb1ff811..9de6e14fbeb 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -68,18 +68,18 @@ pub trait AstBuilder { span: Span, id: ast::Ident, attrs: Vec, - bounds: ast::ParamBounds, + bounds: ast::GenericBounds, default: Option>) -> 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, - 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, - bounds: ast::ParamBounds, + bounds: ast::GenericBounds, default: Option>) -> 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, - bounds: ast::ParamBounds) + bounds: ast::GenericBounds) -> ast::GenericParam { let lifetime = self.lifetime(span, ident); ast::GenericParam { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 290607a702b..5db5d0781ea 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -268,15 +268,15 @@ pub trait Folder : Sized { noop_fold_interpolated(nt, self) } - fn fold_opt_bounds(&mut self, b: Option) -> Option { + fn fold_opt_bounds(&mut self, b: Option) -> Option { 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(decl: P, fld: &mut T) -> P { }) } -pub fn noop_fold_param_bound(pb: ParamBound, fld: &mut T) -> ParamBound where T: Folder { +pub fn noop_fold_param_bound(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(MutTy {ty, mutbl}: MutTy, folder: &mut T) -> MutT } } -pub fn noop_fold_opt_bounds(b: Option, folder: &mut T) - -> Option { +pub fn noop_fold_opt_bounds(b: Option, folder: &mut T) + -> Option { b.map(|bounds| folder.fold_bounds(bounds)) } -fn noop_fold_bounds(bounds: ParamBounds, folder: &mut T) - -> ParamBounds { +fn noop_fold_bounds(bounds: GenericBounds, folder: &mut T) + -> GenericBounds { bounds.move_map(|bound| folder.fold_param_bound(bound)) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 75eefb84432..8588f4c492f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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] 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()?; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 38229fa4998..1e0b107ef6e 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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!(), } } diff --git a/src/libsyntax/util/node_count.rs b/src/libsyntax/util/node_count.rs index 2d92f4b9531..ebb3081c1fd 100644 --- a/src/libsyntax/util/node_count.rs +++ b/src/libsyntax/util/node_count.rs @@ -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) } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 6beaabd03de..71b606f08a5 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -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); diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 89b50044129..0922e7cd800 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -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 diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 99b6398160e..edb901e1f3c 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -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