@@ -100,7 +100,9 @@ use tracing::{debug, instrument};
100100
101101use  super :: matches:: BuiltMatchTree ; 
102102use  crate :: builder:: { BlockAnd ,  BlockAndExtension ,  BlockFrame ,  Builder ,  CFG } ; 
103- use  crate :: errors:: { ConstContinueBadConst ,  ConstContinueUnknownJumpTarget } ; 
103+ use  crate :: errors:: { 
104+     ConstContinueBadConst ,  ConstContinueNotMonomorphicConst ,  ConstContinueUnknownJumpTarget , 
105+ } ; 
104106
105107#[ derive( Debug ) ]  
106108pub ( crate )  struct  Scopes < ' tcx >  { 
@@ -867,7 +869,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
867869            span_bug ! ( span,  "break value must be a scope" ) 
868870        } ; 
869871
870-         let  constant = match  & self . thir [ value] . kind  { 
872+         let  expr = & self . thir [ value] ; 
873+         let  constant = match  & expr. kind  { 
871874            ExprKind :: Adt ( box AdtExpr  {  variant_index,  fields,  base,  .. } )  => { 
872875                assert ! ( matches!( base,  AdtExprBase :: None ) ) ; 
873876                assert ! ( fields. is_empty( ) ) ; 
@@ -887,7 +890,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
887890                    ) , 
888891                } 
889892            } 
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+             } 
891914        } ; 
892915
893916        let  break_index = self 
0 commit comments