Silence line length warnings

rustfmt tries its best already, we should not fight with it.
This commit is contained in:
Mark Rousskov 2019-12-24 16:21:26 -05:00
parent a9c1c04e98
commit 48291a9dda
2 changed files with 21 additions and 44 deletions

View File

@ -12,47 +12,6 @@ ignore = [
# tidy issues (line length, etc.)
# to be fixed shortly
"src/libcore/iter/adapters/mod.rs",
"src/libcore/iter/traits/iterator.rs",
"src/librustc/hir/lowering.rs",
"src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs",
"src/librustc/lint/mod.rs",
"src/librustc/middle/resolve_lifetime.rs",
"src/librustc/traits/mod.rs",
"src/librustc/ty/constness.rs",
"src/librustc/ty/context.rs",
"src/librustc/ty/wf.rs",
"src/librustc_codegen_llvm/back/write.rs",
"src/librustc_codegen_llvm/consts.rs",
"src/librustc_codegen_llvm/debuginfo/metadata.rs",
"src/librustc_codegen_ssa/base.rs",
"src/librustc_codegen_ssa/mir/place.rs",
"src/librustc_codegen_utils/symbol_names/v0.rs",
"src/librustc_errors/emitter.rs",
"src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs",
"src/librustc_mir/borrow_check/type_check/mod.rs",
"src/librustc_mir/build/expr/as_rvalue.rs",
"src/librustc_mir/build/matches/mod.rs",
"src/librustc_mir/build/mod.rs",
"src/librustc_mir/const_eval.rs",
"src/librustc_mir/interpret/place.rs",
"src/librustc_mir/monomorphize/collector.rs",
"src/librustc_passes/ast_validation.rs",
"src/librustc_resolve/lib.rs",
"src/librustc_resolve/resolve_imports.rs",
"src/librustc_typeck/astconv.rs",
"src/librustc_typeck/check/_match.rs",
"src/librustc_typeck/check/coercion.rs",
"src/librustc_typeck/check/method/confirm.rs",
"src/librustc_typeck/check/mod.rs",
"src/librustc_typeck/check/wfcheck.rs",
"src/librustdoc/html/markdown/tests.rs",
"src/libstd/sys/sgx/abi/mem.rs",
"src/libstd/sys/unix/os.rs",
"src/libsyntax_expand/parse/lexer/tests.rs",
"src/libsyntax_expand/parse/tests.rs",
"src/libsyntax_ext/test.rs",
"src/tools/build-manifest/src/main.rs",
"src/librustc_feature",
# do not format submodules
@ -71,4 +30,7 @@ ignore = [
"src/tools/rls",
"src/tools/rust-installer",
"src/tools/rustfmt",
# We do not format this file as it is externally sourced and auto-generated.
"src/libstd/sys/cloudabi/abi/cloudabi.rs",
]

View File

@ -2,14 +2,17 @@
//!
//! Example checks are:
//!
//! * No lines over 100 characters.
//! * No files with over 3000 lines.
//! * No lines over 100 characters (in non-Rust files).
//! * No files with over 3000 lines (in non-Rust files).
//! * No tabs.
//! * No trailing whitespace.
//! * No CR characters.
//! * No `TODO` or `XXX` directives.
//! * No unexplained ` ```ignore ` or ` ```rust,ignore ` doc tests.
//!
//! Note that some of these rules are excluded from Rust files because we enforce rustfmt. It is
//! preferable to be formatted rather than tidy-clean.
//!
//! A number of these checks can be opted-out of with various directives of the form:
//! `// ignore-tidy-CHECK-NAME`.
@ -142,6 +145,15 @@ pub fn check(path: &Path, bad: &mut bool) {
return;
}
let under_rustfmt = filename.ends_with(".rs") &&
// This list should ideally be sourced from rustfmt.toml but we don't want to add a toml
// parser to tidy.
!file.ancestors().any(|a| {
a.ends_with("src/test") ||
a.ends_with("src/libstd/sys/cloudabi") ||
a.ends_with("src/doc/book")
});
if filename.ends_with(".md")
&& file.parent().unwrap().file_name().unwrap().to_string_lossy() != "error_codes"
{
@ -181,7 +193,10 @@ pub fn check(path: &Path, bad: &mut bool) {
let mut err = |msg: &str| {
tidy_error!(bad, "{}:{}: {}", file.display(), i + 1, msg);
};
if line.chars().count() > max_columns && !long_line_is_ok(max_columns, line) {
if !under_rustfmt
&& line.chars().count() > max_columns
&& !long_line_is_ok(max_columns, line)
{
suppressible_tidy_err!(
err,
skip_line_length,