Skip to content

Commit 7de6ed0

Browse files
committed
Rename TraitTyParamBound to ParamBound::Trait
1 parent 8bc3a35 commit 7de6ed0

File tree

17 files changed

+57
-64
lines changed

17 files changed

+57
-64
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,10 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v
733733

734734
pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v ParamBound) {
735735
match *bound {
736-
TraitTyParamBound(ref typ, modifier) => {
736+
ParamBound::Trait(ref typ, modifier) => {
737737
visitor.visit_poly_trait_ref(typ, modifier);
738738
}
739-
Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
739+
ParamBound::Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
740740
}
741741
}
742742

src/librustc/hir/lowering.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,10 @@ impl<'a> LoweringContext<'a> {
11081108
let bounds = bounds
11091109
.iter()
11101110
.filter_map(|bound| match *bound {
1111-
TraitTyParamBound(ref ty, TraitBoundModifier::None) => {
1111+
Trait(ref ty, TraitBoundModifier::None) => {
11121112
Some(self.lower_poly_trait_ref(ty, itctx))
11131113
}
1114-
TraitTyParamBound(_, TraitBoundModifier::Maybe) => None,
1114+
Trait(_, TraitBoundModifier::Maybe) => None,
11151115
Outlives(ref lifetime) => {
11161116
if lifetime_bound.is_none() {
11171117
lifetime_bound = Some(self.lower_lifetime(lifetime));
@@ -1875,12 +1875,12 @@ impl<'a> LoweringContext<'a> {
18751875
itctx: ImplTraitContext,
18761876
) -> hir::ParamBound {
18771877
match *tpb {
1878-
TraitTyParamBound(ref ty, modifier) => hir::TraitTyParamBound(
1878+
ParamBound::Trait(ref ty, modifier) => hir::ParamBound::Trait(
18791879
self.lower_poly_trait_ref(ty, itctx),
18801880
self.lower_trait_bound_modifier(modifier),
18811881
),
1882-
Outlives(ref lifetime) => {
1883-
hir::Outlives(self.lower_lifetime(lifetime))
1882+
ParamBound::Outlives(ref lifetime) => {
1883+
hir::ParamBound::Outlives(self.lower_lifetime(lifetime))
18841884
}
18851885
}
18861886
}
@@ -2010,7 +2010,7 @@ impl<'a> LoweringContext<'a> {
20102010
for pred in &generics.where_clause.predicates {
20112011
if let WherePredicate::BoundPredicate(ref bound_pred) = *pred {
20122012
'next_bound: for bound in &bound_pred.bounds {
2013-
if let TraitTyParamBound(_, TraitBoundModifier::Maybe) = *bound {
2013+
if let ParamBound::Trait(_, TraitBoundModifier::Maybe) = *bound {
20142014
let report_error = |this: &mut Self| {
20152015
this.diagnostic().span_err(
20162016
bound_pred.bounded_ty.span,
@@ -2095,7 +2095,7 @@ impl<'a> LoweringContext<'a> {
20952095
.filter_map(|bound| match *bound {
20962096
// Ignore `?Trait` bounds.
20972097
// Tthey were copied into type parameters already.
2098-
TraitTyParamBound(_, TraitBoundModifier::Maybe) => None,
2098+
ParamBound::Trait(_, TraitBoundModifier::Maybe) => None,
20992099
_ => Some(this.lower_param_bound(
21002100
bound,
21012101
ImplTraitContext::Disallowed,

src/librustc/hir/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub use self::Mutability::*;
2222
pub use self::PrimTy::*;
2323
pub use self::Stmt_::*;
2424
pub use self::Ty_::*;
25-
pub use self::ParamBound::*;
2625
pub use self::UnOp::*;
2726
pub use self::UnsafeSource::*;
2827
pub use self::Visibility::{Public, Inherited};
@@ -445,15 +444,15 @@ pub enum TraitBoundModifier {
445444
/// detects Copy, Send and Sync.
446445
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
447446
pub enum ParamBound {
448-
TraitTyParamBound(PolyTraitRef, TraitBoundModifier),
447+
Trait(PolyTraitRef, TraitBoundModifier),
449448
Outlives(Lifetime),
450449
}
451450

452451
impl ParamBound {
453452
pub fn span(&self) -> Span {
454453
match self {
455-
&TraitTyParamBound(ref t, ..) => t.span,
456-
&Outlives(ref l) => l.span,
454+
&ParamBound::Trait(ref t, ..) => t.span,
455+
&ParamBound::Outlives(ref l) => l.span,
457456
}
458457
}
459458
}

src/librustc/hir/print.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use syntax::util::parser::{self, AssocOp, Fixity};
2424
use syntax_pos::{self, BytePos, FileName};
2525

2626
use hir;
27-
use hir::{PatKind, Outlives, TraitTyParamBound, TraitBoundModifier, RangeEnd};
27+
use hir::{PatKind, ParamBound, TraitBoundModifier, RangeEnd};
2828
use hir::{GenericParam, GenericParamKind, GenericArg};
2929

3030
use std::cell::Cell;
@@ -740,7 +740,7 @@ impl<'a> State<'a> {
740740
self.print_generic_params(&generics.params)?;
741741
let mut real_bounds = Vec::with_capacity(bounds.len());
742742
for b in bounds.iter() {
743-
if let TraitTyParamBound(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
743+
if let ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
744744
self.s.space()?;
745745
self.word_space("for ?")?;
746746
self.print_trait_ref(&ptr.trait_ref)?;
@@ -766,7 +766,7 @@ impl<'a> State<'a> {
766766
let mut real_bounds = Vec::with_capacity(bounds.len());
767767
// FIXME(durka) this seems to be some quite outdated syntax
768768
for b in bounds.iter() {
769-
if let TraitTyParamBound(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
769+
if let ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
770770
self.s.space()?;
771771
self.word_space("for ?")?;
772772
self.print_trait_ref(&ptr.trait_ref)?;
@@ -2086,13 +2086,13 @@ impl<'a> State<'a> {
20862086
}
20872087

20882088
match bound {
2089-
TraitTyParamBound(tref, modifier) => {
2089+
ParamBound::Trait(tref, modifier) => {
20902090
if modifier == &TraitBoundModifier::Maybe {
20912091
self.s.word("?")?;
20922092
}
20932093
self.print_poly_trait_ref(tref)?;
20942094
}
2095-
Outlives(lt) => {
2095+
ParamBound::Outlives(lt) => {
20962096
self.print_lifetime(lt)?;
20972097
}
20982098
}
@@ -2121,7 +2121,7 @@ impl<'a> State<'a> {
21212121
let mut sep = ":";
21222122
for bound in &param.bounds {
21232123
match bound {
2124-
hir::ParamBound::Outlives(lt) => {
2124+
ParamBound::Outlives(lt) => {
21252125
self.s.word(sep)?;
21262126
self.print_lifetime(lt)?;
21272127
sep = "+";
@@ -2181,7 +2181,7 @@ impl<'a> State<'a> {
21812181

21822182
for (i, bound) in bounds.iter().enumerate() {
21832183
match bound {
2184-
hir::ParamBound::Outlives(lt) => {
2184+
ParamBound::Outlives(lt) => {
21852185
self.print_lifetime(lt)?;
21862186
}
21872187
_ => bug!(),

src/librustc/ich/impls_hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl_stable_hash_for!(struct hir::GenericArgs {
189189
});
190190

191191
impl_stable_hash_for!(enum hir::ParamBound {
192-
TraitTyParamBound(poly_trait_ref, trait_bound_modifier),
192+
Trait(poly_trait_ref, trait_bound_modifier),
193193
Outlives(lifetime)
194194
});
195195

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ fn object_lifetime_defaults_for_item(
12561256
) -> Vec<ObjectLifetimeDefault> {
12571257
fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::ParamBound]) {
12581258
for bound in bounds {
1259-
if let hir::Outlives(ref lifetime) = *bound {
1259+
if let hir::ParamBound::Outlives(ref lifetime) = *bound {
12601260
set.insert(lifetime.name);
12611261
}
12621262
}

src/librustc_passes/ast_validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a> AstValidator<'a> {
101101

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

src/librustc_privacy/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
10391039

10401040
fn check_ty_param_bound(&mut self,
10411041
ty_param_bound: &hir::ParamBound) {
1042-
if let hir::TraitTyParamBound(ref trait_ref, _) = *ty_param_bound {
1042+
if let hir::ParamBound::Trait(ref trait_ref, _) = *ty_param_bound {
10431043
if self.path_is_private_type(&trait_ref.trait_ref.path) {
10441044
self.old_error_set.insert(trait_ref.trait_ref.ref_id);
10451045
}

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
761761
// super-traits
762762
for super_bound in trait_refs.iter() {
763763
let trait_ref = match *super_bound {
764-
ast::TraitTyParamBound(ref trait_ref, _) => trait_ref,
764+
ast::Trait(ref trait_ref, _) => trait_ref,
765765
ast::Outlives(..) => {
766766
continue;
767767
}
@@ -1489,7 +1489,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
14891489
ast::GenericParamKind::Lifetime { .. } => {}
14901490
ast::GenericParamKind::Type { ref default, .. } => {
14911491
for bound in &param.bounds {
1492-
if let ast::TraitTyParamBound(ref trait_ref, _) = *bound {
1492+
if let ast::Trait(ref trait_ref, _) = *bound {
14931493
self.process_path(trait_ref.trait_ref.ref_id, &trait_ref.trait_ref.path)
14941494
}
14951495
}

src/librustc_typeck/collect.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ fn is_unsized<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
12571257
// Try to find an unbound in bounds.
12581258
let mut unbound = None;
12591259
for ab in ast_bounds {
1260-
if let &hir::TraitTyParamBound(ref ptr, hir::TraitBoundModifier::Maybe) = ab {
1260+
if let &hir::ParamBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = ab {
12611261
if unbound.is_none() {
12621262
unbound = Some(ptr.trait_ref.clone());
12631263
} else {
@@ -1482,7 +1482,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
14821482

14831483
for bound in bound_pred.bounds.iter() {
14841484
match bound {
1485-
&hir::ParamBound::TraitTyParamBound(ref poly_trait_ref, _) => {
1485+
&hir::ParamBound::Trait(ref poly_trait_ref, _) => {
14861486
let mut projections = Vec::new();
14871487

14881488
let trait_ref =
@@ -1591,22 +1591,16 @@ pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
15911591
let mut trait_bounds = vec![];
15921592
for ast_bound in ast_bounds {
15931593
match *ast_bound {
1594-
hir::TraitTyParamBound(ref b, hir::TraitBoundModifier::None) => {
1595-
trait_bounds.push(b);
1596-
}
1597-
hir::TraitTyParamBound(_, hir::TraitBoundModifier::Maybe) => {}
1598-
hir::Outlives(ref l) => {
1599-
region_bounds.push(l);
1600-
}
1594+
hir::ParamBound::Trait(ref b, hir::TraitBoundModifier::None) => trait_bounds.push(b),
1595+
hir::ParamBound::Trait(_, hir::TraitBoundModifier::Maybe) => {}
1596+
hir::ParamBound::Outlives(ref l) => region_bounds.push(l),
16011597
}
16021598
}
16031599

16041600
let mut projection_bounds = vec![];
16051601

16061602
let mut trait_bounds: Vec<_> = trait_bounds.iter().map(|&bound| {
1607-
astconv.instantiate_poly_trait_ref(bound,
1608-
param_ty,
1609-
&mut projection_bounds)
1603+
astconv.instantiate_poly_trait_ref(bound, param_ty, &mut projection_bounds)
16101604
}).collect();
16111605

16121606
let region_bounds = region_bounds.into_iter().map(|r| {
@@ -1640,7 +1634,7 @@ fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>,
16401634
-> Vec<ty::Predicate<'tcx>>
16411635
{
16421636
match *bound {
1643-
hir::TraitTyParamBound(ref tr, hir::TraitBoundModifier::None) => {
1637+
hir::ParamBound::Trait(ref tr, hir::TraitBoundModifier::None) => {
16441638
let mut projections = Vec::new();
16451639
let pred = astconv.instantiate_poly_trait_ref(tr,
16461640
param_ty,
@@ -1650,14 +1644,12 @@ fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>,
16501644
.chain(Some(pred.to_predicate()))
16511645
.collect()
16521646
}
1653-
hir::Outlives(ref lifetime) => {
1647+
hir::ParamBound::Outlives(ref lifetime) => {
16541648
let region = astconv.ast_region_to_region(lifetime, None);
16551649
let pred = ty::Binder::bind(ty::OutlivesPredicate(param_ty, region));
16561650
vec![ty::Predicate::TypeOutlives(pred)]
16571651
}
1658-
hir::TraitTyParamBound(_, hir::TraitBoundModifier::Maybe) => {
1659-
Vec::new()
1660-
}
1652+
hir::ParamBound::Trait(_, hir::TraitBoundModifier::Maybe) => vec![],
16611653
}
16621654
}
16631655

src/librustdoc/clean/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,8 +1510,8 @@ impl ParamBound {
15101510
impl Clean<ParamBound> for hir::ParamBound {
15111511
fn clean(&self, cx: &DocContext) -> ParamBound {
15121512
match *self {
1513-
hir::Outlives(lt) => Outlives(lt.clean(cx)),
1514-
hir::TraitTyParamBound(ref t, modifier) => TraitBound(t.clean(cx), modifier),
1513+
hir::ParamBound::Outlives(lt) => Outlives(lt.clean(cx)),
1514+
hir::ParamBound::Trait(ref t, modifier) => TraitBound(t.clean(cx), modifier),
15151515
}
15161516
}
15171517
}
@@ -1624,7 +1624,7 @@ impl<'tcx> Clean<Option<Vec<ParamBound>>> for Substs<'tcx> {
16241624
fn clean(&self, cx: &DocContext) -> Option<Vec<ParamBound>> {
16251625
let mut v = Vec::new();
16261626
v.extend(self.regions().filter_map(|r| r.clean(cx))
1627-
.map(Outlives));
1627+
.map(ParamBound::Outlives));
16281628
v.extend(self.types().map(|t| TraitBound(PolyTrait {
16291629
trait_: t.clean(cx),
16301630
generic_params: Vec::new(),
@@ -3080,7 +3080,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
30803080
inline::record_extern_fqn(cx, did, TypeKind::Trait);
30813081

30823082
let mut typarams = vec![];
3083-
reg.clean(cx).map(|b| typarams.push(Outlives(b)));
3083+
reg.clean(cx).map(|b| typarams.push(ParamBound::Outlives(b)));
30843084
for did in obj.auto_traits() {
30853085
let empty = cx.tcx.intern_substs(&[]);
30863086
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
@@ -3137,7 +3137,9 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
31373137
tr
31383138
} else if let ty::Predicate::TypeOutlives(pred) = *predicate {
31393139
// these should turn up at the end
3140-
pred.skip_binder().1.clean(cx).map(|r| regions.push(Outlives(r)));
3140+
pred.skip_binder().1.clean(cx).map(|r| {
3141+
regions.push(ParamBound::Outlives(r))
3142+
});
31413143
return None;
31423144
} else {
31433145
return None;

src/libsyntax/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,14 @@ pub enum TraitBoundModifier {
283283
/// detects Copy, Send and Sync.
284284
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
285285
pub enum ParamBound {
286-
TraitTyParamBound(PolyTraitRef, TraitBoundModifier),
286+
Trait(PolyTraitRef, TraitBoundModifier),
287287
Outlives(Lifetime)
288288
}
289289

290290
impl ParamBound {
291291
pub fn span(&self) -> Span {
292292
match self {
293-
&TraitTyParamBound(ref t, ..) => t.span,
293+
&Trait(ref t, ..) => t.span,
294294
&Outlives(ref l) => l.ident.span,
295295
}
296296
}
@@ -930,7 +930,7 @@ impl Expr {
930930
fn to_bound(&self) -> Option<ParamBound> {
931931
match &self.node {
932932
ExprKind::Path(None, path) =>
933-
Some(TraitTyParamBound(PolyTraitRef::new(Vec::new(), path.clone(), self.span),
933+
Some(Trait(PolyTraitRef::new(Vec::new(), path.clone(), self.span),
934934
TraitBoundModifier::None)),
935935
_ => None,
936936
}

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
465465
}
466466

467467
fn ty_param_bound(&self, path: ast::Path) -> ast::ParamBound {
468-
ast::TraitTyParamBound(self.poly_trait_ref(path.span, path), ast::TraitBoundModifier::None)
468+
ast::Trait(self.poly_trait_ref(path.span, path), ast::TraitBoundModifier::None)
469469
}
470470

471471
fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime {

src/libsyntax/fold.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,8 @@ pub fn noop_fold_fn_decl<T: Folder>(decl: P<FnDecl>, fld: &mut T) -> P<FnDecl> {
678678

679679
pub fn noop_fold_param_bound<T>(pb: ParamBound, fld: &mut T) -> ParamBound where T: Folder {
680680
match pb {
681-
TraitTyParamBound(ty, modifier) => {
682-
TraitTyParamBound(fld.fold_poly_trait_ref(ty), modifier)
681+
Trait(ty, modifier) => {
682+
Trait(fld.fold_poly_trait_ref(ty), modifier)
683683
}
684684
Outlives(lifetime) => Outlives(noop_fold_lifetime(lifetime, fld)),
685685
}

0 commit comments

Comments
 (0)