Change:
I'd be interested in handling this. Looking at , it looks fairly straightforward -- however it does look like there could be some ambiguity with return values in blocks (e.g. ) Would we want to disambiguate lints, or would it be fine to use the same lint diagnostic for both cases?
what sort of ambiguity do you mean? I'd expect a single lint on in your example (note that we about unused ).
To use your original example, Both and are , since they represent the implicit return at the end of a block. I was wondering if we'd care about the case, and if we did, if it made sense to treat it the same as . If you naively add a match arm to the visitor, you get the same diagnostic for both.
Yes, both and should be linted here.

Discussion:
#[inline] pub fn variant_range(&self) -> Range<VariantIdx> { <del> (VariantIdx::new(0)..VariantIdx::new(self.variants.len())) </del> <ins> VariantIdx::new(0)..VariantIdx::new(self.variants.len()) </ins> } /// Computes the discriminant value used by a specific variant.

pub fn variant_range(&self, def_id: DefId, tcx: TyCtxt<'tcx>) -> Range<VariantIdx> { // FIXME requires optimized MIR let num_variants = tcx.generator_layout(def_id).variant_fields.len(); <del> (VariantIdx::new(0)..VariantIdx::new(num_variants)) </del> <ins> VariantIdx::new(0)..VariantIdx::new(num_variants) </ins> } /// The discriminant for the given variant. Panics if the `variant_index` is

R: RangeBounds<K>, { let (start, end) = self.range_slice_indices(range); <del> (&self.data[start..end]) </del> <ins> &self.data[start..end] </ins> } #[inline]

} fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) { <del> if let ast::StmtKind::Local(ref local) = s.kind { self.check_unused_parens_pat(cx, &local.pat, false, false); </del> <ins> use ast::StmtKind::*; </ins> <del> if let Some(ref value) = local.init { self.check_unused_parens_expr(cx, &value, "assigned value", false, None, None); </del> <ins> match s.kind { Local(ref local) => { self.check_unused_parens_pat(cx, &local.pat, false, false); if let Some(ref value) = local.init { self.check_unused_parens_expr(cx, &value, "assigned value", false, None, None); } </ins> } <ins> Expr(ref expr) => { self.check_unused_parens_expr(cx, &expr, "block return value", false, None, None); } _ => {} </ins> } }

// 2       --------   // 2 ------- let (lo, hi) = self.boundaries(); let (other_lo, other_hi) = other.boundaries(); <del> (lo == other_hi || hi == other_lo) </del> <ins> lo == other_hi || hi == other_lo </ins> } fn to_pat(&self, tcx: TyCtxt<'tcx>) -> Pat<'tcx> {

// searching forwards for boundaries we've got somewhere to search. let snippet = if let Some(ref src) = local_begin.sf.src { let len = src.len(); <del> (&src[start_index..len]) </del> <ins> &src[start_index..len] </ins> } else if let Some(src) = src.get_source() { let len = src.len(); <del> (&src[start_index..len]) </del> <ins> &src[start_index..len] </ins> } else { return 1; };

let st = match style { ast::StrStyle::Cooked => (format!(""{}"", st.escape_debug())), ast::StrStyle::Raw(n) => { <del> (format!( "r{delim}"{string}"{delim}", delim = "#".repeat(n as usize), string = st )) </del> <ins> format!("r{delim}"{string}"{delim}", delim = "#".repeat(n as usize), string = st) </ins> } }; self.word(st)

panic!() } <ins> fn unused_parens_around_block_return() -> u32 { let foo = { (5) //~ ERROR unnecessary parentheses around block return value }; (5) //~ ERROR unnecessary parentheses around block return value } </ins> trait Trait { fn test(&self); }

LL | fn unused_parens_around_return_type() -> (u32) { |                                          ^^^^^ help: remove these parentheses <ins> error: unnecessary parentheses around block return value --> $DIR/lint-unnecessary-parens.rs:22:9 | LL |         (5) |         ^^^ help: remove these parentheses error: unnecessary parentheses around block return value --> $DIR/lint-unnecessary-parens.rs:24:5 | LL |     (5) |     ^^^ help: remove these parentheses </ins> error: unnecessary parentheses around function argument <del> --> $DIR/lint-unnecessary-parens.rs:36:9 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:43:9 </ins> | LL |     bar((true)); |         ^^^^^^ help: remove these parentheses error: unnecessary parentheses around `if` condition <del> --> $DIR/lint-unnecessary-parens.rs:38:8 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:45:8 </ins> | LL |     if (true) {} |        ^^^^^^ help: remove these parentheses error: unnecessary parentheses around `while` condition <del> --> $DIR/lint-unnecessary-parens.rs:39:11 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:46:11 </ins> | LL |     while (true) {} |           ^^^^^^ help: remove these parentheses warning: denote infinite loops with `loop { ... }` <del> --> $DIR/lint-unnecessary-parens.rs:39:5 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:46:5 </ins> | LL |     while (true) {} |     ^^^^^^^^^^^^ help: use `loop`

= note: `#[warn(while_true)]` on by default error: unnecessary parentheses around `match` head expression <del> --> $DIR/lint-unnecessary-parens.rs:41:11 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:48:11 </ins> | LL |     match (true) { |           ^^^^^^ help: remove these parentheses error: unnecessary parentheses around `let` head expression <del> --> $DIR/lint-unnecessary-parens.rs:44:16 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:51:16 </ins> | LL |     if let 1 = (1) {} |                ^^^ help: remove these parentheses error: unnecessary parentheses around `let` head expression <del> --> $DIR/lint-unnecessary-parens.rs:45:19 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:52:19 </ins> | LL |     while let 1 = (2) {} |                   ^^^ help: remove these parentheses error: unnecessary parentheses around method argument <del> --> $DIR/lint-unnecessary-parens.rs:59:24 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:66:24 </ins> | LL |     X { y: false }.foo((true)); |                        ^^^^^^ help: remove these parentheses error: unnecessary parentheses around assigned value <del> --> $DIR/lint-unnecessary-parens.rs:61:18 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:68:18 </ins> | LL |     let mut _a = (0); |                  ^^^ help: remove these parentheses error: unnecessary parentheses around assigned value <del> --> $DIR/lint-unnecessary-parens.rs:62:10 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:69:10 </ins> | LL |     _a = (0); |          ^^^ help: remove these parentheses error: unnecessary parentheses around assigned value <del> --> $DIR/lint-unnecessary-parens.rs:63:11 </del> <ins> --> $DIR/lint-unnecessary-parens.rs:70:11 </ins> | LL |     _a += (1); |           ^^^ help: remove these parentheses <del> error: aborting due to 13 previous errors </del> <ins> error: aborting due to 15 previous errors </ins>