@@ -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 {
@@ -2241,7 +2241,7 @@ fn parse_item_from_source_str(
22412241 psess : & ParseSess ,
22422242) -> PResult < ' _ , Option < Box < ast:: Item > > > {
22432243 unwrap_or_emit_fatal ( new_parser_from_source_str ( psess, name, source, StripTokens :: Nothing ) )
2244- . parse_item ( ForceCollect :: No )
2244+ . parse_item ( ForceCollect :: No , AllowConstBlockItems :: Yes )
22452245}
22462246
22472247// Produces a `rustc_span::span`.
@@ -2256,7 +2256,9 @@ fn string_to_expr(source_str: String) -> Box<ast::Expr> {
22562256
22572257/// Parses a string, returns an item.
22582258fn string_to_item ( source_str : String ) -> Option < Box < ast:: Item > > {
2259- with_error_checking_parse ( source_str, & psess ( ) , |p| p. parse_item ( ForceCollect :: No ) )
2259+ with_error_checking_parse ( source_str, & psess ( ) , |p| {
2260+ p. parse_item ( ForceCollect :: No , AllowConstBlockItems :: Yes )
2261+ } )
22602262}
22612263
22622264#[ test]
0 commit comments