X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_middle%2Fsrc%2Fty%2Fquery.rs;h=1be819ca610c7c644f7b3c9c9325f4c52bf81494;hb=72599c69b5db0ea87a843d6f546af1d10ded34a1;hp=9d4ee22a7273beba58c8cb282379a132a7585c03;hpb=333ee6c466972185973d5097f8b5fb0f9fb13fa5;p=rust.git diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index 9d4ee22a727..1be819ca610 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -118,6 +118,7 @@ fn copy(x: &T) -> T { macro_rules! query_helper_param_ty { (DefId) => { impl IntoQueryParam }; + (LocalDefId) => { impl IntoQueryParam }; ($K:ty) => { $K }; } @@ -418,6 +419,13 @@ fn into_query_param(self) -> P { } } + impl IntoQueryParam for OwnerId { + #[inline(always)] + fn into_query_param(self) -> LocalDefId { + self.def_id + } + } + impl IntoQueryParam for LocalDefId { #[inline(always)] fn into_query_param(self) -> DefId { @@ -441,6 +449,10 @@ pub fn def_kind(self, def_id: impl IntoQueryParam) -> DefKind { self.opt_def_kind(def_id) .unwrap_or_else(|| bug!("def_kind: unsupported node: {:?}", def_id)) } + + pub fn bound_type_of(self, def_id: impl IntoQueryParam) -> ty::EarlyBinder> { + ty::EarlyBinder(self.type_of(def_id)) + } } impl<'tcx> TyCtxtAt<'tcx> { @@ -449,4 +461,8 @@ pub fn def_kind(self, def_id: impl IntoQueryParam) -> DefKind { self.opt_def_kind(def_id) .unwrap_or_else(|| bug!("def_kind: unsupported node: {:?}", def_id)) } + + pub fn bound_type_of(self, def_id: impl IntoQueryParam) -> ty::EarlyBinder> { + ty::EarlyBinder(self.type_of(def_id)) + } }