@@ -128,9 +128,6 @@ pub struct SelectionContext<'cx, 'tcx> {
128128 /// and a negative impl
129129 allow_negative_impls : bool ,
130130
131- /// Are we in a const context that needs `~const` bounds to be const?
132- is_in_const_context : bool ,
133-
134131 /// The mode that trait queries run in, which informs our error handling
135132 /// policy. In essence, canonicalized queries need their errors propagated
136133 /// rather than immediately reported because we do not have accurate spans.
@@ -222,7 +219,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
222219 intercrate : false ,
223220 intercrate_ambiguity_causes : None ,
224221 allow_negative_impls : false ,
225- is_in_const_context : false ,
226222 query_mode : TraitQueryMode :: Standard ,
227223 }
228224 }
@@ -234,7 +230,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
234230 intercrate : true ,
235231 intercrate_ambiguity_causes : None ,
236232 allow_negative_impls : false ,
237- is_in_const_context : false ,
238233 query_mode : TraitQueryMode :: Standard ,
239234 }
240235 }
@@ -250,7 +245,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
250245 intercrate : false ,
251246 intercrate_ambiguity_causes : None ,
252247 allow_negative_impls,
253- is_in_const_context : false ,
254248 query_mode : TraitQueryMode :: Standard ,
255249 }
256250 }
@@ -266,26 +260,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
266260 intercrate : false ,
267261 intercrate_ambiguity_causes : None ,
268262 allow_negative_impls : false ,
269- is_in_const_context : false ,
270263 query_mode,
271264 }
272265 }
273266
274- pub fn with_constness (
275- infcx : & ' cx InferCtxt < ' cx , ' tcx > ,
276- constness : hir:: Constness ,
277- ) -> SelectionContext < ' cx , ' tcx > {
278- SelectionContext {
279- infcx,
280- freshener : infcx. freshener_keep_static ( ) ,
281- intercrate : false ,
282- intercrate_ambiguity_causes : None ,
283- allow_negative_impls : false ,
284- is_in_const_context : matches ! ( constness, hir:: Constness :: Const ) ,
285- query_mode : TraitQueryMode :: Standard ,
286- }
287- }
288-
289267 /// Enables tracking of intercrate ambiguity causes. These are
290268 /// used in coherence to give improved diagnostics. We don't do
291269 /// this until we detect a coherence error because it can lead to
@@ -318,20 +296,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
318296 self . intercrate
319297 }
320298
321- /// Returns `true` if the trait predicate is considerd `const` to this selection context.
322- pub fn is_trait_predicate_const ( & self , pred : ty:: TraitPredicate < ' _ > ) -> bool {
323- matches ! ( pred. constness, ty:: BoundConstness :: ConstIfConst ) && self . is_in_const_context
324- }
325-
326- /// Returns `true` if the predicate is considered `const` to
327- /// this selection context.
328- pub fn is_predicate_const ( & self , pred : ty:: Predicate < ' _ > ) -> bool {
329- match pred. kind ( ) . skip_binder ( ) {
330- ty:: PredicateKind :: Trait ( pred) => self . is_trait_predicate_const ( pred) ,
331- _ => false ,
332- }
333- }
334-
335299 ///////////////////////////////////////////////////////////////////////////
336300 // Selection
337301 //
@@ -1138,7 +1102,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11381102
11391103 for candidate in candidates {
11401104 // Respect const trait obligations
1141- if self . is_trait_predicate_const ( obligation. predicate . skip_binder ( ) ) {
1105+ if obligation. is_const ( ) {
11421106 match candidate {
11431107 // const impl
11441108 ImplCandidate ( def_id)
0 commit comments