@@ -7,7 +7,7 @@ use rustc_hir::{
77} ;
88use rustc_infer:: infer:: TyCtxtInferExt ;
99use rustc_middle:: ty:: {
10- AdtKind , AssocKind , FieldDef , FnSig , ParamEnv , Ty , TyCtxt , TyKind , TypingMode ,
10+ AdtKind , AssocKind , FieldDef , FnSig , ParamEnv , Ty , TyCtxt , TyKind , TypingEnv , TypingMode ,
1111} ;
1212use rustc_span:: Symbol ;
1313use rustc_trait_selection:: infer:: InferCtxtExt ;
@@ -36,8 +36,8 @@ pub(crate) fn find_methods_and_fields(ctxt: &mut BevyCtxt<'_>, _args: &Args) ->
3636 info ! ( "ignoring enum variant: {}::{} due to 'reflect(ignore)' attribute" , ctxt. tcx. item_name( def_id) , variant. name) ;
3737 todo ! ( ) ;
3838 }
39-
40- process_fields ( ctxt. tcx , & ctxt. meta_loader , & ctxt. reflect_types , & ctxt. cached_traits , variant. fields . iter ( ) , ctxt . tcx . param_env ( variant . def_id ) )
39+ let param_env = TypingEnv :: non_body_analysis ( ctxt . tcx , variant . def_id ) ;
40+ process_fields ( ctxt. tcx , & ctxt. meta_loader , & ctxt. reflect_types , & ctxt. cached_traits , variant. fields . iter ( ) , param_env)
4141 } ) . collect :: < Vec < _ > > ( ) ;
4242
4343 strats. iter ( ) . for_each ( |( f_did, strat) | match strat {
@@ -52,7 +52,8 @@ pub(crate) fn find_methods_and_fields(ctxt: &mut BevyCtxt<'_>, _args: &Args) ->
5252
5353 } ,
5454 AdtKind :: Struct => {
55- let fields = process_fields ( ctxt. tcx , & ctxt. meta_loader , & ctxt. reflect_types , & ctxt. cached_traits , adt_def. all_fields ( ) , ctxt. tcx . param_env ( def_id) ) ;
55+ let param_env = TypingEnv :: non_body_analysis ( ctxt. tcx , def_id) ;
56+ let fields = process_fields ( ctxt. tcx , & ctxt. meta_loader , & ctxt. reflect_types , & ctxt. cached_traits , adt_def. all_fields ( ) , param_env) ;
5657 fields. iter ( ) . for_each ( |( f_did, strat) | match strat {
5758 ReflectionStrategy :: Reflection => report_field_not_supported ( ctxt. tcx , * f_did, def_id, None , "type is neither a proxy nor a type expressible as lua primitive" ) ,
5859 ReflectionStrategy :: Filtered => report_field_not_supported ( ctxt. tcx , * f_did, def_id, None , "field has a 'reflect(ignore)' attribute" ) ,
@@ -118,7 +119,8 @@ pub(crate) fn find_methods_and_fields(ctxt: &mut BevyCtxt<'_>, _args: &Args) ->
118119 ctxt. tcx. item_name( def_id)
119120 ) ;
120121
121- let param_env = ctxt. tcx . param_env ( fn_did) ;
122+ // let param_env = ctxt.tcx.param_env(fn_did);
123+ let param_env = TypingEnv :: non_body_analysis ( ctxt. tcx , def_id) ;
122124 let sig: FnSig = ctxt. tcx . normalize_erasing_late_bound_regions (
123125 param_env,
124126 ctxt. tcx . fn_sig ( fn_did) . instantiate_identity ( ) ,
@@ -238,10 +240,9 @@ fn report_field_not_supported(
238240 variant_did : Option < DefId > ,
239241 reason : & ' static str ,
240242) {
241- let normalised_ty = tcx. normalize_erasing_regions (
242- tcx. param_env ( type_did) ,
243- tcx. type_of ( f_did) . instantiate_identity ( ) ,
244- ) ;
243+ let param_env = TypingEnv :: non_body_analysis ( tcx, type_did) ;
244+ let normalised_ty =
245+ tcx. normalize_erasing_regions ( param_env, tcx. type_of ( f_did) . instantiate_identity ( ) ) ;
245246 info ! (
246247 "Ignoring field: `{}:{}` on type: `{}` in variant: `{}` as it is not supported: `{}`" ,
247248 tcx. item_name( f_did) ,
@@ -259,7 +260,7 @@ fn process_fields<'tcx, 'f, I: Iterator<Item = &'f FieldDef>>(
259260 reflect_types : & IndexMap < DefId , ReflectType < ' tcx > > ,
260261 cached_traits : & CachedTraits ,
261262 fields : I ,
262- param_env : ParamEnv < ' tcx > ,
263+ param_env : TypingEnv < ' tcx > ,
263264) -> Vec < ( DefId , ReflectionStrategy ) > {
264265 fields
265266 . map ( move |f| {
@@ -364,7 +365,7 @@ fn type_is_adt_and_reflectable<'tcx>(
364365/// Checks if the type can be used directly as a lua function argument, by checking if it implements the FromLua trait
365366fn type_is_supported_as_non_proxy_arg < ' tcx > (
366367 tcx : TyCtxt < ' tcx > ,
367- param_env : ParamEnv < ' tcx > ,
368+ param_env : TypingEnv < ' tcx > ,
368369 cached_traits : & CachedTraits ,
369370 ty : Ty < ' tcx > ,
370371) -> bool {
@@ -380,7 +381,7 @@ fn type_is_supported_as_non_proxy_arg<'tcx>(
380381/// Checks if the type can be used directly as a lua function output
381382fn type_is_supported_as_non_proxy_return_val < ' tcx > (
382383 tcx : TyCtxt < ' tcx > ,
383- param_env : ParamEnv < ' tcx > ,
384+ param_env : TypingEnv < ' tcx > ,
384385 cached_traits : & CachedTraits ,
385386 ty : Ty < ' tcx > ,
386387) -> bool {
@@ -401,12 +402,12 @@ fn type_is_supported_as_non_proxy_return_val<'tcx>(
401402
402403pub ( crate ) fn impls_trait < ' tcx > (
403404 tcx : TyCtxt < ' tcx > ,
404- param_env : ParamEnv < ' tcx > ,
405+ param_env : TypingEnv < ' tcx > ,
405406 ty : Ty < ' tcx > ,
406407 trait_did : DefId ,
407408) -> bool {
408409 tcx. infer_ctxt ( )
409- . build ( TypingMode :: non_body_analysis ( ) )
410- . type_implements_trait ( trait_did, [ ty] , param_env)
410+ . build ( param_env . typing_mode )
411+ . type_implements_trait ( trait_did, [ ty] , param_env. param_env )
411412 . must_apply_modulo_regions ( )
412413}
0 commit comments