@@ -33,7 +33,6 @@ use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded};
3333use rustc_session:: lint:: builtin:: BREAK_WITH_LABEL_AND_LOOP ;
3434use rustc_session:: lint:: BuiltinLintDiagnostics ;
3535use rustc_span:: source_map:: { self , Spanned } ;
36- use rustc_span:: symbol:: kw:: PathRoot ;
3736use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
3837use rustc_span:: { BytePos , Pos , Span } ;
3938use thin_vec:: { thin_vec, ThinVec } ;
@@ -642,26 +641,13 @@ impl<'a> Parser<'a> {
642641 }
643642
644643 /// Parse `box expr` - this syntax has been removed, but we still parse this
645- /// for now to provide an automated way to fix usages of it
646- fn parse_expr_box ( & mut self , lo : Span ) -> PResult < ' a , ( Span , ExprKind ) > {
647- let ( span, expr) = self . parse_expr_prefix_common ( lo) ?;
648- let code = self . sess . source_map ( ) . span_to_snippet ( span. with_lo ( lo. hi ( ) ) ) . unwrap ( ) ;
649- self . dcx ( ) . emit_err ( errors:: BoxSyntaxRemoved { span, code : code. trim ( ) } ) ;
650- // So typechecking works, parse `box <expr>` as `::std::boxed::Box::new(expr)`
651- let path = Path {
652- span,
653- segments : [
654- PathSegment :: from_ident ( Ident :: with_dummy_span ( PathRoot ) ) ,
655- PathSegment :: from_ident ( Ident :: with_dummy_span ( sym:: std) ) ,
656- PathSegment :: from_ident ( Ident :: from_str ( "boxed" ) ) ,
657- PathSegment :: from_ident ( Ident :: from_str ( "Box" ) ) ,
658- PathSegment :: from_ident ( Ident :: with_dummy_span ( sym:: new) ) ,
659- ]
660- . into ( ) ,
661- tokens : None ,
662- } ;
663- let path = self . mk_expr ( span, ExprKind :: Path ( None , path) ) ;
664- Ok ( ( span, self . mk_call ( path, ThinVec :: from ( [ expr] ) ) ) )
644+ /// for now to provide a more useful error
645+ fn parse_expr_box ( & mut self , box_kw : Span ) -> PResult < ' a , ( Span , ExprKind ) > {
646+ let ( span, _) = self . parse_expr_prefix_common ( box_kw) ?;
647+ let inner_span = span. with_lo ( box_kw. hi ( ) ) ;
648+ let code = self . sess . source_map ( ) . span_to_snippet ( inner_span) . unwrap ( ) ;
649+ self . dcx ( ) . emit_err ( errors:: BoxSyntaxRemoved { span : span, code : code. trim ( ) } ) ;
650+ Ok ( ( span, ExprKind :: Err ) )
665651 }
666652
667653 fn is_mistaken_not_ident_negation ( & self ) -> bool {
0 commit comments