Skip to content

Commit

Permalink
Auto merge of rust-lang#87284 - Aaron1011:remove-paren-special, r=pet…
Browse files Browse the repository at this point in the history
…rochenkov

Remove special case for `ExprKind::Paren` in `MutVisitor`

The special case breaks several useful invariants (`ExpnId`s are
globally unique, and never change). This special case
was added back in 2016 in rust-lang#34355

r? `@petrochenkov`
  • Loading branch information
bors committed Jul 19, 2021
2 parents 014026d + f9f238e commit 6535449
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 0 additions & 6 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1347,12 +1347,6 @@ pub fn noop_visit_expr<T: MutVisitor>(
}
ExprKind::Paren(expr) => {
vis.visit_expr(expr);

// Nodes that are equal modulo `Paren` sugar no-ops should have the same IDs.
*id = expr.id;
vis.visit_span(span);
visit_thin_attrs(attrs, vis);
return;
}
ExprKind::Yield(expr) => {
visit_opt(expr, |expr| vis.visit_expr(expr));
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/lint/issue-87274-paren-parent.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// check-pass
// Tests that we properly lint at 'paren' expressions

fn foo() -> Result<(), String> {
(try!(Ok::<u8, String>(1))); //~ WARN use of deprecated macro `try`
Ok(())
}

fn main() {}
10 changes: 10 additions & 0 deletions src/test/ui/lint/issue-87274-paren-parent.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: use of deprecated macro `try`: use the `?` operator instead
--> $DIR/issue-87274-paren-parent.rs:5:6
|
LL | (try!(Ok::<u8, String>(1)));
| ^^^
|
= note: `#[warn(deprecated)]` on by default

warning: 1 warning emitted

0 comments on commit 6535449

Please sign in to comment.