File tree Expand file tree Collapse file tree
compiler/rustc_middle/src/hir Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -321,7 +321,13 @@ impl<'tcx> TyCtxt<'tcx> {
321321 BodyOwnerKind :: Closure if self . is_const_fn ( def_id) => {
322322 return self . hir_body_const_context ( self . local_parent ( local_def_id) ) ;
323323 }
324- BodyOwnerKind :: Fn if self . is_const_fn ( def_id) => ConstContext :: ConstFn ,
324+ BodyOwnerKind :: Fn if self . is_const_fn ( def_id) => {
325+ if matches ! ( self . constness( def_id) , rustc_hir:: Constness :: Const { always: true } ) {
326+ ConstContext :: Const { inline : true }
327+ } else {
328+ ConstContext :: ConstFn
329+ }
330+ }
325331 BodyOwnerKind :: Fn | BodyOwnerKind :: Closure | BodyOwnerKind :: GlobalAsm => return None ,
326332 } ;
327333
Original file line number Diff line number Diff line change @@ -17,6 +17,6 @@ const fn bar() {
1717
1818#[ rustc_comptime]
1919fn baz ( ) {
20- // TODO: Should be allowed
21- foo ( ) ; //~ ERROR: comptime fns can only be called at compile time
20+ // Ok
21+ foo ( ) ;
2222}
Original file line number Diff line number Diff line change @@ -10,11 +10,5 @@ error: comptime fns can only be called at compile time
1010LL | foo();
1111 | ^^^^^
1212
13- error: comptime fns can only be called at compile time
14- --> $DIR/not_callable.rs:21:5
15- |
16- LL | foo();
17- | ^^^^^
18-
19- error: aborting due to 3 previous errors
13+ error: aborting due to 2 previous errors
2014
You can’t perform that action at this time.
0 commit comments