Skip to content

Commit 19a38de

Browse files
committedAug 30, 2019
Auto merge of #63402 - estebank:strip-margin, r=oli-obk
Strip code to the left and right in diagnostics for long lines Fix #62999.
·
1.88.01.39.0
2 parents c7d4df0 + aaf4dc3 commit 19a38de

26 files changed

+580
-156
lines changed
 

‎Cargo.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,6 +3232,7 @@ dependencies = [
32323232
"rustc_data_structures",
32333233
"serialize",
32343234
"syntax_pos",
3235+
"term_size",
32353236
"termcolor",
32363237
"unicode-width",
32373238
]
@@ -4107,6 +4108,17 @@ dependencies = [
41074108
"winapi 0.3.6",
41084109
]
41094110

4111+
[[package]]
4112+
name = "term_size"
4113+
version = "0.3.1"
4114+
source = "registry+https://github.com/rust-lang/crates.io-index"
4115+
checksum = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327"
4116+
dependencies = [
4117+
"kernel32-sys",
4118+
"libc",
4119+
"winapi 0.2.8",
4120+
]
4121+
41104122
[[package]]
41114123
name = "termcolor"
41124124
version = "1.0.4"

‎src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12921292
"show macro backtraces even for non-local macros"),
12931293
teach: bool = (false, parse_bool, [TRACKED],
12941294
"show extended diagnostic help"),
1295+
terminal_width: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
1296+
"set the current terminal width"),
12951297
continue_parse_after_error: bool = (false, parse_bool, [TRACKED],
12961298
"attempt to recover from parse errors (experimental)"),
12971299
dep_tasks: bool = (false, parse_bool, [UNTRACKED],

‎src/librustc/session/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,13 +1055,15 @@ fn default_emitter(
10551055
Some(source_map.clone()),
10561056
short,
10571057
sopts.debugging_opts.teach,
1058+
sopts.debugging_opts.terminal_width,
10581059
),
10591060
Some(dst) => EmitterWriter::new(
10601061
dst,
10611062
Some(source_map.clone()),
10621063
short,
10631064
false, // no teach messages when writing to a buffer
10641065
false, // no colors when writing to a buffer
1066+
None, // no terminal width
10651067
),
10661068
};
10671069
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing))
@@ -1375,7 +1377,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
13751377
let emitter: Box<dyn Emitter + sync::Send> = match output {
13761378
config::ErrorOutputType::HumanReadable(kind) => {
13771379
let (short, color_config) = kind.unzip();
1378-
Box::new(EmitterWriter::stderr(color_config, None, short, false))
1380+
Box::new(EmitterWriter::stderr(color_config, None, short, false, None))
13791381
}
13801382
config::ErrorOutputType::Json { pretty, json_rendered } =>
13811383
Box::new(JsonEmitter::basic(pretty, json_rendered)),
@@ -1389,7 +1391,7 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
13891391
let emitter: Box<dyn Emitter + sync::Send> = match output {
13901392
config::ErrorOutputType::HumanReadable(kind) => {
13911393
let (short, color_config) = kind.unzip();
1392-
Box::new(EmitterWriter::stderr(color_config, None, short, false))
1394+
Box::new(EmitterWriter::stderr(color_config, None, short, false, None))
13931395
}
13941396
config::ErrorOutputType::Json { pretty, json_rendered } =>
13951397
Box::new(JsonEmitter::basic(pretty, json_rendered)),

‎src/librustc_driver/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,11 +1156,13 @@ pub fn report_ices_to_stderr_if_any<F: FnOnce() -> R, R>(f: F) -> Result<R, Erro
11561156
// Thread panicked without emitting a fatal diagnostic
11571157
eprintln!("");
11581158

1159-
let emitter =
1160-
Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
1161-
None,
1162-
false,
1163-
false));
1159+
let emitter = Box::new(errors::emitter::EmitterWriter::stderr(
1160+
errors::ColorConfig::Auto,
1161+
None,
1162+
false,
1163+
false,
1164+
None,
1165+
));
11641166
let handler = errors::Handler::with_emitter(true, None, emitter);
11651167

