From 48291a9dda821a81957b44034572c0ec62728f35 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 24 Dec 2019 16:21:26 -0500 Subject: [PATCH] Silence line length warnings rustfmt tries its best already, we should not fight with it. --- rustfmt.toml | 44 +++---------------------------------- src/tools/tidy/src/style.rs | 21 +++++++++++++++--- 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 0a90c89bffe..5eab1944645 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -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", ] diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index addee1108e8..b15c29921d2 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -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,