File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed
compiler/rustc_middle/src/hir Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,11 @@ impl<'tcx> TyCtxt<'tcx> {
319319
320320 BodyOwnerKind :: Fn if self . is_constructor ( def_id) => return None ,
321321 BodyOwnerKind :: Fn | BodyOwnerKind :: Closure if self . is_const_fn ( def_id) => {
322- ConstContext :: ConstFn
322+ if self . constness ( def_id) == rustc_hir:: Constness :: Comptime {
323+ ConstContext :: Const { inline : true }
324+ } else {
325+ ConstContext :: ConstFn
326+ }
323327 }
324328 BodyOwnerKind :: Fn if self . is_const_default_method ( def_id) => ConstContext :: ConstFn ,
325329 BodyOwnerKind :: Fn | BodyOwnerKind :: Closure | BodyOwnerKind :: GlobalAsm => return None ,
Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ const fn bar() {
1919
2020#[ rustc_comptime]
2121fn baz ( ) {
22- // Should be allowed
22+ // Ok
2323 foo ( ) ;
24- //~^ ERROR: comptime fns can only be called at compile time
2524}
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:23: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