File tree Expand file tree Collapse file tree 4 files changed +31
-7
lines changed
codegen-units/item-collection Expand file tree Collapse file tree 4 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -173,10 +173,7 @@ impl<'tcx> InstanceDef<'tcx> {
173173 // available to normal end-users.
174174 return true
175175 }
176- let codegen_fn_attrs = tcx. codegen_fn_attrs ( self . def_id ( ) ) ;
177- // need to use `is_const_fn_raw` since we don't really care if the user can use it as a
178- // const fn, just whether the function should be inlined
179- codegen_fn_attrs. requests_inline ( ) || tcx. is_const_fn_raw ( self . def_id ( ) )
176+ tcx. codegen_fn_attrs ( self . def_id ( ) ) . requests_inline ( )
180177 }
181178}
182179
Original file line number Diff line number Diff line change 1111// ignore-tidy-linelength
1212// compile-flags:-Zprint-mono-items=lazy
1313
14- // NB: We do not expect *any* monomorphization to be generated here.
15-
1614#![ deny( dead_code) ]
1715#![ crate_type = "rlib" ]
1816
17+ //~ MONO_ITEM fn unreferenced_const_fn::foo[0] @@ unreferenced_const_fn-cgu.0[External]
1918pub const fn foo ( x : u32 ) -> u32 {
2019 x + 0xf00
2120}
Original file line number Diff line number Diff line change 1010
1111// Crate that exports a const fn. Used for testing cross-crate.
1212
13+ #![ feature( const_fn) ]
1314#![ crate_type="rlib" ]
1415
15- pub const fn foo ( ) -> usize { 22 } //~ ERROR const fn is unstable
16+ pub const fn foo ( ) -> usize { 22 }
17+
18+ pub const fn bar ( ) -> fn ( ) {
19+ fn x ( ) { }
20+ x
21+ }
22+
23+ #[ inline]
24+ pub const fn bar_inlined ( ) -> fn ( ) {
25+ fn x ( ) { }
26+ x
27+ }
28+
29+ #[ inline( always) ]
30+ pub const fn bar_inlined_always ( ) -> fn ( ) {
31+ fn x ( ) { }
32+ x
33+ }
Original file line number Diff line number Diff line change 1+ // compile-pass
2+ // aux-build:const_fn_lib.rs
3+
4+ extern crate const_fn_lib;
5+
6+ fn main ( ) {
7+ const_fn_lib:: bar ( ) ( ) ;
8+ const_fn_lib:: bar_inlined ( ) ( ) ;
9+ const_fn_lib:: bar_inlined_always ( ) ( ) ;
10+ }
You can’t perform that action at this time.
0 commit comments