@@ -285,42 +285,46 @@ pub trait InferCtxtLike: Sized {
285
285
286
286
fn reset_opaque_types ( & self ) ;
287
287
288
- fn may_use_unstable_feature (
289
- & self ,
290
- param_env : <Self :: Interner as Interner >:: ParamEnv ,
291
- symbol : <Self :: Interner as Interner >:: Symbol ,
292
- ) -> bool {
293
- // Iterate through all goals in param_env to find the one that has the same symbol.
294
- for pred in param_env. caller_bounds ( ) . iter ( ) {
295
- if let ty:: ClauseKind :: UnstableFeature ( sym) = pred. kind ( ) . skip_binder ( ) {
296
- if sym == symbol {
297
- return true ;
298
- }
288
+ }
289
+
290
+
291
+ pub fn may_use_unstable_feature < ' a , I : Interner , Infcx > (
292
+ infcx : & ' a Infcx ,
293
+ param_env : I :: ParamEnv ,
294
+ symbol : I :: Symbol ,
295
+ ) -> bool
296
+ where Infcx : InferCtxtLike < Interner = I >
297
+ {
298
+ // Iterate through all goals in param_env to find the one that has the same symbol.
299
+ for pred in param_env. caller_bounds ( ) . iter ( ) {
300
+ if let ty:: ClauseKind :: UnstableFeature ( sym) = pred. kind ( ) . skip_binder ( ) {
301
+ if sym == symbol {
302
+ return true ;
299
303
}
300
304
}
305
+ }
301
306
302
- // During codegen we must assume that all feature bounds hold as we may be
303
- // monomorphizing a body from an upstream crate which had an unstable feature
304
- // enabled that we do not.
305
- //
306
- // Coherence should already report overlap errors involving unstable impls
307
- // as the affected code would otherwise break when stabilizing this feature.
308
- // It is also easily possible to accidentally cause unsoundness this way as
309
- // we have to always enable unstable impls during codegen.
310
- //
311
- // Return ambiguity can also prevent people from writing code which depends on inference guidance
312
- // that might no longer work after the impl is stabilised,
313
- // tests/ui/unstable-feature_bound/unstable_impl_coherence_inherence.rs is one of the example.
314
- //
315
- // Note: `feature_bound_holds_in_crate` does not consider a feature to be enabled
316
- // if we are in std/core even if there is a corresponding `feature` attribute on the crate.
317
-
318
- if ( self . typing_mode ( ) == TypingMode :: PostAnalysis )
319
- || self . cx ( ) . features ( ) . feature_bound_holds_in_crate ( symbol)
320
- {
321
- return true ;
322
- } else {
323
- return false ;
324
- }
307
+ // During codegen we must assume that all feature bounds hold as we may be
308
+ // monomorphizing a body from an upstream crate which had an unstable feature
309
+ // enabled that we do not.
310
+ //
311
+ // Coherence should already report overlap errors involving unstable impls
312
+ // as the affected code would otherwise break when stabilizing this feature.
313
+ // It is also easily possible to accidentally cause unsoundness this way as
314
+ // we have to always enable unstable impls during codegen.
315
+ //
316
+ // Return ambiguity can also prevent people from writing code which depends on inference guidance
317
+ // that might no longer work after the impl is stabilised,
318
+ // tests/ui/unstable-feature_bound/unstable_impl_coherence_inherence.rs is one of the example.
319
+ //
320
+ // Note: `feature_bound_holds_in_crate` does not consider a feature to be enabled
321
+ // if we are in std/core even if there is a corresponding `feature` attribute on the crate.
322
+
323
+ if ( infcx. typing_mode ( ) == TypingMode :: PostAnalysis )
324
+ || infcx. cx ( ) . features ( ) . feature_bound_holds_in_crate ( symbol)
325
+ {
326
+ return true ;
327
+ } else {
328
+ return false ;
325
329
}
326
330
}
0 commit comments