]> git.lizzy.rs Git - rust.git/commitdiff
Rename ExplicitSelfCategory's variants and stop re-exporting them.
authorMs2ger <Ms2ger@gmail.com>
Mon, 28 Dec 2015 11:52:43 +0000 (12:52 +0100)
committerMs2ger <Ms2ger@gmail.com>
Mon, 28 Dec 2015 11:52:43 +0000 (12:52 +0100)
12 files changed:
src/librustc/middle/traits/object_safety.rs
src/librustc/middle/ty/mod.rs
src/librustc/util/ppaux.rs
src/librustc_metadata/decoder.rs
src/librustc_metadata/encoder.rs
src/librustc_trans/save/dump_csv.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/wfcheck.rs
src/librustdoc/clean/mod.rs

index bd60d0a212252f549ba9c54d5437bf1a74a30ee3..c8e34165b90212e9e924a8a38e5b423f809f5d52 100644 (file)
@@ -254,13 +254,13 @@ fn virtual_call_violation_for_method<'tcx>(tcx: &ty::ctxt<'tcx>,
     // autorefs) to `&self`. For now, we only accept `self`, `&self`
     // and `Box<Self>`.
     match method.explicit_self {
-        ty::StaticExplicitSelfCategory => {
+        ty::ExplicitSelfCategory::Static => {
             return Some(MethodViolationCode::StaticMethod);
         }
 
-        ty::ByValueExplicitSelfCategory |
-        ty::ByReferenceExplicitSelfCategory(..) |
-        ty::ByBoxExplicitSelfCategory => {
+        ty::ExplicitSelfCategory::ByValue |
+        ty::ExplicitSelfCategory::ByReference(..) |
+        ty::ExplicitSelfCategory::ByBox => {
         }
     }
 
index 50c9a1a31f2208b047638d239f2fe4f6a586d646..5daa9bcd0d1ae0a89d49961d4f8fea668f9c4d67 100644 (file)
@@ -12,7 +12,6 @@
 pub use self::ClosureKind::*;
 pub use self::Variance::*;
 pub use self::DtorKind::*;
-pub use self::ExplicitSelfCategory::*;
 pub use self::ImplOrTraitItemContainer::*;
 pub use self::BorrowKind::*;
 pub use self::ImplOrTraitItem::*;
@@ -2733,10 +2732,10 @@ pub fn upvar_capture(&self, upvar_id: ty::UpvarId) -> Option<ty::UpvarCapture> {
 /// The category of explicit self.
 #[derive(Clone, Copy, Eq, PartialEq, Debug)]
 pub enum ExplicitSelfCategory {
-    StaticExplicitSelfCategory,
-    ByValueExplicitSelfCategory,
-    ByReferenceExplicitSelfCategory(Region, hir::Mutability),
-    ByBoxExplicitSelfCategory,
+    Static,
+    ByValue,
+    ByReference(Region, hir::Mutability),
+    ByBox,
 }
 
 /// A free variable referred to in a function.
index 0b362be215dfef40e6b9bc83158bb7430523436a..11d3068f065b7fb2578f35e38440116f6765decf 100644 (file)
@@ -919,13 +919,13 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 impl fmt::Display for ty::ExplicitSelfCategory {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.write_str(match *self {
-            ty::StaticExplicitSelfCategory => "static",
-            ty::ByValueExplicitSelfCategory => "self",
-            ty::ByReferenceExplicitSelfCategory(_, hir::MutMutable) => {
+            ty::ExplicitSelfCategory::Static => "static",
+            ty::ExplicitSelfCategory::ByValue => "self",
+            ty::ExplicitSelfCategory::ByReference(_, hir::MutMutable) => {
                 "&mut self"
             }
-            ty::ByReferenceExplicitSelfCategory(_, hir::MutImmutable) => "&self",
-            ty::ByBoxExplicitSelfCategory => "Box<self>",
+            ty::ExplicitSelfCategory::ByReference(_, hir::MutImmutable) => "&self",
+            ty::ExplicitSelfCategory::ByBox => "Box<self>",
         })
     }
 }
index 8126970759e6dcc7e0adaaf3c202126fa0820422..29fe9bc759ddece4164284ffe37daea4c7e9519b 100644 (file)
@@ -884,12 +884,12 @@ fn get_mutability(ch: u8) -> hir::Mutability {
 
     let explicit_self_kind = string.as_bytes()[0];
     match explicit_self_kind as char {
-        's' => ty::StaticExplicitSelfCategory,
-        'v' => ty::ByValueExplicitSelfCategory,
-        '~' => ty::ByBoxExplicitSelfCategory,
+        's' => ty::ExplicitSelfCategory::Static,
+        'v' => ty::ExplicitSelfCategory::ByValue,
+        '~' => ty::ExplicitSelfCategory::ByBox,
         // FIXME(#4846) expl. region
         '&' => {
-            ty::ByReferenceExplicitSelfCategory(
+            ty::ExplicitSelfCategory::ByReference(
                 ty::ReEmpty,
                 get_mutability(string.as_bytes()[1]))
         }
@@ -923,7 +923,7 @@ pub fn is_static_method(cdata: Cmd, id: DefIndex) -> bool {
     let doc = cdata.lookup_item(id);
     match item_sort(doc) {
         Some('r') | Some('p') => {
-            get_explicit_self(doc) == ty::StaticExplicitSelfCategory
+            get_explicit_self(doc) == ty::ExplicitSelfCategory::Static
         }
         _ => false
     }
index cd70172e8fa2112500da97662a9d337d2cd87451..f1c5d47df8889789f64535efc03960c156d6d980 100644 (file)
@@ -498,16 +498,16 @@ fn encode_explicit_self(rbml_w: &mut Encoder,
 
     // Encode the base self type.
     match *explicit_self {
-        ty::StaticExplicitSelfCategory => {
+        ty::ExplicitSelfCategory::Static => {
             rbml_w.wr_tagged_bytes(tag, &['s' as u8]);
         }
-        ty::ByValueExplicitSelfCategory => {
+        ty::ExplicitSelfCategory::ByValue => {
             rbml_w.wr_tagged_bytes(tag, &['v' as u8]);
         }
-        ty::ByBoxExplicitSelfCategory => {
+        ty::ExplicitSelfCategory::ByBox => {
             rbml_w.wr_tagged_bytes(tag, &['~' as u8]);
         }
-        ty::ByReferenceExplicitSelfCategory(_, m) => {
+        ty::ExplicitSelfCategory::ByReference(_, m) => {
             // FIXME(#4846) encode custom lifetime
             let ch = encode_mutability(m);
             rbml_w.wr_tagged_bytes(tag, &['&' as u8, ch]);
@@ -675,7 +675,7 @@ fn encode_method_ty_fields<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
     encode_visibility(rbml_w, method_ty.vis);
     encode_explicit_self(rbml_w, &method_ty.explicit_self);
     match method_ty.explicit_self {
-        ty::StaticExplicitSelfCategory => {
+        ty::ExplicitSelfCategory::Static => {
             encode_family(rbml_w, STATIC_METHOD_FAMILY);
         }
         _ => encode_family(rbml_w, METHOD_FAMILY)
@@ -1340,7 +1340,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
                                 path.clone().chain(Some(elem)));
 
                     match method_ty.explicit_self {
-                        ty::StaticExplicitSelfCategory => {
+                        ty::ExplicitSelfCategory::Static => {
                             encode_family(rbml_w,
                                           STATIC_METHOD_FAMILY);
                         }
@@ -1353,7 +1353,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
                                                     ecx.local_id(method_def_id));
 
                     is_nonstatic_method = method_ty.explicit_self !=
-                        ty::StaticExplicitSelfCategory;
+                        ty::ExplicitSelfCategory::Static;
                 }
                 ty::TypeTraitItem(associated_type) => {
                     encode_name(rbml_w, associated_type.name);
index 9c6b54e13796de6b9e2682a0a9c50978b841db8e..c34013a7bbbb1b56d8955e44954e748ec32ba02d 100644 (file)
@@ -682,7 +682,7 @@ fn process_path(&mut self, id: NodeId, path: &ast::Path, ref_kind: Option<record
             def::DefMethod(did) => {
                 let ti = self.tcx.impl_or_trait_item(did);
                 if let ty::MethodTraitItem(m) = ti {
-                    if m.explicit_self == ty::StaticExplicitSelfCategory {
+                    if m.explicit_self == ty::ExplicitSelfCategory::Static {
                         self.write_sub_path_trait_truncated(path);
                     }
                 }
index 95d85964044da7be0ef5175ed104128ecf6d213a..4790c7392db1fb39ebea94886466d8f62456832f 100644 (file)
@@ -1815,7 +1815,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
     // reference) in the arguments, then any anonymous regions in the output
     // have that lifetime.
     let implied_output_region = match explicit_self_category {
-        Some(ty::ByReferenceExplicitSelfCategory(region, _)) => Ok(region),
+        Some(ty::ExplicitSelfCategory::ByReference(region, _)) => Ok(region),
         _ => find_implied_output_region(this.tcx(), &arg_tys, arg_pats)
     };
 
@@ -1846,9 +1846,9 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
 {
     let self_ty = self_info.untransformed_self_ty;
     return match self_info.explicit_self.node {
-        hir::SelfStatic => (None, Some(ty::StaticExplicitSelfCategory)),
+        hir::SelfStatic => (None, Some(ty::ExplicitSelfCategory::Static)),
         hir::SelfValue(_) => {
-            (Some(self_ty), Some(ty::ByValueExplicitSelfCategory))
+            (Some(self_ty), Some(ty::ExplicitSelfCategory::ByValue))
         }
         hir::SelfRegion(ref lifetime, mutability, _) => {
             let region =
@@ -1862,7 +1862,7 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
                     ty: self_ty,
                     mutbl: mutability
                 })),
-             Some(ty::ByReferenceExplicitSelfCategory(region, mutability)))
+             Some(ty::ExplicitSelfCategory::ByReference(region, mutability)))
         }
         hir::SelfExplicit(ref ast_type, _) => {
             let explicit_type = ast_ty_to_ty(this, rscope, &**ast_type);
@@ -1878,12 +1878,12 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
             // ```
             // impl Foo for &T {
             //     // Legal declarations:
-            //     fn method1(self: &&T); // ByReferenceExplicitSelfCategory
-            //     fn method2(self: &T); // ByValueExplicitSelfCategory
-            //     fn method3(self: Box<&T>); // ByBoxExplicitSelfCategory
+            //     fn method1(self: &&T); // ExplicitSelfCategory::ByReference
+            //     fn method2(self: &T); // ExplicitSelfCategory::ByValue
+            //     fn method3(self: Box<&T>); // ExplicitSelfCategory::ByBox
             //
             //     // Invalid cases will be caught later by `check_method_self_type`:
-            //     fn method_err1(self: &mut T); // ByReferenceExplicitSelfCategory
+            //     fn method_err1(self: &mut T); // ExplicitSelfCategory::ByReference
             // }
             // ```
             //
@@ -1894,7 +1894,7 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
             // call it by-ref, by-box as appropriate. For method1, for
             // example, the impl type has one modifier, but the method
             // type has two, so we end up with
-            // ByReferenceExplicitSelfCategory.
+            // ExplicitSelfCategory::ByReference.
 
             let impl_modifiers = count_modifiers(self_info.untransformed_self_ty);
             let method_modifiers = count_modifiers(explicit_type);
@@ -1908,12 +1908,12 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>,
                    method_modifiers);
 
             let category = if impl_modifiers >= method_modifiers {
-                ty::ByValueExplicitSelfCategory
+                ty::ExplicitSelfCategory::ByValue
             } else {
                 match explicit_type.sty {
-                    ty::TyRef(r, mt) => ty::ByReferenceExplicitSelfCategory(*r, mt.mutbl),
-                    ty::TyBox(_) => ty::ByBoxExplicitSelfCategory,
-                    _ => ty::ByValueExplicitSelfCategory,
+                    ty::TyRef(r, mt) => ty::ExplicitSelfCategory::ByReference(*r, mt.mutbl),
+                    ty::TyBox(_) => ty::ExplicitSelfCategory::ByBox,
+                    _ => ty::ExplicitSelfCategory::ByValue,
                 }
             };
 
index d28a673f748c07c46157d74a253d9d386a908b5a..554424a36b19af688259725a2efaf3ad87e5642a 100644 (file)
@@ -55,9 +55,9 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
     // inscrutable, particularly for cases where one method has no
     // self.
     match (&trait_m.explicit_self, &impl_m.explicit_self) {
-        (&ty::StaticExplicitSelfCategory,
-         &ty::StaticExplicitSelfCategory) => {}
-        (&ty::StaticExplicitSelfCategory, _) => {
+        (&ty::ExplicitSelfCategory::Static,
+         &ty::ExplicitSelfCategory::Static) => {}
+        (&ty::ExplicitSelfCategory::Static, _) => {
             span_err!(tcx.sess, impl_m_span, E0185,
                 "method `{}` has a `{}` declaration in the impl, \
                         but not in the trait",
@@ -65,7 +65,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
                         impl_m.explicit_self);
             return;
         }
-        (_, &ty::StaticExplicitSelfCategory) => {
+        (_, &ty::ExplicitSelfCategory::Static) => {
             span_err!(tcx.sess, impl_m_span, E0186,
                 "method `{}` has a `{}` declaration in the trait, \
                         but not in the impl",
index e0ad51b4ea1b54532dd56d0fe0d763d7aa5ab9ed..a961268c6c49bd8244e5072f6828c1c3a72a063c 100644 (file)
@@ -274,13 +274,13 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                    method_ty.explicit_self);
 
             match method_ty.explicit_self {
-                ty::ByValueExplicitSelfCategory => {
+                ty::ExplicitSelfCategory::ByValue => {
                     // Trait method is fn(self), no transformation needed.
                     assert!(!unsize);
                     fcx.write_autoderef_adjustment(self_expr.id, autoderefs);
                 }
 
-                ty::ByReferenceExplicitSelfCategory(..) => {
+                ty::ExplicitSelfCategory::ByReference(..) => {
                     // Trait method is fn(&self) or fn(&mut self), need an
                     // autoref. Pull the region etc out of the type of first argument.
                     match transformed_self_ty.sty {
index ed819d46041e60ce45c5db274a6501b725a64003..3bf24aba62467d21652501118268abe9d2695818 100644 (file)
@@ -1144,10 +1144,10 @@ fn has_applicable_self(&self, item: &ty::ImplOrTraitItem) -> bool {
         match *item {
             ty::ImplOrTraitItem::MethodTraitItem(ref method) =>
                 match method.explicit_self {
-                    ty::StaticExplicitSelfCategory => self.mode == Mode::Path,
-                    ty::ByValueExplicitSelfCategory |
-                    ty::ByReferenceExplicitSelfCategory(..) |
-                    ty::ByBoxExplicitSelfCategory => true,
+                    ty::ExplicitSelfCategory::Static => self.mode == Mode::Path,
+                    ty::ExplicitSelfCategory::ByValue |
+                    ty::ExplicitSelfCategory::ByReference(..) |
+                    ty::ExplicitSelfCategory::ByBox => true,
                 },
             ty::ImplOrTraitItem::ConstTraitItem(..) => self.mode == Mode::Path,
             _ => false,
index 230422b7044cd5d366463efc59d885daf57eec84..e6bebaf7f75c47475a2bb464156b2681adb17c3b 100644 (file)
@@ -398,15 +398,15 @@ fn check_method_receiver<'fcx>(&mut self,
                method.name, method.explicit_self, self_ty, sig);
 
         let rcvr_ty = match method.explicit_self {
-            ty::StaticExplicitSelfCategory => return,
-            ty::ByValueExplicitSelfCategory => self_ty,
-            ty::ByReferenceExplicitSelfCategory(region, mutability) => {
+            ty::ExplicitSelfCategory::Static => return,
+            ty::ExplicitSelfCategory::ByValue => self_ty,
+            ty::ExplicitSelfCategory::ByReference(region, mutability) => {
                 fcx.tcx().mk_ref(fcx.tcx().mk_region(region), ty::TypeAndMut {
                     ty: self_ty,
                     mutbl: mutability
                 })
             }
-            ty::ByBoxExplicitSelfCategory => fcx.tcx().mk_box(self_ty)
+            ty::ExplicitSelfCategory::ByBox => fcx.tcx().mk_box(self_ty)
         };
         let rcvr_ty = fcx.instantiate_type_scheme(span, free_substs, &rcvr_ty);
         let rcvr_ty = fcx.tcx().liberate_late_bound_regions(free_id_outlive,
index 675eef637b10b7626a83b476ae79a084b7df973b..d2a5fd457d2fba4cdc9183f06796ad1d05ee037b 100644 (file)
@@ -1306,16 +1306,16 @@ fn clean(&self, cx: &DocContext) -> Item {
 impl<'tcx> Clean<Item> for ty::Method<'tcx> {
     fn clean(&self, cx: &DocContext) -> Item {
         let (self_, sig) = match self.explicit_self {
-            ty::StaticExplicitSelfCategory => (hir::SelfStatic.clean(cx),
-                                               self.fty.sig.clone()),
+            ty::ExplicitSelfCategory::Static => (hir::SelfStatic.clean(cx),
+                                                 self.fty.sig.clone()),
             s => {
                 let sig = ty::Binder(ty::FnSig {
                     inputs: self.fty.sig.0.inputs[1..].to_vec(),
                     ..self.fty.sig.0.clone()
                 });
                 let s = match s {
-                    ty::ByValueExplicitSelfCategory => SelfValue,
-                    ty::ByReferenceExplicitSelfCategory(..) => {
+                    ty::ExplicitSelfCategory::ByValue => SelfValue,
+                    ty::ExplicitSelfCategory::ByReference(..) => {
                         match self.fty.sig.0.inputs[0].sty {
                             ty::TyRef(r, mt) => {
                                 SelfBorrowed(r.clean(cx), mt.mutbl.clean(cx))
@@ -1323,10 +1323,10 @@ fn clean(&self, cx: &DocContext) -> Item {
                             _ => unreachable!(),
                         }
                     }
-                    ty::ByBoxExplicitSelfCategory => {
+                    ty::ExplicitSelfCategory::ByBox => {
                         SelfExplicit(self.fty.sig.0.inputs[0].clean(cx))
                     }
-                    ty::StaticExplicitSelfCategory => unreachable!(),
+                    ty::ExplicitSelfCategory::Static => unreachable!(),
                 };
                 (s, sig)
             }