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<'_>) {
203
203
tcx. ensure_ok ( ) . eval_static_initializer ( item_def_id) ;
204
204
check:: maybe_check_static_with_link_section ( tcx, item_def_id) ;
205
205
}
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!
207
209
let instance = ty:: Instance :: new_raw ( item_def_id. into ( ) , ty:: GenericArgs :: empty ( ) ) ;
208
210
let cid = GlobalId { instance, promoted : None } ;
209
211
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> {
1483
1483
1484
1484
// But even just declaring them must collect the items they refer to
1485
1485
// 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 ( )
1487
1487
&& let Ok ( val) = self . tcx . const_eval_poly ( id. owner_id . to_def_id ( ) )
1488
1488
{
1489
1489
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
3
3
|
4
4
LL | const _<'_a>: () = panic!();
5
5
| ^^^^^^^^ evaluation panicked: explicit panic
Original file line number Diff line number Diff line change 1
1
//! Test that we only evaluate free const items (their def site to be clear)
2
2
//! whose generics don't require monomorphization.
3
3
#![ feature( generic_const_items) ]
4
- #![ allow ( incomplete_features) ]
4
+ #![ expect ( incomplete_features) ]
5
5
6
6
//@ revisions: fail pass
7
- //@[fail] build-fail (we require monomorphization)
8
- //@[pass] build-pass (we require monomorphization)
7
+ //@[pass] check-pass
9
8
10
9
const _<_T >: ( ) = panic ! ( ) ;
11
10
const _<const _N: usize >: ( ) = panic ! ( ) ;
12
11
13
12
#[ cfg( fail) ]
14
- const _<' _a>: ( ) = panic ! ( ) ; //[fail]~ ERROR evaluation of `_::<'_>` failed
13
+ const _<' _a>: ( ) = panic ! ( ) ; //[fail]~ ERROR evaluation of constant value failed
15
14
16
15
fn main ( ) { }
You can’t perform that action at this time.
0 commit comments