@@ -22,36 +22,38 @@ use crate::errors;
2222pub ( crate ) fn crate_inherent_impls (
2323 tcx : TyCtxt < ' _ > ,
2424 ( ) : ( ) ,
25- ) -> Result < & ' _ CrateInherentImpls , ErrorGuaranteed > {
25+ ) -> ( & ' _ CrateInherentImpls , Result < ( ) , ErrorGuaranteed > ) {
2626 let mut collect = InherentCollect { tcx, impls_map : Default :: default ( ) } ;
27+
2728 let mut res = Ok ( ( ) ) ;
2829 for id in tcx. hir ( ) . items ( ) {
2930 res = res. and ( collect. check_item ( id) ) ;
3031 }
31- res? ;
32- Ok ( tcx. arena . alloc ( collect. impls_map ) )
32+
33+ ( tcx. arena . alloc ( collect. impls_map ) , res )
3334}
3435
35- pub ( crate ) fn crate_incoherent_impls (
36+ pub ( crate ) fn crate_inherent_impls_validity_check (
3637 tcx : TyCtxt < ' _ > ,
37- simp : SimplifiedType ,
38- ) -> Result < & [ DefId ] , ErrorGuaranteed > {
39- let crate_map = tcx. crate_inherent_impls ( ( ) ) ?;
40- Ok ( tcx. arena . alloc_from_iter (
38+ ( ) : ( ) ,
39+ ) -> Result < ( ) , ErrorGuaranteed > {
40+ tcx. crate_inherent_impls ( ( ) ) . 1
41+ }
42+
43+ pub ( crate ) fn crate_incoherent_impls ( tcx : TyCtxt < ' _ > , simp : SimplifiedType ) -> & [ DefId ] {
44+ let ( crate_map, _) = tcx. crate_inherent_impls ( ( ) ) ;
45+ tcx. arena . alloc_from_iter (
4146 crate_map. incoherent_impls . get ( & simp) . unwrap_or ( & Vec :: new ( ) ) . iter ( ) . map ( |d| d. to_def_id ( ) ) ,
42- ) )
47+ )
4348}
4449
4550/// On-demand query: yields a vector of the inherent impls for a specific type.
46- pub ( crate ) fn inherent_impls (
47- tcx : TyCtxt < ' _ > ,
48- ty_def_id : LocalDefId ,
49- ) -> Result < & [ DefId ] , ErrorGuaranteed > {
50- let crate_map = tcx. crate_inherent_impls ( ( ) ) ?;
51- Ok ( match crate_map. inherent_impls . get ( & ty_def_id) {
51+ pub ( crate ) fn inherent_impls ( tcx : TyCtxt < ' _ > , ty_def_id : LocalDefId ) -> & [ DefId ] {
52+ let ( crate_map, _) = tcx. crate_inherent_impls ( ( ) ) ;
53+ match crate_map. inherent_impls . get ( & ty_def_id) {
5254 Some ( v) => & v[ ..] ,
5355 None => & [ ] ,
54- } )
56+ }
5557}
5658
5759struct InherentCollect < ' tcx > {
0 commit comments