11661168
// a .span_bug or .bug call has already printed what

‎src/librustc_errors/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ unicode-width = "0.1.4"
1818
atty = "0.2"
1919
termcolor = "1.0"
2020
annotate-snippets = "0.6.1"
21+
term_size = "0.3.1"

‎src/librustc_errors/emitter.rs

Lines changed: 370 additions & 92 deletions
Large diffs are not rendered by default.

‎src/librustc_errors/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl Handler {
383383
cm: Option<Lrc<SourceMapperDyn>>,
384384
flags: HandlerFlags)
385385
-> Handler {
386-
let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false));
386+
let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false, None));
387387
Handler::with_emitter_and_flags(emitter, flags)
388388
}
389389

‎src/librustdoc/core.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ pub fn new_handler(error_format: ErrorOutputType,
193193
source_map.map(|cm| cm as _),
194194
short,
195195
sessopts.debugging_opts.teach,
196+
sessopts.debugging_opts.terminal_width,
196197
).ui_testing(ui_testing)
197198
)
198199
},

‎src/librustdoc/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ pub fn make_test(s: &str,
433433
// Any errors in parsing should also appear when the doctest is compiled for real, so just
434434
// send all the errors that libsyntax emits directly into a `Sink` instead of stderr.
435435
let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
436-
let emitter = EmitterWriter::new(box io::sink(), None, false, false, false);
436+
let emitter = EmitterWriter::new(box io::sink(), None, false, false, false, None);
437437
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
438438
let handler = Handler::with_emitter(false, None, box emitter);
439439
let sess = ParseSess::with_span_handler(handler, cm);

‎src/libsyntax/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Diagnostic {
219219
}
220220
let buf = BufWriter::default();
221221
let output = buf.clone();
222-
je.json_rendered.new_emitter(Box::new(buf), Some(je.sm.clone()), false)
222+
je.json_rendered.new_emitter(Box::new(buf), Some(je.sm.clone()), false, None)
223223
.ui_testing(je.ui_testing).emit_diagnostic(db);
224224
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
225225
let output = String::from_utf8(output).unwrap();

‎src/libsyntax/parse/lexer/tests.rs

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ use errors::{Handler, emitter::EmitterWriter};
1010
use syntax_pos::{BytePos, Span};
1111

1212
fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess {
13-
let emitter = EmitterWriter::new(Box::new(io::sink()), Some(sm.clone()), false, false, false);
13+
let emitter = EmitterWriter::new(
14+
Box::new(io::sink()),
15+
Some(sm.clone()),
16+
false,
17+
false,
18+
false,
19+
None,
20+
);
1421
ParseSess::with_span_handler(Handler::with_emitter(true, None, Box::new(emitter)), sm)
1522
}
1623

@@ -28,10 +35,11 @@ fn t1() {
2835
with_default_globals(|| {
2936
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
3037
let sh = mk_sess(sm.clone());
31-
let mut string_reader = setup(&sm,
32-
&sh,
33-
"/* my source file */ fn main() { println!(\"zebra\"); }\n"
34-
.to_string());
38+
let mut string_reader = setup(
39+
&sm,
40+
&sh,
41+
"/* my source file */ fn main() { println!(\"zebra\"); }\n".to_string(),
42+
);
3543
assert_eq!(string_reader.next_token(), token::Comment);
3644
assert_eq!(string_reader.next_token(), token::Whitespace);
3745
let tok1 = string_reader.next_token();
@@ -127,8 +135,10 @@ fn character_a() {
127135
with_default_globals(|| {
128136
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
129137
let sh = mk_sess(sm.clone());
130-
assert_eq!(setup(&sm, &sh, "'a'".to_string()).next_token(),
131-
mk_lit(token::Char, "a", None));
138+
assert_eq!(
139+
setup(&sm, &sh, "'a'".to_string()).next_token(),
140+
mk_lit(token::Char, "a", None),
141+
);
132142
})
133143
}
134144

@@ -137,8 +147,10 @@ fn character_space() {
137147
with_default_globals(|| {
138148
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
139149
let sh = mk_sess(sm.clone());
140-
assert_eq!(setup(&sm, &sh, "' '".to_string()).next_token(),
141-
mk_lit(token::Char, " ", None));
150+
assert_eq!(
151+
setup(&sm, &sh, "' '".to_string()).next_token(),
152+
mk_lit(token::Char, " ", None),
153+
);
142154
})
143155
}
144156

@@ -147,8 +159,10 @@ fn character_escaped() {
147159
with_default_globals(|| {
148160
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
149161
let sh = mk_sess(sm.clone());
150-
assert_eq!(setup(&sm, &sh, "'\\n'".to_string()).next_token(),
151-
mk_lit(token::Char, "\\n", None));
162+
assert_eq!(
163+
setup(&sm, &sh, "'\\n'".to_string()).next_token(),
164+
mk_lit(token::Char, "\\n", None),
165+
);
152166
})
153167
}
154168

@@ -157,8 +171,10 @@ fn lifetime_name() {
157171
with_default_globals(|| {
158172
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
159173
let sh = mk_sess(sm.clone());
160-
assert_eq!(setup(&sm, &sh, "'abc".to_string()).next_token(),
161-
token::Lifetime(Symbol::intern("'abc")));
174+
assert_eq!(
175+
setup(&sm, &sh, "'abc".to_string()).next_token(),
176+
token::Lifetime(Symbol::intern("'abc")),
177+
);
162178
})
163179
}
164180

@@ -167,8 +183,10 @@ fn raw_string() {
167183
with_default_globals(|| {
168184
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
169185
let sh = mk_sess(sm.clone());
170-
assert_eq!(setup(&sm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string()).next_token(),
171-
mk_lit(token::StrRaw(3), "\"#a\\b\x00c\"", None));
186+
assert_eq!(
187+
setup(&sm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string()).next_token(),
188+
mk_lit(token::StrRaw(3), "\"#a\\b\x00c\"", None),
189+
);
172190
})
173191
}
174192

@@ -179,11 +197,15 @@ fn literal_suffixes() {
179197
let sh = mk_sess(sm.clone());
180198
macro_rules! test {
181199
($input: expr, $tok_type: ident, $tok_contents: expr) => {{
182-
assert_eq!(setup(&sm, &sh, format!("{}suffix", $input)).next_token(),
183-
mk_lit(token::$tok_type, $tok_contents, Some("suffix")));
200+
assert_eq!(
201+
setup(&sm, &sh, format!("{}suffix", $input)).next_token(),
202+
mk_lit(token::$tok_type, $tok_contents, Some("suffix")),
203+
);
184204
// with a whitespace separator:
185-
assert_eq!(setup(&sm, &sh, format!("{} suffix", $input)).next_token(),
186-
mk_lit(token::$tok_type, $tok_contents, None));
205+
assert_eq!(
206+
setup(&sm, &sh, format!("{} suffix", $input)).next_token(),
207+
mk_lit(token::$tok_type, $tok_contents, None),
208+
);
187209
}}
188210
}
189211

@@ -197,12 +219,18 @@ fn literal_suffixes() {
197219
test!("1.0", Float, "1.0");
198220
test!("1.0e10", Float, "1.0e10");
199221

200-
assert_eq!(setup(&sm, &sh, "2us".to_string()).next_token(),
201-
mk_lit(token::Integer, "2", Some("us")));
202-
assert_eq!(setup(&sm, &sh, "r###\"raw\"###suffix".to_string()).next_token(),
203-
mk_lit(token::StrRaw(3), "raw", Some("suffix")));
204-
assert_eq!(setup(&sm, &sh, "br###\"raw\"###suffix".to_string()).next_token(),
205-
mk_lit(token::ByteStrRaw(3), "raw", Some("suffix")));
222+
assert_eq!(
223+
setup(&sm, &sh, "2us".to_string()).next_token(),
224+
mk_lit(token::Integer, "2", Some("us")),
225+
);
226+
assert_eq!(
227+
setup(&sm, &sh, "r###\"raw\"###suffix".to_string()).next_token(),
228+
mk_lit(token::StrRaw(3), "raw", Some("suffix")),
229+
);
230+
assert_eq!(
231+
setup(&sm, &sh, "br###\"raw\"###suffix".to_string()).next_token(),
232+
mk_lit(token::ByteStrRaw(3), "raw", Some("suffix")),
233+
);
206234
})
207235
}
208236

‎src/libsyntax/tests.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,14 @@ fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &
144144
println!("text: {:?}", source_map.span_to_snippet(span));
145145
}
146146

147-
let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }),
148-
Some(source_map.clone()),
149-
false,
150-
false,
151-
false);
147+
let emitter = EmitterWriter::new(
148+
Box::new(Shared { data: output.clone() }),
149+
Some(source_map.clone()),
150+
false,
151+
false,
152+
false,
153+
None,
154+
);
152155
let handler = Handler::with_emitter(true, None, Box::new(emitter));
153156
handler.span_err(msp, "foo");
154157

