Skip to content

Commit b2c3703

Browse files
committed
Rename ExplicitSelfCategory's variants and stop re-exporting them.
1 parent 0e9f6ec commit b2c3703

File tree

12 files changed

+59
-60
lines changed

12 files changed

+59
-60
lines changed

src/librustc/middle/traits/object_safety.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ fn virtual_call_violation_for_method<'tcx>(tcx: &ty::ctxt<'tcx>,
254254
// autorefs) to `&self`. For now, we only accept `self`, `&self`
255255
// and `Box<Self>`.
256256
match method.explicit_self {
257-
ty::StaticExplicitSelfCategory => {
257+
ty::ExplicitSelfCategory::Static => {
258258
return Some(MethodViolationCode::StaticMethod);
259259
}
260260

261-
ty::ByValueExplicitSelfCategory |
262-
ty::ByReferenceExplicitSelfCategory(..) |
263-
ty::ByBoxExplicitSelfCategory => {
261+
ty::ExplicitSelfCategory::ByValue |
262+
ty::ExplicitSelfCategory::ByReference(..) |
263+
ty::ExplicitSelfCategory::ByBox => {
264264
}
265265
}
266266

src/librustc/middle/ty/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub use self::ImplOrTraitItemId::*;
1212
pub use self::ClosureKind::*;
1313
pub use self::Variance::*;
1414
pub use self::DtorKind::*;
15-
pub use self::ExplicitSelfCategory::*;
1615
pub use self::ImplOrTraitItemContainer::*;
1716
pub use self::BorrowKind::*;
1817
pub use self::ImplOrTraitItem::*;
@@ -2733,10 +2732,10 @@ impl<'tcx> ctxt<'tcx> {
27332732
/// The category of explicit self.
27342733
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
27352734
pub enum ExplicitSelfCategory {
2736-
StaticExplicitSelfCategory,
2737-
ByValueExplicitSelfCategory,
2738-
ByReferenceExplicitSelfCategory(Region, hir::Mutability),
2739-
ByBoxExplicitSelfCategory,
2735+
Static,
2736+
ByValue,
2737+
ByReference(Region, hir::Mutability),
2738+
ByBox,
27402739
}
27412740

27422741
/// A free variable referred to in a function.

src/librustc/util/ppaux.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -919,13 +919,13 @@ impl fmt::Display for ty::InferTy {
919919
impl fmt::Display for ty::ExplicitSelfCategory {
920920
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
921921
f.write_str(match *self {
922-
ty::StaticExplicitSelfCategory => "static",
923-
ty::ByValueExplicitSelfCategory => "self",
924-
ty::ByReferenceExplicitSelfCategory(_, hir::MutMutable) => {
922+
ty::ExplicitSelfCategory::Static => "static",
923+
ty::ExplicitSelfCategory::ByValue => "self",
924+
ty::ExplicitSelfCategory::ByReference(_, hir::MutMutable) => {
925925
"&mut self"
926926
}
927-
ty::ByReferenceExplicitSelfCategory(_, hir::MutImmutable) => "&self",
928-
ty::ByBoxExplicitSelfCategory => "Box<self>",
927+
ty::ExplicitSelfCategory::ByReference(_, hir::MutImmutable) => "&self",
928+
ty::ExplicitSelfCategory::ByBox => "Box<self>",
929929
})
930930
}
931931
}

src/librustc_metadata/decoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -884,12 +884,12 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory {
884884

885885
let explicit_self_kind = string.as_bytes()[0];
886886
match explicit_self_kind as char {
887-
's' => ty::StaticExplicitSelfCategory,
888-
'v' => ty::ByValueExplicitSelfCategory,
889-
'~' => ty::ByBoxExplicitSelfCategory,
887+
's' => ty::ExplicitSelfCategory::Static,
888+
'v' => ty::ExplicitSelfCategory::ByValue,
889+
'~' => ty::ExplicitSelfCategory::ByBox,
890890
// FIXME(#4846) expl. region
891891
'&' => {
892-
ty::ByReferenceExplicitSelfCategory(
892+
ty::ExplicitSelfCategory::ByReference(
893893
ty::ReEmpty,
894894
get_mutability(string.as_bytes()[1]))
895895
}
@@ -923,7 +923,7 @@ pub fn is_static_method(cdata: Cmd, id: DefIndex) -> bool {
923923
let doc = cdata.lookup_item(id);
924924
match item_sort(doc) {
925925
Some('r') | Some('p') => {
926-
get_explicit_self(doc) == ty::StaticExplicitSelfCategory
926+
get_explicit_self(doc) == ty::ExplicitSelfCategory::Static
927927
}
928928
_ => false
929929
}

src/librustc_metadata/encoder.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -498,16 +498,16 @@ fn encode_explicit_self(rbml_w: &mut Encoder,
498498

499499
// Encode the base self type.
500500
match *explicit_self {
501-
ty::StaticExplicitSelfCategory => {
501+
ty::ExplicitSelfCategory::Static => {
502502
rbml_w.wr_tagged_bytes(tag, &['s' as u8]);
503503
}
504-
ty::ByValueExplicitSelfCategory => {
504+
ty::ExplicitSelfCategory::ByValue => {
505505
rbml_w.wr_tagged_bytes(tag, &['v' as u8]);
506506
}
507-
ty::ByBoxExplicitSelfCategory => {
507+
ty::ExplicitSelfCategory::ByBox => {
508508
rbml_w.wr_tagged_bytes(tag, &['~' as u8]);
509509
}
510-
ty::ByReferenceExplicitSelfCategory(_, m) => {
510+
ty::ExplicitSelfCategory::ByReference(_, m) => {
511511
// FIXME(#4846) encode custom lifetime
512512
let ch = encode_mutability(m);
513513
rbml_w.wr_tagged_bytes(tag, &['&' as u8, ch]);
@@ -675,7 +675,7 @@ fn encode_method_ty_fields<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
675675
encode_visibility(rbml_w, method_ty.vis);
676676
encode_explicit_self(rbml_w, &method_ty.explicit_self);
677677
match method_ty.explicit_self {
678-
ty::StaticExplicitSelfCategory => {
678+
ty::ExplicitSelfCategory::Static => {
679679
encode_family(rbml_w, STATIC_METHOD_FAMILY);
680680
}
681681
_ => encode_family(rbml_w, METHOD_FAMILY)
@@ -1340,7 +1340,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
13401340
path.clone().chain(Some(elem)));
13411341

13421342
match method_ty.explicit_self {
1343-
ty::StaticExplicitSelfCategory => {
1343+
ty::ExplicitSelfCategory::Static => {
13441344
encode_family(rbml_w,
13451345
STATIC_METHOD_FAMILY);
13461346
}
@@ -1353,7 +1353,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
13531353
ecx.local_id(method_def_id));
13541354

13551355
is_nonstatic_method = method_ty.explicit_self !=
1356-
ty::StaticExplicitSelfCategory;
1356+
ty::ExplicitSelfCategory::Static;
13571357
}
13581358
ty::TypeTraitItem(associated_type) => {
13591359
encode_name(rbml_w, associated_type.name);

src/librustc_trans/save/dump_csv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
682682
def::DefMethod(did) => {
683683
let ti = self.tcx.impl_or_trait_item(did);
684684
if let ty::MethodTraitItem(m) = ti {
685-
if m.explicit_self == ty::StaticExplicitSelfCategory {
685+
if m.explicit_self == ty::ExplicitSelfCategory::Static {
686686
self.write_sub_path_trait_truncated(path);
687687
}
688688
}

src/librustc_typeck/astconv.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
18151815
// reference) in the arguments, then any anonymous regions in the output
18161816
// have that lifetime.
18171817
let implied_output_region = match explicit_self_category {
1818-
Some(ty::ByReferenceExplicitSelfCategory(region, _)) => Ok(region),
1818+
Some(ty::ExplicitSelfCategory::ByReference(region, _)) => Ok(region),
18191819
_ => find_implied_output_region(this.tcx(), &arg_tys, arg_pats)
18201820
};
18211821

@@ -1846,9 +1846,9 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
18461846
{
18471847
let self_ty = self_info.untransformed_self_ty;
18481848
return match self_info.explicit_self.node {
1849-
hir::SelfStatic => (None, Some(ty::StaticExplicitSelfCategory)),
1849+
hir::SelfStatic => (None, Some(ty::ExplicitSelfCategory::Static)),
18501850
hir::SelfValue(_) => {
1851-
(Some(self_ty), Some(ty::ByValueExplicitSelfCategory))
1851+
(Some(self_ty), Some(ty::ExplicitSelfCategory::ByValue))
18521852
}
18531853
hir::SelfRegion(ref lifetime, mutability, _) => {
18541854
let region =
@@ -1862,7 +1862,7 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
18621862
ty: self_ty,
18631863
mutbl: mutability
18641864
})),
1865-
Some(ty::ByReferenceExplicitSelfCategory(region, mutability)))
1865+
Some(ty::ExplicitSelfCategory::ByReference(region, mutability)))
18661866
}
18671867
hir::SelfExplicit(ref ast_type, _) => {
18681868
let explicit_type = ast_ty_to_ty(this, rscope, &**ast_type);
@@ -1878,12 +1878,12 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
18781878
// ```
18791879
// impl Foo for &T {
18801880
// // Legal declarations:
1881-
// fn method1(self: &&T); // ByReferenceExplicitSelfCategory
1882-
// fn method2(self: &T); // ByValueExplicitSelfCategory
1883-
// fn method3(self: Box<&T>); // ByBoxExplicitSelfCategory
1881+
// fn method1(self: &&T); // ExplicitSelfCategory::ByReference
1882+
// fn method2(self: &T); // ExplicitSelfCategory::ByValue
1883+
// fn method3(self: Box<&T>); // ExplicitSelfCategory::ByBox
18841884
//
18851885
// // Invalid cases will be caught later by `check_method_self_type`:
1886-
// fn method_err1(self: &mut T); // ByReferenceExplicitSelfCategory
1886+
// fn method_err1(self: &mut T); // ExplicitSelfCategory::ByReference
18871887
// }
18881888
// ```
18891889
//
@@ -1894,7 +1894,7 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
18941894
// call it by-ref, by-box as appropriate. For method1, for
18951895
// example, the impl type has one modifier, but the method
18961896
// type has two, so we end up with
1897-
// ByReferenceExplicitSelfCategory.
1897+
// ExplicitSelfCategory::ByReference.
18981898

18991899
let impl_modifiers = count_modifiers(self_info.untransformed_self_ty);
19001900
let method_modifiers = count_modifiers(explicit_type);
@@ -1908,12 +1908,12 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
19081908
method_modifiers);
19091909

19101910
let category = if impl_modifiers >= method_modifiers {
1911-
ty::ByValueExplicitSelfCategory
1911+
ty::ExplicitSelfCategory::ByValue
19121912
} else {
19131913
match explicit_type.sty {
1914-
ty::TyRef(r, mt) => ty::ByReferenceExplicitSelfCategory(*r, mt.mutbl),
1915-
ty::TyBox(_) => ty::ByBoxExplicitSelfCategory,
1916-
_ => ty::ByValueExplicitSelfCategory,
1914+
ty::TyRef(r, mt) => ty::ExplicitSelfCategory::ByReference(*r, mt.mutbl),
1915+
ty::TyBox(_) => ty::ExplicitSelfCategory::ByBox,
1916+
_ => ty::ExplicitSelfCategory::ByValue,
19171917
}
19181918
};
19191919

src/librustc_typeck/check/compare_method.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
5555
// inscrutable, particularly for cases where one method has no
5656
// self.
5757
match (&trait_m.explicit_self, &impl_m.explicit_self) {
58-
(&ty::StaticExplicitSelfCategory,
59-
&ty::StaticExplicitSelfCategory) => {}
60-
(&ty::StaticExplicitSelfCategory, _) => {
58+
(&ty::ExplicitSelfCategory::Static,
59+
&ty::ExplicitSelfCategory::Static) => {}
60+
(&ty::ExplicitSelfCategory::Static, _) => {
6161
span_err!(tcx.sess, impl_m_span, E0185,
6262
"method `{}` has a `{}` declaration in the impl, \
6363
but not in the trait",
6464
trait_m.name,
6565
impl_m.explicit_self);
6666
return;
6767
}
68-
(_, &ty::StaticExplicitSelfCategory) => {
68+
(_, &ty::ExplicitSelfCategory::Static) => {
6969
span_err!(tcx.sess, impl_m_span, E0186,
7070
"method `{}` has a `{}` declaration in the trait, \
7171
but not in the impl",

src/librustc_typeck/check/method/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
274274
method_ty.explicit_self);
275275

276276
match method_ty.explicit_self {
277-
ty::ByValueExplicitSelfCategory => {
277+
ty::ExplicitSelfCategory::ByValue => {
278278
// Trait method is fn(self), no transformation needed.
279279
assert!(!unsize);
280280
fcx.write_autoderef_adjustment(self_expr.id, autoderefs);
281281
}
282282

283-
ty::ByReferenceExplicitSelfCategory(..) => {
283+
ty::ExplicitSelfCategory::ByReference(..) => {
284284
// Trait method is fn(&self) or fn(&mut self), need an
285285
// autoref. Pull the region etc out of the type of first argument.
286286
match transformed_self_ty.sty {

src/librustc_typeck/check/method/probe.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,10 +1144,10 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
11441144
match *item {
11451145
ty::ImplOrTraitItem::MethodTraitItem(ref method) =>
11461146
match method.explicit_self {
1147-
ty::StaticExplicitSelfCategory => self.mode == Mode::Path,
1148-
ty::ByValueExplicitSelfCategory |
1149-
ty::ByReferenceExplicitSelfCategory(..) |
1150-
ty::ByBoxExplicitSelfCategory => true,
1147+
ty::ExplicitSelfCategory::Static => self.mode == Mode::Path,
1148+
ty::ExplicitSelfCategory::ByValue |
1149+
ty::ExplicitSelfCategory::ByReference(..) |
1150+
ty::ExplicitSelfCategory::ByBox => true,
11511151
},
11521152
ty::ImplOrTraitItem::ConstTraitItem(..) => self.mode == Mode::Path,
11531153
_ => false,

src/librustc_typeck/check/wfcheck.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,15 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
398398
method.name, method.explicit_self, self_ty, sig);
399399

400400
let rcvr_ty = match method.explicit_self {
401-
ty::StaticExplicitSelfCategory => return,
402-
ty::ByValueExplicitSelfCategory => self_ty,
403-
ty::ByReferenceExplicitSelfCategory(region, mutability) => {
401+
ty::ExplicitSelfCategory::Static => return,
402+
ty::ExplicitSelfCategory::ByValue => self_ty,
403+
ty::ExplicitSelfCategory::ByReference(region, mutability) => {
404404
fcx.tcx().mk_ref(fcx.tcx().mk_region(region), ty::TypeAndMut {
405405
ty: self_ty,
406406
mutbl: mutability
407407
})
408408
}
409-
ty::ByBoxExplicitSelfCategory => fcx.tcx().mk_box(self_ty)
409+
ty::ExplicitSelfCategory::ByBox => fcx.tcx().mk_box(self_ty)
410410
};
411411
let rcvr_ty = fcx.instantiate_type_scheme(span, free_substs, &rcvr_ty);
412412
let rcvr_ty = fcx.tcx().liberate_late_bound_regions(free_id_outlive,

src/librustdoc/clean/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,27 +1306,27 @@ impl Clean<Item> for hir::ImplItem {
13061306
impl<'tcx> Clean<Item> for ty::Method<'tcx> {
13071307
fn clean(&self, cx: &DocContext) -> Item {
13081308
let (self_, sig) = match self.explicit_self {
1309-
ty::StaticExplicitSelfCategory => (hir::SelfStatic.clean(cx),
1310-
self.fty.sig.clone()),
1309+
ty::ExplicitSelfCategory::Static => (hir::SelfStatic.clean(cx),
1310+
self.fty.sig.clone()),
13111311
s => {
13121312
let sig = ty::Binder(ty::FnSig {
13131313
inputs: self.fty.sig.0.inputs[1..].to_vec(),
13141314
..self.fty.sig.0.clone()
13151315
});
13161316
let s = match s {
1317-
ty::ByValueExplicitSelfCategory => SelfValue,
1318-
ty::ByReferenceExplicitSelfCategory(..) => {
1317+
ty::ExplicitSelfCategory::ByValue => SelfValue,
1318+
ty::ExplicitSelfCategory::ByReference(..) => {
13191319
match self.fty.sig.0.inputs[0].sty {
13201320
ty::TyRef(r, mt) => {
13211321
SelfBorrowed(r.clean(cx), mt.mutbl.clean(cx))
13221322
}
13231323
_ => unreachable!(),
13241324
}
13251325
}
1326-
ty::ByBoxExplicitSelfCategory => {
1326+
ty::ExplicitSelfCategory::ByBox => {
13271327
SelfExplicit(self.fty.sig.0.inputs[0].clean(cx))
13281328
}
1329-
ty::StaticExplicitSelfCategory => unreachable!(),
1329+
ty::ExplicitSelfCategory::Static => unreachable!(),
13301330
};
13311331
(s, sig)
13321332
}

0 commit comments

Comments
 (0)