@@ -15,7 +15,7 @@ use rustc_hir::def::{DefKind, Res};
1515use rustc_hir:: {
1616 BinOpKind , Block , ConstBlock , Expr , ExprKind , HirId , Item , ItemKind , Node , PatExpr , PatExprKind , QPath , UnOp ,
1717} ;
18- use rustc_lexer:: tokenize;
18+ use rustc_lexer:: { FrontmatterAllowed , tokenize} ;
1919use rustc_lint:: LateContext ;
2020use rustc_middle:: mir:: ConstValue ;
2121use rustc_middle:: mir:: interpret:: { Scalar , alloc_range} ;
@@ -304,9 +304,7 @@ pub fn lit_to_mir_constant<'tcx>(lit: &LitKind, ty: Option<Ty<'tcx>>) -> Constan
304304 match * lit {
305305 LitKind :: Str ( ref is, _) => Constant :: Str ( is. to_string ( ) ) ,
306306 LitKind :: Byte ( b) => Constant :: Int ( u128:: from ( b) ) ,
307- LitKind :: ByteStr ( ref s, _) | LitKind :: CStr ( ref s, _) => {
308- Constant :: Binary ( s. as_byte_str ( ) . to_vec ( ) )
309- }
307+ LitKind :: ByteStr ( ref s, _) | LitKind :: CStr ( ref s, _) => Constant :: Binary ( s. as_byte_str ( ) . to_vec ( ) ) ,
310308 LitKind :: Char ( c) => Constant :: Char ( c) ,
311309 LitKind :: Int ( n, _) => Constant :: Int ( n. get ( ) ) ,
312310 LitKind :: Float ( ref is, LitFloatType :: Suffixed ( fty) ) => match fty {
@@ -568,9 +566,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
568566 } else {
569567 match & lit. node {
570568 LitKind :: Str ( is, _) => Some ( is. is_empty ( ) ) ,
571- LitKind :: ByteStr ( s, _) | LitKind :: CStr ( s, _) => {
572- Some ( s. as_byte_str ( ) . is_empty ( ) )
573- }
569+ LitKind :: ByteStr ( s, _) | LitKind :: CStr ( s, _) => Some ( s. as_byte_str ( ) . is_empty ( ) ) ,
574570 _ => None ,
575571 }
576572 }
@@ -715,7 +711,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
715711 && let Some ( src) = src. as_str ( )
716712 {
717713 use rustc_lexer:: TokenKind :: { BlockComment , LineComment , OpenBrace , Semi , Whitespace } ;
718- if !tokenize ( src)
714+ if !tokenize ( src, FrontmatterAllowed :: No )
719715 . map ( |t| t. kind )
720716 . filter ( |t| !matches ! ( t, Whitespace | LineComment { .. } | BlockComment { .. } | Semi ) )
721717 . eq ( [ OpenBrace ] )
0 commit comments