‎src/test/ui/inline-asm-bad-operand.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ LL | asm!("mov sp, $0"::"r"(addr),
3737
error[E0669]: invalid value for constraint in inline assembly
3838
--> $DIR/inline-asm-bad-operand.rs:56:32
3939
|
40-
LL | "r"("hello e0669"));
41-
| ^^^^^^^^^^^^^
40+
LL | ... "r"("hello e0669"));
41+
| ^^^^^^^^^^^^^
4242

4343
error: aborting due to 7 previous errors
4444

‎src/test/ui/lint/lint-stability-deprecated.stderr

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ LL | deprecated_unstable_text();
6767
warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
6868
--> $DIR/lint-stability-deprecated.rs:57:9
6969
|
70-
LL | Trait::trait_deprecated_unstable_text(&foo);
71-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70+
LL | ... Trait::trait_deprecated_unstable_text(&foo);
71+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7272

7373
warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
7474
--> $DIR/lint-stability-deprecated.rs:59:9
7575
|
76-
LL | <Foo as Trait>::trait_deprecated_unstable_text(&foo);
77-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76+
LL | ... <Foo as Trait>::trait_deprecated_unstable_text(&foo);
77+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7878

7979
warning: use of deprecated item 'lint_stability::DeprecatedStruct': text
8080
--> $DIR/lint-stability-deprecated.rs:106:17
@@ -181,14 +181,14 @@ LL | <Foo as Trait>::trait_deprecated_unstable(&foo);
181181
warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
182182
--> $DIR/lint-stability-deprecated.rs:155:9
183183
|
184-
LL | Trait::trait_deprecated_unstable_text(&foo);
185-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
184+
LL | ... Trait::trait_deprecated_unstable_text(&foo);
185+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
186186

