9
9
//! fixed, but for the moment it's easier to do these checks early.
10
10
11
11
use crate :: constrained_generic_params as cgp;
12
+ use min_specialization:: check_min_specialization;
13
+
12
14
use rustc:: ty:: query:: Providers ;
13
15
use rustc:: ty:: { self , TyCtxt , TypeFoldable } ;
14
16
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
15
17
use rustc_errors:: struct_span_err;
16
18
use rustc_hir as hir;
17
19
use rustc_hir:: def_id:: DefId ;
18
20
use rustc_hir:: itemlikevisit:: ItemLikeVisitor ;
21
+ use rustc_span:: Span ;
22
+
19
23
use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
20
24
21
- use rustc_span :: Span ;
25
+ mod min_specialization ;
22
26
23
27
/// Checks that all the type/lifetime parameters on an impl also
24
28
/// appear in the trait ref or self type (or are constrained by a
@@ -60,7 +64,9 @@ pub fn impl_wf_check(tcx: TyCtxt<'_>) {
60
64
}
61
65
62
66
fn check_mod_impl_wf ( tcx : TyCtxt < ' _ > , module_def_id : DefId ) {
63
- tcx. hir ( ) . visit_item_likes_in_module ( module_def_id, & mut ImplWfCheck { tcx } ) ;
67
+ let min_specialization = tcx. features ( ) . min_specialization ;
68
+ tcx. hir ( )
69
+ . visit_item_likes_in_module ( module_def_id, & mut ImplWfCheck { tcx, min_specialization } ) ;
64
70
}
65
71
66
72
pub fn provide ( providers : & mut Providers < ' _ > ) {
@@ -69,6 +75,7 @@ pub fn provide(providers: &mut Providers<'_>) {
69
75
70
76
struct ImplWfCheck < ' tcx > {
71
77
tcx : TyCtxt < ' tcx > ,
78
+ min_specialization : bool ,
72
79
}
73
80
74
81
impl ItemLikeVisitor < ' tcx > for ImplWfCheck < ' tcx > {
@@ -77,6 +84,9 @@ impl ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> {
77
84
let impl_def_id = self . tcx . hir ( ) . local_def_id ( item. hir_id ) ;
78
85
enforce_impl_params_are_constrained ( self . tcx , impl_def_id, items) ;
79
86
enforce_impl_items_are_distinct ( self . tcx , items) ;
87
+ if self . min_specialization {
88
+ check_min_specialization ( self . tcx , impl_def_id, item. span ) ;
89
+ }
80
90
}
81
91
}
82
92
0 commit comments