@@ -94,11 +94,12 @@ use rustc_abi::{CVariadicStatus, ExternAbi};
9494use rustc_hir:: def:: DefKind ;
9595use rustc_hir:: lints:: DelayedLint ;
9696use rustc_hir:: { self as hir} ;
97- use rustc_middle:: middle ;
97+ use rustc_middle:: mir :: interpret :: GlobalId ;
9898use rustc_middle:: query:: Providers ;
9999use rustc_middle:: ty:: { Const , Ty , TyCtxt } ;
100+ use rustc_middle:: { middle, ty} ;
100101use rustc_session:: parse:: feature_err;
101- use rustc_span:: { ErrorGuaranteed , Span } ;
102+ use rustc_span:: { ErrorGuaranteed , Span , sym } ;
102103use rustc_trait_selection:: traits;
103104
104105pub use crate :: collect:: suggest_impl_trait;
@@ -226,6 +227,17 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
226227 tcx. ensure_ok ( ) . eval_static_initializer ( item_def_id) ;
227228 check:: maybe_check_static_with_link_section ( tcx, item_def_id) ;
228229 }
230+ DefKind :: Const
231+ if !tcx. generics_of ( item_def_id) . own_requires_monomorphization ( )
232+ && !tcx. has_attr ( item_def_id, sym:: type_const) =>
233+ {
234+ // FIXME(generic_const_items): Passing empty instead of identity args is fishy but
235+ // seems to be fine for now. Revisit this!
236+ let instance = ty:: Instance :: new_raw ( item_def_id. into ( ) , ty:: GenericArgs :: empty ( ) ) ;
237+ let cid = GlobalId { instance, promoted : None } ;
238+ let typing_env = ty:: TypingEnv :: fully_monomorphized ( ) ;
239+ tcx. ensure_ok ( ) . eval_to_const_value_raw ( typing_env. as_query_input ( cid) ) ;
240+ }
229241 _ => ( ) ,
230242 }
231243 // Skip `AnonConst`s because we feed their `type_of`.
0 commit comments