187187
warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
188188
--> $DIR/lint-stability-deprecated.rs:157:9
189189
|
190-
LL | <Foo as Trait>::trait_deprecated_unstable_text(&foo);
191-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
190+
LL | ... <Foo as Trait>::trait_deprecated_unstable_text(&foo);
191+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192192

193193
warning: use of deprecated item 'lint_stability::DeprecatedTrait': text
194194
--> $DIR/lint-stability-deprecated.rs:185:10
@@ -421,20 +421,20 @@ LL | <Foo>::trait_deprecated_unstable(&foo);
421421
warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text
422422
--> $DIR/lint-stability-deprecated.rs:53:13
423423
|
424-
LL | foo.method_deprecated_unstable_text();
425-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
424+
LL | ... foo.method_deprecated_unstable_text();
425+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
426426

427427
warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text
428428
--> $DIR/lint-stability-deprecated.rs:54:9
429429
|
430-
LL | Foo::method_deprecated_unstable_text(&foo);
431-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
430+
LL | ... Foo::method_deprecated_unstable_text(&foo);
431+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
432432

433433
warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text
434434
--> $DIR/lint-stability-deprecated.rs:55:9
435435
|
436-
LL | <Foo>::method_deprecated_unstable_text(&foo);
437-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
436+
LL | ... <Foo>::method_deprecated_unstable_text(&foo);
437+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
438438

