@@ -34,24 +34,7 @@ pub fn search_for_structural_match_violation<'tcx>(
34
34
tcx : TyCtxt < ' tcx > ,
35
35
ty : Ty < ' tcx > ,
36
36
) -> 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 ( )
55
38
}
56
39
57
40
/// This implements the traversal over the structure of a given type to try to
@@ -65,11 +48,6 @@ struct Search<'tcx> {
65
48
/// Tracks ADTs previously encountered during search, so that
66
49
/// we will not recur on them again.
67
50
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 ,
73
51
}
74
52
75
53
impl < ' tcx > Search < ' tcx > {
@@ -124,41 +102,29 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for Search<'tcx> {
124
102
}
125
103
126
104
ty:: FnPtr ( ..) => {
127
- if !self . adt_const_param {
128
- return ControlFlow :: Continue ( ( ) ) ;
129
- } else {
130
- return ControlFlow :: Break ( ty) ;
131
- }
105
+ return ControlFlow :: Continue ( ( ) ) ;
132
106
}
133
107
134
108
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 ( ( ) ) ;
154
124
}
155
125
156
126
ty:: Float ( _) => {
157
- if !self . adt_const_param {
158
- return ControlFlow :: Continue ( ( ) ) ;
159
- } else {
160
- return ControlFlow :: Break ( ty) ;
161
- }
127
+ return ControlFlow :: Continue ( ( ) ) ;
162
128
}
163
129
164
130
ty:: Array ( ..) | ty:: Slice ( _) | ty:: Ref ( ..) | ty:: Tuple ( ..) => {
0 commit comments