From e42337b6089dcabcbb9313ff0f7a959c949391d5 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 24 Apr 2020 18:22:18 +0200 Subject: [PATCH 1/2] Quick and dirty fix of the unused_braces lint Adresses #70814 --- src/librustc_lint/unused.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index a3748a3a9fede..ddd252cb290e4 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -16,7 +16,7 @@ use rustc_middle::ty::{self, Ty}; use rustc_session::lint::builtin::UNUSED_ATTRIBUTES; use rustc_span::symbol::Symbol; use rustc_span::symbol::{kw, sym}; -use rustc_span::{BytePos, Span}; +use rustc_span::{BytePos, Span, DUMMY_SP}; use log::debug; @@ -415,6 +415,12 @@ trait UnusedDelimLint { msg: &str, keep_space: (bool, bool), ) { + // FIXME(flip1995): Quick and dirty fix for #70814. This should be fixed in rustdoc + // properly. + if span == DUMMY_SP { + return; + } + cx.struct_span_lint(self.lint(), span, |lint| { let span_msg = format!("unnecessary {} around {}", Self::DELIM_STR, msg); let mut err = lint.build(&span_msg); From 485f1999f59a9895b94534de91e8bbd870e7bd49 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 24 Apr 2020 18:22:59 +0200 Subject: [PATCH 2/2] Add rustdoc regression test for the unused_braces lint --- src/test/rustdoc-ui/unused-braces-lint.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/test/rustdoc-ui/unused-braces-lint.rs diff --git a/src/test/rustdoc-ui/unused-braces-lint.rs b/src/test/rustdoc-ui/unused-braces-lint.rs new file mode 100644 index 0000000000000..be0e31e4be2ff --- /dev/null +++ b/src/test/rustdoc-ui/unused-braces-lint.rs @@ -0,0 +1,14 @@ +// check-pass + +// This tests the bug in #70814, where the unused_braces lint triggered on the following code +// without providing a span. + +#![deny(unused_braces)] + +fn main() { + { + { + use std; + } + } +}