Skip to content

Commit 48291a9

Browse files
Silence line length warnings
rustfmt tries its best already, we should not fight with it.
1 parent a9c1c04 commit 48291a9

File tree

2 files changed

+21
-44
lines changed

2 files changed

+21
-44
lines changed

rustfmt.toml

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,6 @@ ignore = [
1212

1313
# tidy issues (line length, etc.)
1414
# to be fixed shortly
15-
"src/libcore/iter/adapters/mod.rs",
16-
"src/libcore/iter/traits/iterator.rs",
17-
"src/librustc/hir/lowering.rs",
18-
"src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs",
19-
"src/librustc/lint/mod.rs",
20-
"src/librustc/middle/resolve_lifetime.rs",
21-
"src/librustc/traits/mod.rs",
22-
"src/librustc/ty/constness.rs",
23-
"src/librustc/ty/context.rs",
24-
"src/librustc/ty/wf.rs",
25-
"src/librustc_codegen_llvm/back/write.rs",
26-
"src/librustc_codegen_llvm/consts.rs",
27-
"src/librustc_codegen_llvm/debuginfo/metadata.rs",
28-
"src/librustc_codegen_ssa/base.rs",
29-
"src/librustc_codegen_ssa/mir/place.rs",
30-
"src/librustc_codegen_utils/symbol_names/v0.rs",
31-
"src/librustc_errors/emitter.rs",
32-
"src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs",
33-
"src/librustc_mir/borrow_check/type_check/mod.rs",
34-
"src/librustc_mir/build/expr/as_rvalue.rs",
35-
"src/librustc_mir/build/matches/mod.rs",
36-
"src/librustc_mir/build/mod.rs",
37-
"src/librustc_mir/const_eval.rs",
38-
"src/librustc_mir/interpret/place.rs",
39-
"src/librustc_mir/monomorphize/collector.rs",
40-
"src/librustc_passes/ast_validation.rs",
41-
"src/librustc_resolve/lib.rs",
42-
"src/librustc_resolve/resolve_imports.rs",
43-
"src/librustc_typeck/astconv.rs",
44-
"src/librustc_typeck/check/_match.rs",
45-
"src/librustc_typeck/check/coercion.rs",
46-
"src/librustc_typeck/check/method/confirm.rs",
47-
"src/librustc_typeck/check/mod.rs",
48-
"src/librustc_typeck/check/wfcheck.rs",
49-
"src/librustdoc/html/markdown/tests.rs",
50-
"src/libstd/sys/sgx/abi/mem.rs",
51-
"src/libstd/sys/unix/os.rs",
52-
"src/libsyntax_expand/parse/lexer/tests.rs",
53-
"src/libsyntax_expand/parse/tests.rs",
54-
"src/libsyntax_ext/test.rs",
55-
"src/tools/build-manifest/src/main.rs",
5615
"src/librustc_feature",
5716

5817
# do not format submodules
@@ -71,4 +30,7 @@ ignore = [
7130
"src/tools/rls",
7231
"src/tools/rust-installer",
7332
"src/tools/rustfmt",
33+
34+
# We do not format this file as it is externally sourced and auto-generated.
35+
"src/libstd/sys/cloudabi/abi/cloudabi.rs",
7436
]

src/tools/tidy/src/style.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
//!
33
//! Example checks are:
44
//!
5-
//! * No lines over 100 characters.
6-
//! * No files with over 3000 lines.
5+
//! * No lines over 100 characters (in non-Rust files).
6+
//! * No files with over 3000 lines (in non-Rust files).
77
//! * No tabs.
88
//! * No trailing whitespace.
99
//! * No CR characters.
1010
//! * No `TODO` or `XXX` directives.
1111
//! * No unexplained ` ```ignore ` or ` ```rust,ignore ` doc tests.
1212
//!
13+
//! Note that some of these rules are excluded from Rust files because we enforce rustfmt. It is
14+
//! preferable to be formatted rather than tidy-clean.
15+
//!
1316
//! A number of these checks can be opted-out of with various directives of the form:
1417
//! `// ignore-tidy-CHECK-NAME`.
1518
@@ -142,6 +145,15 @@ pub fn check(path: &Path, bad: &mut bool) {
142145
return;
143146
}
144147

148+
let under_rustfmt = filename.ends_with(".rs") &&
149+
// This list should ideally be sourced from rustfmt.toml but we don't want to add a toml
150+
// parser to tidy.
151+
!file.ancestors().any(|a| {
152+
a.ends_with("src/test") ||
153+
a.ends_with("src/libstd/sys/cloudabi") ||
154+
a.ends_with("src/doc/book")
155+
});
156+
145157
if filename.ends_with(".md")
146158
&& file.parent().unwrap().file_name().unwrap().to_string_lossy() != "error_codes"
147159
{
@@ -181,7 +193,10 @@ pub fn check(path: &Path, bad: &mut bool) {
181193
let mut err = |msg: &str| {
182194
tidy_error!(bad, "{}:{}: {}", file.display(), i + 1, msg);
183195
};
184-
if line.chars().count() > max_columns && !long_line_is_ok(max_columns, line) {
196+
if !under_rustfmt
197+
&& line.chars().count() > max_columns
198+
&& !long_line_is_ok(max_columns, line)
199+
{
185200
suppressible_tidy_err!(
186201
err,
187202
skip_line_length,

0 commit comments

Comments
 (0)