Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick and dirty fix of the unused_braces lint #71517

Merged
merged 2 commits into from
Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions src/test/rustdoc-ui/unused-braces-lint.rs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}