@@ -576,11 +576,13 @@ rustc_queries! {
576
576
desc { |tcx| "collecting associated items of {}" , tcx. def_path_str( key) }
577
577
}
578
578
579
- query impl_trait_ref( key: DefId ) -> Option <ty:: TraitRef <' tcx>> {
580
- desc { |tcx| "computing trait implemented by `{}`" , tcx. def_path_str( key) }
579
+ /// Given an `impl_id`, return the trait it implements.
580
+ /// Return `None` if this is an inherent impl.
581
+ query impl_trait_ref( impl_id: DefId ) -> Option <ty:: TraitRef <' tcx>> {
582
+ desc { |tcx| "computing trait implemented by `{}`" , tcx. def_path_str( impl_id) }
581
583
}
582
- query impl_polarity( key : DefId ) -> ty:: ImplPolarity {
583
- desc { |tcx| "computing implementation polarity of `{}`" , tcx. def_path_str( key ) }
584
+ query impl_polarity( impl_id : DefId ) -> ty:: ImplPolarity {
585
+ desc { |tcx| "computing implementation polarity of `{}`" , tcx. def_path_str( impl_id ) }
584
586
}
585
587
586
588
query issue33140_self_ty( key: DefId ) -> Option <ty:: Ty <' tcx>> {
@@ -917,8 +919,10 @@ rustc_queries! {
917
919
}
918
920
919
921
TypeChecking {
920
- query trait_of_item( def_id: DefId ) -> Option <DefId > {
921
- desc { |tcx| "finding trait defining `{}`" , tcx. def_path_str( def_id) }
922
+ /// Given an `associated_item`, find the trait it belongs to.
923
+ /// Return `None` if the `DefId` is not an associated item.
924
+ query trait_of_item( associated_item: DefId ) -> Option <DefId > {
925
+ desc { |tcx| "finding trait defining `{}`" , tcx. def_path_str( associated_item) }
922
926
}
923
927
}
924
928
@@ -948,27 +952,37 @@ rustc_queries! {
948
952
}
949
953
950
954
TypeChecking {
951
- query all_local_trait_impls( key: CrateNum ) -> & ' tcx BTreeMap <DefId , Vec <hir:: HirId >> {
955
+ /// Return all `impl` blocks in the current crate.
956
+ ///
957
+ /// To allow caching this between crates, you must pass in [`LOCAL_CRATE`] as the crate number.
958
+ /// Passing in any other crate will cause an ICE.
959
+ ///
960
+ /// [`LOCAL_CRATE`]: rustc_hir::def_id::LOCAL_CRATE
961
+ query all_local_trait_impls( local_crate: CrateNum ) -> & ' tcx BTreeMap <DefId , Vec <hir:: HirId >> {
952
962
desc { "local trait impls" }
953
963
}
954
- query trait_impls_of( key: DefId ) -> ty:: trait_def:: TraitImpls {
964
+
965
+ /// Given a trait `trait_id`, return all known `impl` blocks.
966
+ query trait_impls_of( trait_id: DefId ) -> ty:: trait_def:: TraitImpls {
955
967
storage( ArenaCacheSelector <' tcx>)
956
- desc { |tcx| "trait impls of `{}`" , tcx. def_path_str( key ) }
968
+ desc { |tcx| "trait impls of `{}`" , tcx. def_path_str( trait_id ) }
957
969
}
958
- query specialization_graph_of( key: DefId ) -> specialization_graph:: Graph {
970
+
971
+ query specialization_graph_of( trait_id: DefId ) -> specialization_graph:: Graph {
959
972
storage( ArenaCacheSelector <' tcx>)
960
- desc { |tcx| "building specialization graph of trait `{}`" , tcx. def_path_str( key ) }
973
+ desc { |tcx| "building specialization graph of trait `{}`" , tcx. def_path_str( trait_id ) }
961
974
cache_on_disk_if { true }
962
975
}
963
- query object_safety_violations( key : DefId ) -> & ' tcx [ traits:: ObjectSafetyViolation ] {
964
- desc { |tcx| "determine object safety of trait `{}`" , tcx. def_path_str( key ) }
976
+ query object_safety_violations( trait_id : DefId ) -> & ' tcx [ traits:: ObjectSafetyViolation ] {
977
+ desc { |tcx| "determine object safety of trait `{}`" , tcx. def_path_str( trait_id ) }
965
978
}
966
979
967
980
/// Gets the ParameterEnvironment for a given item; this environment
968
981
/// will be in "user-facing" mode, meaning that it is suitable for
969
982
/// type-checking etc, and it does not normalize specializable
970
983
/// associated types. This is almost always what you want,
971
984
/// unless you are doing MIR optimizations, in which case you
985
+ /// might want to use `reveal_all()` method to change modes.
972
986
query param_env( def_id: DefId ) -> ty:: ParamEnv <' tcx> {
973
987
desc { |tcx| "computing normalized predicates of `{}`" , tcx. def_path_str( def_id) }
974
988
}
@@ -1229,10 +1243,15 @@ rustc_queries! {
1229
1243
}
1230
1244
1231
1245
TypeChecking {
1246
+ /// Given a crate and a trait, look up all impls of that trait in the crate.
1247
+ /// Return `(impl_id, self_ty)`.
1232
1248
query implementations_of_trait( _: ( CrateNum , DefId ) )
1233
1249
-> & ' tcx [ ( DefId , Option <ty:: fast_reject:: SimplifiedType >) ] {
1234
1250
desc { "looking up implementations of a trait in a crate" }
1235
1251
}
1252
+
1253
+ /// Given a crate, look up all trait impls in that crate.
1254
+ /// Return `(impl_id, self_ty)`.
1236
1255
query all_trait_implementations( _: CrateNum )
1237
1256
-> & ' tcx [ ( DefId , Option <ty:: fast_reject:: SimplifiedType >) ] {
1238
1257
desc { "looking up all (?) trait implementations" }
0 commit comments