1
1
//! Check properties that are required by built-in traits and set
2
2
//! up data structures required by type-checking/codegen.
3
3
4
- use std:: assert_matches:: assert_matches;
5
4
use std:: collections:: BTreeMap ;
6
5
7
6
use rustc_data_structures:: fx:: FxHashSet ;
@@ -40,10 +39,7 @@ pub(super) fn check_trait<'tcx>(
40
39
checker. check ( lang_items. async_drop_trait ( ) , visit_implementation_of_drop) ?;
41
40
checker. check ( lang_items. copy_trait ( ) , visit_implementation_of_copy) ?;
42
41
checker. check ( lang_items. const_param_ty_trait ( ) , |checker| {
43
- visit_implementation_of_const_param_ty ( checker, LangItem :: ConstParamTy )
44
- } ) ?;
45
- checker. check ( lang_items. unsized_const_param_ty_trait ( ) , |checker| {
46
- visit_implementation_of_const_param_ty ( checker, LangItem :: UnsizedConstParamTy )
42
+ visit_implementation_of_const_param_ty ( checker)
47
43
} ) ?;
48
44
checker. check ( lang_items. coerce_unsized_trait ( ) , visit_implementation_of_coerce_unsized) ?;
49
45
checker
@@ -138,12 +134,7 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
138
134
}
139
135
}
140
136
141
- fn visit_implementation_of_const_param_ty (
142
- checker : & Checker < ' _ > ,
143
- kind : LangItem ,
144
- ) -> Result < ( ) , ErrorGuaranteed > {
145
- assert_matches ! ( kind, LangItem :: ConstParamTy | LangItem :: UnsizedConstParamTy ) ;
146
-
137
+ fn visit_implementation_of_const_param_ty ( checker : & Checker < ' _ > ) -> Result < ( ) , ErrorGuaranteed > {
147
138
let tcx = checker. tcx ;
148
139
let header = checker. impl_header ;
149
140
let impl_did = checker. impl_def_id ;
@@ -157,7 +148,7 @@ fn visit_implementation_of_const_param_ty(
157
148
}
158
149
159
150
let cause = traits:: ObligationCause :: misc ( DUMMY_SP , impl_did) ;
160
- match type_allowed_to_implement_const_param_ty ( tcx, param_env, self_type, kind , cause) {
151
+ match type_allowed_to_implement_const_param_ty ( tcx, param_env, self_type, cause) {
161
152
Ok ( ( ) ) => Ok ( ( ) ) ,
162
153
Err ( ConstParamTyImplementationError :: InfrigingFields ( fields) ) => {
163
154
let span = tcx. hir_expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
0 commit comments