]> git.lizzy.rs Git - rust.git/commitdiff
Apply suggestions from review
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Fri, 10 Apr 2020 21:06:57 +0000 (14:06 -0700)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Sat, 11 Apr 2020 22:18:51 +0000 (15:18 -0700)
src/librustc_middle/ty/query/mod.rs
src/librustc_span/def_id.rs

index 9f04cff4d2fb9d591c917b463c441b67440cf02f..76e519c990ed50c72639eb5df9129fb1efe968e8 100644 (file)
@@ -190,22 +190,28 @@ pub(crate) fn try_load_from_on_disk_cache<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &De
     rustc_dep_node_try_load_from_on_disk_cache!(dep_node, tcx)
 }
 
-/// An analogue of the `Into` trait that's intended only for query paramaters.
-///
-/// This exists to allow queries to accept either `DefId` or `LocalDefId` while requiring that the
-/// user call `to_def_id` to convert between them everywhere else.
-pub trait IntoQueryParam<P> {
-    fn into_query_param(self) -> P;
-}
+mod sealed {
+    use super::{DefId, LocalDefId};
+
+    /// An analogue of the `Into` trait that's intended only for query paramaters.
+    ///
+    /// This exists to allow queries to accept either `DefId` or `LocalDefId` while requiring that the
+    /// user call `to_def_id` to convert between them everywhere else.
+    pub trait IntoQueryParam<P> {
+        fn into_query_param(self) -> P;
+    }
 
-impl<P> IntoQueryParam<P> for P {
-    fn into_query_param(self) -> P {
-        self
+    impl<P> IntoQueryParam<P> for P {
+        fn into_query_param(self) -> P {
+            self
+        }
     }
-}
 
-impl IntoQueryParam<DefId> for LocalDefId {
-    fn into_query_param(self) -> DefId {
-        self.to_def_id()
+    impl IntoQueryParam<DefId> for LocalDefId {
+        fn into_query_param(self) -> DefId {
+            self.to_def_id()
+        }
     }
 }
+
+use sealed::IntoQueryParam;
index a3909904e8ce7495f4c338eb0cb04166a049aee3..fad9f2f613012db8ac9e00610a75911865b41c5f 100644 (file)
@@ -237,12 +237,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     }
 }
 
-impl From<LocalDefId> for DefId {
-    fn from(v: LocalDefId) -> Self {
-        v.to_def_id()
-    }
-}
-
 impl rustc_serialize::UseSpecializedEncodable for LocalDefId {}
 impl rustc_serialize::UseSpecializedDecodable for LocalDefId {}