diff options
| author | bors <bors@rust-lang.org> | 2021-07-19 23:50:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-19 23:50:23 +0000 |
| commit | 6535449a002264ee08dec8e741f1aadd97428fae (patch) | |
| tree | 883f6eeb348e6c283e65d21a6eb62db61c93b418 | |
| parent | 014026d1a7ca991f82f12efa95ef4dffb29dc8af (diff) | |
| parent | f9f238e6b8fcfbe4ab8af2b48cebf597d47d308b (diff) | |
| download | rust-6535449a002264ee08dec8e741f1aadd97428fae.tar.gz rust-6535449a002264ee08dec8e741f1aadd97428fae.zip | |
Auto merge of #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 https://github.com/rust-lang/rust/pull/34355 r? `@petrochenkov`
| -rw-r--r-- | compiler/rustc_ast/src/mut_visit.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/lint/issue-87274-paren-parent.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/lint/issue-87274-paren-parent.stderr | 10 |
3 files changed, 19 insertions, 6 deletions
diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 296766f8019..87950b44083 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -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)); diff --git a/src/test/ui/lint/issue-87274-paren-parent.rs b/src/test/ui/lint/issue-87274-paren-parent.rs new file mode 100644 index 00000000000..0141c5a252f --- /dev/null +++ b/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() {} diff --git a/src/test/ui/lint/issue-87274-paren-parent.stderr b/src/test/ui/lint/issue-87274-paren-parent.stderr new file mode 100644 index 00000000000..f06024298bc --- /dev/null +++ b/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 + |
