@@ -15,7 +15,7 @@ use rustc_hir::def::{DefKind, Res};
15
15
use rustc_hir:: {
16
16
BinOpKind , Block , ConstBlock , Expr , ExprKind , HirId , Item , ItemKind , Node , PatExpr , PatExprKind , QPath , UnOp ,
17
17
} ;
18
- use rustc_lexer:: tokenize;
18
+ use rustc_lexer:: { FrontmatterAllowed , tokenize} ;
19
19
use rustc_lint:: LateContext ;
20
20
use rustc_middle:: mir:: ConstValue ;
21
21
use 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
304
304
match * lit {
305
305
LitKind :: Str ( ref is, _) => Constant :: Str ( is. to_string ( ) ) ,
306
306
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 ( ) ) ,
310
308
LitKind :: Char ( c) => Constant :: Char ( c) ,
311
309
LitKind :: Int ( n, _) => Constant :: Int ( n. get ( ) ) ,
312
310
LitKind :: Float ( ref is, LitFloatType :: Suffixed ( fty) ) => match fty {
@@ -568,9 +566,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
568
566
} else {
569
567
match & lit. node {
570
568
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 ( ) ) ,
574
570
_ => None ,
575
571
}
576
572
}
@@ -715,7 +711,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
715
711
&& let Some ( src) = src. as_str ( )
716
712
{
717
713
use rustc_lexer:: TokenKind :: { BlockComment , LineComment , OpenBrace , Semi , Whitespace } ;
718
- if !tokenize ( src)
714
+ if !tokenize ( src, FrontmatterAllowed :: No )
719
715
. map ( |t| t. kind )
720
716
. filter ( |t| !matches ! ( t, Whitespace | LineComment { .. } | BlockComment { .. } | Semi ) )
721
717
. eq ( [ OpenBrace ] )
0 commit comments