Skip to content

Commit e5d01dc

Browse files
committed
Remove an address comparison from the parser
1 parent 57d3c58 commit e5d01dc

File tree

1 file changed

+1
-6
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+1
-6
lines changed

compiler/rustc_parse/src/parser/expr.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -833,16 +833,11 @@ impl<'a> Parser<'a> {
833833
("cast", None)
834834
};
835835

836-
// Save the memory location of expr before parsing any following postfix operators.
837-
// This will be compared with the memory location of the output expression.
838-
// If they different we can assume we parsed another expression because the existing expression is not reallocated.
839-
let addr_before = &*cast_expr as *const _ as usize;
840836
let with_postfix = self.parse_dot_or_call_expr_with_(cast_expr, span)?;
841-
let changed = addr_before != &*with_postfix as *const _ as usize;
842837

843838
// Check if an illegal postfix operator has been added after the cast.
844839
// If the resulting expression is not a cast, or has a different memory location, it is an illegal postfix operator.
845-
if !matches!(with_postfix.kind, ExprKind::Cast(_, _) | ExprKind::Type(_, _)) || changed {
840+
if !matches!(with_postfix.kind, ExprKind::Cast(_, _) | ExprKind::Type(_, _)) {
846841
let msg = format!(
847842
"{cast_kind} cannot be followed by {}",
848843
match with_postfix.kind {

0 commit comments

Comments
 (0)