File tree 1 file changed +3
-1
lines changed
compiler/rustc_hir_analysis/src/coherence
1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -120,11 +120,13 @@ pub fn provide(providers: &mut Providers) {
120
120
}
121
121
122
122
fn coherent_trait ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> Result < ( ) , ErrorGuaranteed > {
123
+ // If there are no impls for the trait, then "all impls" are trivially coherent and we won't check anything
124
+ // anyway. Thus we bail out even before the specialization graph, avoiding the dep_graph edge.
125
+ let Some ( impls) = tcx. all_local_trait_impls ( ( ) ) . get ( & def_id) else { return Ok ( ( ) ) } ;
123
126
// Trigger building the specialization graph for the trait. This will detect and report any
124
127
// overlap errors.
125
128
let mut res = tcx. ensure ( ) . specialization_graph_of ( def_id) ;
126
129
127
- let impls = tcx. hir ( ) . trait_impls ( def_id) ;
128
130
for & impl_def_id in impls {
129
131
let trait_ref = tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) . instantiate_identity ( ) ;
130
132
You can’t perform that action at this time.
0 commit comments