File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
compiler/rustc_mir/src/transform
src/test/ui/consts/const-eval Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -407,6 +407,10 @@ fn check_terminator(
407
407
} => {
408
408
let fn_ty = func. ty ( body, tcx) ;
409
409
if let ty:: FnDef ( fn_def_id, _) = * fn_ty. kind ( ) {
410
+ // Panic functions (with one argument) might be const fn.
411
+ if super :: check_consts:: is_lang_panic_fn ( tcx, fn_def_id) {
412
+ return Ok ( ( ) ) ;
413
+ }
410
414
// Allow unstable const if we opt in by using #[allow_internal_unstable]
411
415
// on function or macro declaration.
412
416
if !crate :: const_eval:: is_min_const_fn ( tcx, fn_def_id)
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ #![ crate_type = "lib" ]
4
+ #![ feature( const_panic) ]
5
+
6
+ pub const fn always_panic ( ) {
7
+ panic ! ( "always" )
8
+ }
9
+
10
+ pub const fn assert_truth ( ) {
11
+ assert_eq ! ( 2 + 2 , 4 )
12
+ }
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ #![ no_std]
4
+ #![ crate_type = "lib" ]
5
+ #![ feature( const_panic) ]
6
+
7
+ pub const fn always_panic ( ) {
8
+ panic ! ( "always" )
9
+ }
10
+
11
+ pub const fn assert_truth ( ) {
12
+ assert_eq ! ( 2 + 2 , 4 )
13
+ }
You can’t perform that action at this time.
0 commit comments