File tree 4 files changed +31
-7
lines changed
codegen-units/item-collection
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> {
173
173
// available to normal end-users.
174
174
return true
175
175
}
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 ( )
180
177
}
181
178
}
182
179
Original file line number Diff line number Diff line change 11
11
// ignore-tidy-linelength
12
12
// compile-flags:-Zprint-mono-items=lazy
13
13
14
- // NB: We do not expect *any* monomorphization to be generated here.
15
-
16
14
#![ deny( dead_code) ]
17
15
#![ crate_type = "rlib" ]
18
16
17
+ //~ MONO_ITEM fn unreferenced_const_fn::foo[0] @@ unreferenced_const_fn-cgu.0[External]
19
18
pub const fn foo ( x : u32 ) -> u32 {
20
19
x + 0xf00
21
20
}
Original file line number Diff line number Diff line change 10
10
11
11
// Crate that exports a const fn. Used for testing cross-crate.
12
12
13
+ #![ feature( const_fn) ]
13
14
#![ crate_type="rlib" ]
14
15
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