Skip to content

Commit 6535449

Browse files
committed
Auto merge of rust-lang#87284 - Aaron1011:remove-paren-special, r=petrochenkov
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`
2 parents 014026d + f9f238e commit 6535449

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

compiler/rustc_ast/src/mut_visit.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1347,12 +1347,6 @@ pub fn noop_visit_expr<T: MutVisitor>(
13471347
}
13481348
ExprKind::Paren(expr) => {
13491349
vis.visit_expr(expr);
1350-
1351-
// Nodes that are equal modulo `Paren` sugar no-ops should have the same IDs.
1352-
*id = expr.id;
1353-
vis.visit_span(span);
1354-
visit_thin_attrs(attrs, vis);
1355-
return;
13561350
}
13571351
ExprKind::Yield(expr) => {
13581352
visit_opt(expr, |expr| vis.visit_expr(expr));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// check-pass
2+
// Tests that we properly lint at 'paren' expressions
3+
4+
fn foo() -> Result<(), String> {
5+
(try!(Ok::<u8, String>(1))); //~ WARN use of deprecated macro `try`
6+
Ok(())
7+
}
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: use of deprecated macro `try`: use the `?` operator instead
2+
--> $DIR/issue-87274-paren-parent.rs:5:6
3+
|
4+
LL | (try!(Ok::<u8, String>(1)));
5+
| ^^^
6+
|
7+
= note: `#[warn(deprecated)]` on by default
8+
9+
warning: 1 warning emitted
10+

0 commit comments

Comments
 (0)