@@ -100,7 +100,9 @@ use tracing::{debug, instrument};
100
100
101
101
use super :: matches:: BuiltMatchTree ;
102
102
use crate :: builder:: { BlockAnd , BlockAndExtension , BlockFrame , Builder , CFG } ;
103
- use crate :: errors:: { ConstContinueBadConst , ConstContinueUnknownJumpTarget } ;
103
+ use crate :: errors:: {
104
+ ConstContinueBadConst , ConstContinueNotMonomorphicConst , ConstContinueUnknownJumpTarget ,
105
+ } ;
104
106
105
107
#[ derive( Debug ) ]
106
108
pub ( crate ) struct Scopes < ' tcx > {
@@ -867,7 +869,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
867
869
span_bug ! ( span, "break value must be a scope" )
868
870
} ;
869
871
870
- let constant = match & self . thir [ value] . kind {
872
+ let expr = & self . thir [ value] ;
873
+ let constant = match & expr. kind {
871
874
ExprKind :: Adt ( box AdtExpr { variant_index, fields, base, .. } ) => {
872
875
assert ! ( matches!( base, AdtExprBase :: None ) ) ;
873
876
assert ! ( fields. is_empty( ) ) ;
@@ -887,7 +890,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
887
890
) ,
888
891
}
889
892
}
890
- _ => self . as_constant ( & self . thir [ value] ) ,
893
+
894
+ ExprKind :: Literal { .. }
895
+ | ExprKind :: NonHirLiteral { .. }
896
+ | ExprKind :: ZstLiteral { .. }
897
+ | ExprKind :: NamedConst { .. } => self . as_constant ( & self . thir [ value] ) ,
898
+
899
+ other => {
900
+ use crate :: errors:: ConstContinueNotMonomorphicConstReason as Reason ;
901
+
902
+ let span = expr. span ;
903
+ let reason = match other {
904
+ ExprKind :: ConstParam { .. } => Reason :: ConstantParameter { span } ,
905
+ ExprKind :: ConstBlock { .. } => Reason :: ConstBlock { span } ,
906
+ _ => Reason :: Other { span } ,
907
+ } ;
908
+
909
+ self . tcx
910
+ . dcx ( )
911
+ . emit_err ( ConstContinueNotMonomorphicConst { span : expr. span , reason } ) ;
912
+ return block. unit ( ) ;
913
+ }
891
914
} ;
892
915
893
916
let break_index = self
0 commit comments