Skip to content

Commit

Permalink
Remove special case for ExprKind::Paren in MutVisitor
Browse files Browse the repository at this point in the history
The special case breaks several useful invariants (`ExpnId`s are
globally unique, and never change). This special case
was added back in 2016 in #34355
  • Loading branch information
Aaron1011 committed Jul 19, 2021
1 parent 8df945c commit f9f238e
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
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
@@ -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
@@ -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 f9f238e

Please sign in to comment.