@@ -117,7 +117,7 @@ use crate::ich::StableHashingContext;
117117use crate :: metadata:: { AmbigModChild , ModChild } ;
118118use crate :: middle:: privacy:: EffectiveVisibilities ;
119119use crate :: mir:: { Body , CoroutineLayout , CoroutineSavedLocal , SourceInfo } ;
120- use crate :: query:: { IntoQueryParam , Providers } ;
120+ use crate :: query:: { IntoQueryKey , Providers } ;
121121use crate :: ty;
122122use crate :: ty:: codec:: { TyDecoder , TyEncoder } ;
123123pub use crate :: ty:: diagnostics:: * ;
@@ -1031,12 +1031,14 @@ impl<'tcx> TypingEnv<'tcx> {
10311031 /// converted to use proper canonical inputs instead.
10321032 pub fn non_body_analysis (
10331033 tcx : TyCtxt < ' tcx > ,
1034- def_id : impl IntoQueryParam < DefId > ,
1034+ def_id : impl IntoQueryKey < DefId > ,
10351035 ) -> TypingEnv < ' tcx > {
1036+ let def_id = def_id. into_query_key ( ) ;
10361037 TypingEnv { typing_mode : TypingMode :: non_body_analysis ( ) , param_env : tcx. param_env ( def_id) }
10371038 }
10381039
1039- pub fn post_analysis ( tcx : TyCtxt < ' tcx > , def_id : impl IntoQueryParam < DefId > ) -> TypingEnv < ' tcx > {
1040+ pub fn post_analysis ( tcx : TyCtxt < ' tcx > , def_id : impl IntoQueryKey < DefId > ) -> TypingEnv < ' tcx > {
1041+ let def_id = def_id. into_query_key ( ) ;
10401042 tcx. typing_env_normalized_for_post_analysis ( def_id)
10411043 }
10421044
@@ -1528,8 +1530,8 @@ impl<'tcx> TyCtxt<'tcx> {
15281530 }
15291531
15301532 /// Look up the name of a definition across crates. This does not look at HIR.
1531- pub fn opt_item_name ( self , def_id : impl IntoQueryParam < DefId > ) -> Option < Symbol > {
1532- let def_id = def_id. into_query_param ( ) ;
1533+ pub fn opt_item_name ( self , def_id : impl IntoQueryKey < DefId > ) -> Option < Symbol > {
1534+ let def_id = def_id. into_query_key ( ) ;
15331535 if let Some ( cnum) = def_id. as_crate_root ( ) {
15341536 Some ( self . crate_name ( cnum) )
15351537 } else {
@@ -1549,8 +1551,8 @@ impl<'tcx> TyCtxt<'tcx> {
15491551 /// [`opt_item_name`] instead.
15501552 ///
15511553 /// [`opt_item_name`]: Self::opt_item_name
1552- pub fn item_name ( self , id : impl IntoQueryParam < DefId > ) -> Symbol {
1553- let id = id. into_query_param ( ) ;
1554+ pub fn item_name ( self , id : impl IntoQueryKey < DefId > ) -> Symbol {
1555+ let id = id. into_query_key ( ) ;
15541556 self . opt_item_name ( id) . unwrap_or_else ( || {
15551557 bug ! ( "item_name: no name for {:?}" , self . def_path( id) ) ;
15561558 } )
@@ -1559,8 +1561,8 @@ impl<'tcx> TyCtxt<'tcx> {
15591561 /// Look up the name and span of a definition.
15601562 ///
15611563 /// See [`item_name`][Self::item_name] for more information.
1562- pub fn opt_item_ident ( self , def_id : impl IntoQueryParam < DefId > ) -> Option < Ident > {
1563- let def_id = def_id. into_query_param ( ) ;
1564+ pub fn opt_item_ident ( self , def_id : impl IntoQueryKey < DefId > ) -> Option < Ident > {
1565+ let def_id = def_id. into_query_key ( ) ;
15641566 let def = self . opt_item_name ( def_id) ?;
15651567 let span = self
15661568 . def_ident_span ( def_id)
@@ -1571,8 +1573,8 @@ impl<'tcx> TyCtxt<'tcx> {
15711573 /// Look up the name and span of a definition.
15721574 ///
15731575 /// See [`item_name`][Self::item_name] for more information.
1574- pub fn item_ident ( self , def_id : impl IntoQueryParam < DefId > ) -> Ident {
1575- let def_id = def_id. into_query_param ( ) ;
1576+ pub fn item_ident ( self , def_id : impl IntoQueryKey < DefId > ) -> Ident {
1577+ let def_id = def_id. into_query_key ( ) ;
15761578 self . opt_item_ident ( def_id) . unwrap_or_else ( || {
15771579 bug ! ( "item_ident: no name for {:?}" , self . def_path( def_id) ) ;
15781580 } )
@@ -1902,8 +1904,9 @@ impl<'tcx> TyCtxt<'tcx> {
19021904 }
19031905
19041906 /// Returns the trait item that is implemented by the given item `DefId`.
1905- pub fn trait_item_of ( self , def_id : impl IntoQueryParam < DefId > ) -> Option < DefId > {
1906- self . opt_associated_item ( def_id. into_query_param ( ) ) ?. trait_item_def_id ( )
1907+ pub fn trait_item_of ( self , def_id : impl IntoQueryKey < DefId > ) -> Option < DefId > {
1908+ let def_id = def_id. into_query_key ( ) ;
1909+ self . opt_associated_item ( def_id) ?. trait_item_def_id ( )
19071910 }
19081911
19091912 /// If the given `DefId` is an associated item of a trait,
@@ -1915,8 +1918,8 @@ impl<'tcx> TyCtxt<'tcx> {
19151918 }
19161919 }
19171920
1918- pub fn impl_is_of_trait ( self , def_id : impl IntoQueryParam < DefId > ) -> bool {
1919- let def_id = def_id. into_query_param ( ) ;
1921+ pub fn impl_is_of_trait ( self , def_id : impl IntoQueryKey < DefId > ) -> bool {
1922+ let def_id = def_id. into_query_key ( ) ;
19201923 let DefKind :: Impl { of_trait } = self . def_kind ( def_id) else {
19211924 panic ! ( "expected Impl for {def_id:?}" ) ;
19221925 } ;
@@ -1950,37 +1953,40 @@ impl<'tcx> TyCtxt<'tcx> {
19501953 }
19511954 }
19521955
1953- pub fn impl_polarity ( self , def_id : impl IntoQueryParam < DefId > ) -> ty:: ImplPolarity {
1956+ pub fn impl_polarity ( self , def_id : impl IntoQueryKey < DefId > ) -> ty:: ImplPolarity {
1957+ let def_id = def_id. into_query_key ( ) ;
19541958 self . impl_trait_header ( def_id) . polarity
19551959 }
19561960
19571961 /// Given an `impl_id`, return the trait it implements.
19581962 pub fn impl_trait_ref (
19591963 self ,
1960- def_id : impl IntoQueryParam < DefId > ,
1964+ def_id : impl IntoQueryKey < DefId > ,
19611965 ) -> ty:: EarlyBinder < ' tcx , ty:: TraitRef < ' tcx > > {
1966+ let def_id = def_id. into_query_key ( ) ;
19621967 self . impl_trait_header ( def_id) . trait_ref
19631968 }
19641969
19651970 /// Given an `impl_id`, return the trait it implements.
19661971 /// Returns `None` if it is an inherent impl.
19671972 pub fn impl_opt_trait_ref (
19681973 self ,
1969- def_id : impl IntoQueryParam < DefId > ,
1974+ def_id : impl IntoQueryKey < DefId > ,
19701975 ) -> Option < ty:: EarlyBinder < ' tcx , ty:: TraitRef < ' tcx > > > {
1971- let def_id = def_id. into_query_param ( ) ;
1976+ let def_id = def_id. into_query_key ( ) ;
19721977 self . impl_is_of_trait ( def_id) . then ( || self . impl_trait_ref ( def_id) )
19731978 }
19741979
19751980 /// Given the `DefId` of an impl, returns the `DefId` of the trait it implements.
1976- pub fn impl_trait_id ( self , def_id : impl IntoQueryParam < DefId > ) -> DefId {
1981+ pub fn impl_trait_id ( self , def_id : impl IntoQueryKey < DefId > ) -> DefId {
1982+ let def_id = def_id. into_query_key ( ) ;
19771983 self . impl_trait_ref ( def_id) . skip_binder ( ) . def_id
19781984 }
19791985
19801986 /// Given the `DefId` of an impl, returns the `DefId` of the trait it implements.
19811987 /// Returns `None` if it is an inherent impl.
1982- pub fn impl_opt_trait_id ( self , def_id : impl IntoQueryParam < DefId > ) -> Option < DefId > {
1983- let def_id = def_id. into_query_param ( ) ;
1988+ pub fn impl_opt_trait_id ( self , def_id : impl IntoQueryKey < DefId > ) -> Option < DefId > {
1989+ let def_id = def_id. into_query_key ( ) ;
19841990 self . impl_is_of_trait ( def_id) . then ( || self . impl_trait_id ( def_id) )
19851991 }
19861992
0 commit comments