File tree Expand file tree Collapse file tree 4 files changed +9
-8
lines changed
tests/ui/generic-const-items Expand file tree Collapse file tree 4 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -203,7 +203,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
203203 tcx. ensure_ok ( ) . eval_static_initializer ( item_def_id) ;
204204 check:: maybe_check_static_with_link_section ( tcx, item_def_id) ;
205205 }
206- DefKind :: Const if tcx. generics_of ( item_def_id) . is_empty ( ) => {
206+ DefKind :: Const if !tcx. generics_of ( item_def_id) . own_requires_monomorphization ( ) => {
207+ // FIXME(generic_const_items): Passing empty instead of identity args is fishy but
208+ // seems to be fine for now. Revisit this!
207209 let instance = ty:: Instance :: new_raw ( item_def_id. into ( ) , ty:: GenericArgs :: empty ( ) ) ;
208210 let cid = GlobalId { instance, promoted : None } ;
209211 let typing_env = ty:: TypingEnv :: fully_monomorphized ( ) ;
Original file line number Diff line number Diff line change @@ -1483,7 +1483,7 @@ impl<'v> RootCollector<'_, 'v> {
14831483
14841484 // But even just declaring them must collect the items they refer to
14851485 // unless their generics require monomorphization.
1486- if !self . tcx . generics_of ( id. owner_id ) . requires_monomorphization ( self . tcx )
1486+ if !self . tcx . generics_of ( id. owner_id ) . own_requires_monomorphization ( )
14871487 && let Ok ( val) = self . tcx . const_eval_poly ( id. owner_id . to_def_id ( ) )
14881488 {
14891489 collect_const_value ( self . tcx , val, self . output ) ;
Original file line number Diff line number Diff line change 1- error[E0080]: evaluation of `_::<'_>` failed
2- --> $DIR/def-site-eval.rs:14 :20
1+ error[E0080]: evaluation of constant value failed
2+ --> $DIR/def-site-eval.rs:13 :20
33 |
44LL | const _<'_a>: () = panic!();
55 | ^^^^^^^^ evaluation panicked: explicit panic
Original file line number Diff line number Diff line change 11//! Test that we only evaluate free const items (their def site to be clear)
22//! whose generics don't require monomorphization.
33#![ feature( generic_const_items) ]
4- #![ allow ( incomplete_features) ]
4+ #![ expect ( incomplete_features) ]
55
66//@ revisions: fail pass
7- //@[fail] build-fail (we require monomorphization)
8- //@[pass] build-pass (we require monomorphization)
7+ //@[pass] check-pass
98
109const _<_T >: ( ) = panic ! ( ) ;
1110const _<const _N: usize >: ( ) = panic ! ( ) ;
1211
1312#[ cfg( fail) ]
14- const _<' _a>: ( ) = panic ! ( ) ; //[fail]~ ERROR evaluation of `_::<'_>` failed
13+ const _<' _a>: ( ) = panic ! ( ) ; //[fail]~ ERROR evaluation of constant value failed
1514
1615fn main ( ) { }
You can’t perform that action at this time.
0 commit comments