439439
warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
440440
--> $DIR/lint-stability-deprecated.rs:56:13
@@ -445,8 +445,8 @@ LL | foo.trait_deprecated_unstable_text();
445445
warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
446446
--> $DIR/lint-stability-deprecated.rs:58:9
447447
|
448-
LL | <Foo>::trait_deprecated_unstable_text(&foo);
449-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
448+
LL | ... <Foo>::trait_deprecated_unstable_text(&foo);
449+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
450450

451451
warning: use of deprecated item 'lint_stability::DeprecatedStruct::i': text
452452
--> $DIR/lint-stability-deprecated.rs:107:13
@@ -505,8 +505,8 @@ LL | foo.trait_deprecated_unstable_text();
505505
warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
506506
--> $DIR/lint-stability-deprecated.rs:156:9
507507
|
508-
LL | <Foo>::trait_deprecated_unstable_text(&foo);
509-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
508+
LL | ... <Foo>::trait_deprecated_unstable_text(&foo);
509+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
510510

511511
warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text
512512
--> $DIR/lint-stability-deprecated.rs:173:13

‎src/test/ui/regions/regions-name-undeclared.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ LL | fn fn_types(a: &'a isize,
4949
error[E0261]: use of undeclared lifetime name `'b`
5050
--> $DIR/regions-name-undeclared.rs:42:36
5151
|
52-
LL | &'b isize,
53-
| ^^ undeclared lifetime
52+
LL | ... &'b isize,
53+
| ^^ undeclared lifetime
5454

5555
error[E0261]: use of undeclared lifetime name `'b`
5656
--> $DIR/regions-name-undeclared.rs:45:36
5757
|
58-
LL | &'b isize)>,
59-
| ^^ undeclared lifetime
58+
LL | ... &'b isize)>,
59+
| ^^ undeclared lifetime
6060

6161
error[E0261]: use of undeclared lifetime name `'a`
6262
--> $DIR/regions-name-undeclared.rs:46:17
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ignore-tidy-linelength
2+
3+
fn main() {
4+
let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15;
5+
//~^ ERROR mismatched types
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/non-whitespace-trimming-2.rs:4:311
3+
|
4+
LL | ...; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _:...
5+
| ^^ expected (), found integer
6+
|
7+
= note: expected type `()`
8+
found type `{integer}`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ignore-tidy-linelength
2+
3+
fn main() {
4+
let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4";
5+
//~^ ERROR mismatched types
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/non-whitespace-trimming-unicode.rs:4:415
3+
|
4+
LL | ...♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆...
5+
| ^^ expected (), found integer
6+
|
7+
= note: expected type `()`
8+
found type `{integer}`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ignore-tidy-linelength
2+
3+
fn main() {
4+
let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ();
5+
//~^ ERROR mismatched types
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/non-whitespace-trimming.rs:4:241
3+
|
4+
LL | ...) = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ()...
5+
| ^^ expected (), found integer
6+
|
7+
= note: expected type `()`
8+
found type `{integer}`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// ignore-tidy-linelength
2+
3+
fn foo() -> usize {
4+
()
5+
//~^ ERROR mismatched types
6+
}
7+
8+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/whitespace-trimming-2.rs:4:187
3+
|
4+
LL | ...-> usize {
5+
| ----- expected `usize` because of return type
6+
LL | ... ()
7+
| ^^ expected usize, found ()
8+
|
9+
= note: expected type `usize`
10+
found type `()`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ignore-tidy-linelength
2+
3+
fn main() {
4+
let _: () = 42;
5+
//~^ ERROR mismatched types
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/whitespace-trimming.rs:4:193
3+
|
4+
LL | ... let _: () = 42;
5+
| ^^ expected (), found integer
6+
|
7+
= note: expected type `()`
8+
found type `{integer}`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

‎src/tools/tidy/src/deps.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ const WHITELIST: &[Crate<'_>] = &[
162162
Crate("termcolor"),
163163
Crate("terminon"),
164164
Crate("termion"),
165+
Crate("term_size"),
165166
Crate("thread_local"),
166167
Crate("ucd-util"),
167168
Crate("unicode-width"),

0 commit comments

Comments
 (0)
Please sign in to comment.