@@ -22,7 +22,7 @@ use rustc_span::{
2222} ;
2323
2424use crate :: lexer:: StripTokens ;
25- use crate :: parser:: { ForceCollect , Parser } ;
25+ use crate :: parser:: { AllowConstBlockItems , ForceCollect , Parser } ;
2626use crate :: { new_parser_from_source_str, source_str_to_stream, unwrap_or_emit_fatal} ;
2727
2828fn psess ( ) -> ParseSess {
@@ -2239,7 +2239,7 @@ fn parse_item_from_source_str(
22392239 psess : & ParseSess ,
22402240) -> PResult < ' _ , Option < Box < ast:: Item > > > {
22412241 unwrap_or_emit_fatal ( new_parser_from_source_str ( psess, name, source, StripTokens :: Nothing ) )
2242- . parse_item ( ForceCollect :: No )
2242+ . parse_item ( ForceCollect :: No , AllowConstBlockItems :: Yes )
22432243}
22442244
22452245// Produces a `rustc_span::span`.
@@ -2254,7 +2254,9 @@ fn string_to_expr(source_str: String) -> Box<ast::Expr> {
22542254
22552255/// Parses a string, returns an item.
22562256fn string_to_item ( source_str : String ) -> Option < Box < ast:: Item > > {
2257- with_error_checking_parse ( source_str, & psess ( ) , |p| p. parse_item ( ForceCollect :: No ) )
2257+ with_error_checking_parse ( source_str, & psess ( ) , |p| {
2258+ p. parse_item ( ForceCollect :: No , AllowConstBlockItems :: Yes )
2259+ } )
22582260}
22592261
22602262#[ test]
0 commit comments