@@ -22,36 +22,38 @@ use crate::errors;
22
22
pub ( crate ) fn crate_inherent_impls (
23
23
tcx : TyCtxt < ' _ > ,
24
24
( ) : ( ) ,
25
- ) -> Result < & ' _ CrateInherentImpls , ErrorGuaranteed > {
25
+ ) -> ( & ' _ CrateInherentImpls , Result < ( ) , ErrorGuaranteed > ) {
26
26
let mut collect = InherentCollect { tcx, impls_map : Default :: default ( ) } ;
27
+
27
28
let mut res = Ok ( ( ) ) ;
28
29
for id in tcx. hir ( ) . items ( ) {
29
30
res = res. and ( collect. check_item ( id) ) ;
30
31
}
31
- res? ;
32
- Ok ( tcx. arena . alloc ( collect. impls_map ) )
32
+
33
+ ( tcx. arena . alloc ( collect. impls_map ) , res )
33
34
}
34
35
35
- pub ( crate ) fn crate_incoherent_impls (
36
+ pub ( crate ) fn crate_inherent_impls_validity_check (
36
37
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 (
41
46
crate_map. incoherent_impls . get ( & simp) . unwrap_or ( & Vec :: new ( ) ) . iter ( ) . map ( |d| d. to_def_id ( ) ) ,
42
- ) )
47
+ )
43
48
}
44
49
45
50
/// 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) {
52
54
Some ( v) => & v[ ..] ,
53
55
None => & [ ] ,
54
- } )
56
+ }
55
57
}
56
58
57
59
struct InherentCollect < ' tcx > {
0 commit comments