@@ -34,24 +34,7 @@ pub fn search_for_structural_match_violation<'tcx>(
3434 tcx : TyCtxt < ' tcx > ,
3535 ty : Ty < ' tcx > ,
3636) -> Option < Ty < ' tcx > > {
37- ty. visit_with ( & mut Search { tcx, span, seen : FxHashSet :: default ( ) , adt_const_param : false } )
38- . break_value ( )
39- }
40-
41- /// This method traverses the structure of `ty`, trying to find any
42- /// types that are not allowed to be used in a const generic.
43- ///
44- /// This is either because the type does not implement `StructuralEq`
45- /// and `StructuralPartialEq`, or because the type is intentionally
46- /// not supported in const generics (such as floats and raw pointers,
47- /// which are allowed in match blocks).
48- pub fn search_for_adt_const_param_violation < ' tcx > (
49- span : Span ,
50- tcx : TyCtxt < ' tcx > ,
51- ty : Ty < ' tcx > ,
52- ) -> Option < Ty < ' tcx > > {
53- ty. visit_with ( & mut Search { tcx, span, seen : FxHashSet :: default ( ) , adt_const_param : true } )
54- . break_value ( )
37+ ty. visit_with ( & mut Search { tcx, span, seen : FxHashSet :: default ( ) } ) . break_value ( )
5538}
5639
5740/// This implements the traversal over the structure of a given type to try to
@@ -65,11 +48,6 @@ struct Search<'tcx> {
6548 /// Tracks ADTs previously encountered during search, so that
6649 /// we will not recur on them again.
6750 seen : FxHashSet < hir:: def_id:: DefId > ,
68-
69- // Additionally deny things that have been allowed in patterns,
70- // but are not allowed in adt const params, such as floats and
71- // fn ptrs.
72- adt_const_param : bool ,
7351}
7452
7553impl < ' tcx > Search < ' tcx > {
@@ -124,41 +102,29 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for Search<'tcx> {
124102 }
125103
126104 ty:: FnPtr ( ..) => {
127- if !self . adt_const_param {
128- return ControlFlow :: Continue ( ( ) ) ;
129- } else {
130- return ControlFlow :: Break ( ty) ;
131- }
105+ return ControlFlow :: Continue ( ( ) ) ;
132106 }
133107
134108 ty:: RawPtr ( ..) => {
135- if !self . adt_const_param {
136- // structural-match ignores substructure of
137- // `*const _`/`*mut _`, so skip `super_visit_with`.
138- //
139- // For example, if you have:
140- // ```
141- // struct NonStructural;
142- // #[derive(PartialEq, Eq)]
143- // struct T(*const NonStructural);
144- // const C: T = T(std::ptr::null());
145- // ```
146- //
147- // Even though `NonStructural` does not implement `PartialEq`,
148- // structural equality on `T` does not recur into the raw
149- // pointer. Therefore, one can still use `C` in a pattern.
150- return ControlFlow :: Continue ( ( ) ) ;
151- } else {
152- return ControlFlow :: Break ( ty) ;
153- }
109+ // structural-match ignores substructure of
110+ // `*const _`/`*mut _`, so skip `super_visit_with`.
111+ //
112+ // For example, if you have:
113+ // ```
114+ // struct NonStructural;
115+ // #[derive(PartialEq, Eq)]
116+ // struct T(*const NonStructural);
117+ // const C: T = T(std::ptr::null());
118+ // ```
119+ //
120+ // Even though `NonStructural` does not implement `PartialEq`,
121+ // structural equality on `T` does not recur into the raw
122+ // pointer. Therefore, one can still use `C` in a pattern.
123+ return ControlFlow :: Continue ( ( ) ) ;
154124 }
155125
156126 ty:: Float ( _) => {
157- if !self . adt_const_param {
158- return ControlFlow :: Continue ( ( ) ) ;
159- } else {
160- return ControlFlow :: Break ( ty) ;
161- }
127+ return ControlFlow :: Continue ( ( ) ) ;
162128 }
163129
164130 ty:: Array ( ..) | ty:: Slice ( _) | ty:: Ref ( ..) | ty:: Tuple ( ..) => {
0 commit comments