Skip to content
Merged
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
12 changes: 12 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -3219,6 +3219,7 @@ dependencies = [
"rustc_data_structures",
"serialize",
"syntax_pos",
"term_size",
"termcolor",
"unicode-width",
]
@@ -4090,6 +4091,17 @@ dependencies = [
"winapi 0.3.6",
]

[[package]]
name = "term_size"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327"
dependencies = [
"kernel32-sys",
"libc",
"winapi 0.2.8",
]

[[package]]
name = "termcolor"
version = "1.0.4"
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
@@ -1292,6 +1292,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"show macro backtraces even for non-local macros"),
teach: bool = (false, parse_bool, [TRACKED],
"show extended diagnostic help"),
terminal_width: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
"set the current terminal width"),
continue_parse_after_error: bool = (false, parse_bool, [TRACKED],
"attempt to recover from parse errors (experimental)"),
dep_tasks: bool = (false, parse_bool, [UNTRACKED],
6 changes: 4 additions & 2 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
@@ -1055,13 +1055,15 @@ fn default_emitter(
Some(source_map.clone()),
short,
sopts.debugging_opts.teach,
sopts.debugging_opts.terminal_width,
),
Some(dst) => EmitterWriter::new(
dst,
Some(source_map.clone()),
short,
false, // no teach messages when writing to a buffer
false, // no colors when writing to a buffer
None, // no terminal width
),
};
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing))
@@ -1375,7 +1377,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
let emitter: Box<dyn Emitter + sync::Send> = match output {
config::ErrorOutputType::HumanReadable(kind) => {
let (short, color_config) = kind.unzip();
Box::new(EmitterWriter::stderr(color_config, None, short, false))
Box::new(EmitterWriter::stderr(color_config, None, short, false, None))
}
config::ErrorOutputType::Json { pretty, json_rendered } =>
Box::new(JsonEmitter::basic(pretty, json_rendered)),
@@ -1389,7 +1391,7 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
let emitter: Box<dyn Emitter + sync::Send> = match output {
config::ErrorOutputType::HumanReadable(kind) => {
let (short, color_config) = kind.unzip();
Box::new(EmitterWriter::stderr(color_config, None, short, false))
Box::new(EmitterWriter::stderr(color_config, None, short, false, None))
}
config::ErrorOutputType::Json { pretty, json_rendered } =>
Box::new(JsonEmitter::basic(pretty, json_rendered)),
12 changes: 7 additions & 5 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
@@ -1135,11 +1135,13 @@ pub fn report_ices_to_stderr_if_any<F: FnOnce() -> R, R>(f: F) -> Result<R, Erro
// Thread panicked without emitting a fatal diagnostic
eprintln!("");

let emitter =
Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
None,
false,
false));
let emitter = Box::new(errors::emitter::EmitterWriter::stderr(
errors::ColorConfig::Auto,
None,
false,
false,
None,
));
let handler = errors::Handler::with_emitter(true, None, emitter);

// a .span_bug or .bug call has already printed what
1 change: 1 addition & 0 deletions src/librustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
@@ -18,3 +18,4 @@ unicode-width = "0.1.4"
atty = "0.2"
termcolor = "1.0"
annotate-snippets = "0.6.1"
term_size = "0.3.1"
462 changes: 370 additions & 92 deletions src/librustc_errors/emitter.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
@@ -383,7 +383,7 @@ impl Handler {
cm: Option<Lrc<SourceMapperDyn>>,
flags: HandlerFlags)
-> Handler {
let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false));
let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false, None));
Handler::with_emitter_and_flags(emitter, flags)
}

1 change: 1 addition & 0 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
@@ -193,6 +193,7 @@ pub fn new_handler(error_format: ErrorOutputType,
source_map.map(|cm| cm as _),
short,
sessopts.debugging_opts.teach,
sessopts.debugging_opts.terminal_width,
).ui_testing(ui_testing)
)
},
2 changes: 1 addition & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
@@ -427,7 +427,7 @@ pub fn make_test(s: &str,
// Any errors in parsing should also appear when the doctest is compiled for real, so just
// send all the errors that libsyntax emits directly into a `Sink` instead of stderr.
let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let emitter = EmitterWriter::new(box io::sink(), None, false, false, false);
let emitter = EmitterWriter::new(box io::sink(), None, false, false, false, None);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these arguments are really getting out of hand

// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
let handler = Handler::with_emitter(false, None, box emitter);
let sess = ParseSess::with_span_handler(handler, cm);
2 changes: 1 addition & 1 deletion src/libsyntax/json.rs
Original file line number Diff line number Diff line change
@@ -219,7 +219,7 @@ impl Diagnostic {
}
let buf = BufWriter::default();
let output = buf.clone();
je.json_rendered.new_emitter(Box::new(buf), Some(je.sm.clone()), false)
je.json_rendered.new_emitter(Box::new(buf), Some(je.sm.clone()), false, None)
.ui_testing(je.ui_testing).emit_diagnostic(db);
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
let output = String::from_utf8(output).unwrap();
78 changes: 53 additions & 25 deletions src/libsyntax/parse/lexer/tests.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,14 @@ use errors::{Handler, emitter::EmitterWriter};
use syntax_pos::{BytePos, Span};

fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess {
let emitter = EmitterWriter::new(Box::new(io::sink()), Some(sm.clone()), false, false, false);
let emitter = EmitterWriter::new(
Box::new(io::sink()),
Some(sm.clone()),
false,
false,
false,
None,
);
ParseSess::with_span_handler(Handler::with_emitter(true, None, Box::new(emitter)), sm)
}

@@ -28,10 +35,11 @@ fn t1() {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut string_reader = setup(&sm,
&sh,
"/* my source file */ fn main() { println!(\"zebra\"); }\n"
.to_string());
let mut string_reader = setup(
&sm,
&sh,
"/* my source file */ fn main() { println!(\"zebra\"); }\n".to_string(),
);
assert_eq!(string_reader.next_token(), token::Comment);
assert_eq!(string_reader.next_token(), token::Whitespace);
let tok1 = string_reader.next_token();
@@ -127,8 +135,10 @@ fn character_a() {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'a'".to_string()).next_token(),
mk_lit(token::Char, "a", None));
assert_eq!(
setup(&sm, &sh, "'a'".to_string()).next_token(),
mk_lit(token::Char, "a", None),
);
})
}

@@ -137,8 +147,10 @@ fn character_space() {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "' '".to_string()).next_token(),
mk_lit(token::Char, " ", None));
assert_eq!(
setup(&sm, &sh, "' '".to_string()).next_token(),
mk_lit(token::Char, " ", None),
);
})
}

@@ -147,8 +159,10 @@ fn character_escaped() {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'\\n'".to_string()).next_token(),
mk_lit(token::Char, "\\n", None));
assert_eq!(
setup(&sm, &sh, "'\\n'".to_string()).next_token(),
mk_lit(token::Char, "\\n", None),
);
})
}

@@ -157,8 +171,10 @@ fn lifetime_name() {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'abc".to_string()).next_token(),
token::Lifetime(Symbol::intern("'abc")));
assert_eq!(
setup(&sm, &sh, "'abc".to_string()).next_token(),
token::Lifetime(Symbol::intern("'abc")),
);
})
}

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

@@ -179,11 +197,15 @@ fn literal_suffixes() {
let sh = mk_sess(sm.clone());
macro_rules! test {
($input: expr, $tok_type: ident, $tok_contents: expr) => {{
assert_eq!(setup(&sm, &sh, format!("{}suffix", $input)).next_token(),
mk_lit(token::$tok_type, $tok_contents, Some("suffix")));
assert_eq!(
setup(&sm, &sh, format!("{}suffix", $input)).next_token(),
mk_lit(token::$tok_type, $tok_contents, Some("suffix")),
);
// with a whitespace separator:
assert_eq!(setup(&sm, &sh, format!("{} suffix", $input)).next_token(),
mk_lit(token::$tok_type, $tok_contents, None));
assert_eq!(
setup(&sm, &sh, format!("{} suffix", $input)).next_token(),
mk_lit(token::$tok_type, $tok_contents, None),
);
}}
}

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

assert_eq!(setup(&sm, &sh, "2us".to_string()).next_token(),
mk_lit(token::Integer, "2", Some("us")));
assert_eq!(setup(&sm, &sh, "r###\"raw\"###suffix".to_string()).next_token(),
mk_lit(token::StrRaw(3), "raw", Some("suffix")));
assert_eq!(setup(&sm, &sh, "br###\"raw\"###suffix".to_string()).next_token(),
mk_lit(token::ByteStrRaw(3), "raw", Some("suffix")));
assert_eq!(
setup(&sm, &sh, "2us".to_string()).next_token(),
mk_lit(token::Integer, "2", Some("us")),
);
assert_eq!(
setup(&sm, &sh, "r###\"raw\"###suffix".to_string()).next_token(),
mk_lit(token::StrRaw(3), "raw", Some("suffix")),
);
assert_eq!(
setup(&sm, &sh, "br###\"raw\"###suffix".to_string()).next_token(),
mk_lit(token::ByteStrRaw(3), "raw", Some("suffix")),
);
})
}

13 changes: 8 additions & 5 deletions src/libsyntax/tests.rs
Original file line number Diff line number Diff line change
@@ -144,11 +144,14 @@ fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &
println!("text: {:?}", source_map.span_to_snippet(span));
}

let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }),
Some(source_map.clone()),
false,
false,
false);
let emitter = EmitterWriter::new(
Box::new(Shared { data: output.clone() }),
Some(source_map.clone()),
false,
false,
false,
None,
);
let handler = Handler::with_emitter(true, None, Box::new(emitter));
handler.span_err(msp, "foo");

4 changes: 2 additions & 2 deletions src/test/ui/inline-asm-bad-operand.stderr
Original file line number Diff line number Diff line change
@@ -37,8 +37,8 @@ LL | asm!("mov sp, $0"::"r"(addr),
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:56:32
|
LL | "r"("hello e0669"));
| ^^^^^^^^^^^^^
LL | ... "r"("hello e0669"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we trim whitespace more eagerly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, although I want it always to be clear that trimming is happening (with the leading ... and some leading whitespace as possible).

| ^^^^^^^^^^^^^

error: aborting due to 7 previous errors

36 changes: 18 additions & 18 deletions src/test/ui/lint/lint-stability-deprecated.stderr
Original file line number Diff line number Diff line change
@@ -67,14 +67,14 @@ LL | deprecated_unstable_text();
warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text
--> $DIR/lint-stability-deprecated.rs:57:9
|
LL | Trait::trait_deprecated_unstable_text(&foo);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | ... Trait::trait_deprecated_unstable_text(&foo);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

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

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

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

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

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

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

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

warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text
--> $DIR/lint-stability-deprecated.rs:173:13
8 changes: 4 additions & 4 deletions src/test/ui/regions/regions-name-undeclared.stderr
Original file line number Diff line number Diff line change
@@ -49,14 +49,14 @@ LL | fn fn_types(a: &'a isize,
error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/regions-name-undeclared.rs:42:36
|
LL | &'b isize,
| ^^ undeclared lifetime
LL | ... &'b isize,
| ^^ undeclared lifetime

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

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/regions-name-undeclared.rs:46:17
6 changes: 6 additions & 0 deletions src/test/ui/terminal-width/non-whitespace-trimming-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ignore-tidy-linelength

fn main() {
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;
//~^ ERROR mismatched types
}
12 changes: 12 additions & 0 deletions src/test/ui/terminal-width/non-whitespace-trimming-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/non-whitespace-trimming-2.rs:4:311
|
LL | ...; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _:...
| ^^ expected (), found integer
|
= note: expected type `()`
found type `{integer}`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
6 changes: 6 additions & 0 deletions src/test/ui/terminal-width/non-whitespace-trimming-unicode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ignore-tidy-linelength

fn main() {
let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4";
//~^ ERROR mismatched types
}
12 changes: 12 additions & 0 deletions src/test/ui/terminal-width/non-whitespace-trimming-unicode.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/non-whitespace-trimming-unicode.rs:4:415
|
LL | ...♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆...
| ^^ expected (), found integer
|
= note: expected type `()`
found type `{integer}`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
6 changes: 6 additions & 0 deletions src/test/ui/terminal-width/non-whitespace-trimming.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ignore-tidy-linelength

fn main() {
let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ();
//~^ ERROR mismatched types
}
12 changes: 12 additions & 0 deletions src/test/ui/terminal-width/non-whitespace-trimming.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/non-whitespace-trimming.rs:4:241
|
LL | ...) = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ()...
| ^^ expected (), found integer
|
= note: expected type `()`
found type `{integer}`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
8 changes: 8 additions & 0 deletions src/test/ui/terminal-width/whitespace-trimming-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// ignore-tidy-linelength

fn foo() -> usize {
()
//~^ ERROR mismatched types
}

fn main() {}
14 changes: 14 additions & 0 deletions src/test/ui/terminal-width/whitespace-trimming-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/whitespace-trimming-2.rs:4:187
|
LL | ...-> usize {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't too great. Not sure what to do about it though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a pathological case and the current behavior is the best possible one given the constraints.

| ----- expected `usize` because of return type
LL | ... ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could also benefit from more eager whitespace eating

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test in particular can't eat more without changing the shape of the code. The trimming uses bounding boxes, and what you see here is the smallest bounding box possible that points to both the return type and the () being returned by the tail expression. I personally prefer this behavior (at least to start with) to using different left side trimming on different lines.

| ^^ expected usize, found ()
|
= note: expected type `usize`
found type `()`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
6 changes: 6 additions & 0 deletions src/test/ui/terminal-width/whitespace-trimming.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ignore-tidy-linelength

fn main() {
let _: () = 42;
//~^ ERROR mismatched types
}
12 changes: 12 additions & 0 deletions src/test/ui/terminal-width/whitespace-trimming.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/whitespace-trimming.rs:4:193
|
LL | ... let _: () = 42;
| ^^ expected (), found integer
|
= note: expected type `()`
found type `{integer}`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
1 change: 1 addition & 0 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
@@ -159,6 +159,7 @@ const WHITELIST: &[Crate<'_>] = &[
Crate("termcolor"),
Crate("terminon"),
Crate("termion"),
Crate("term_size"),
Crate("thread_local"),
Crate("ucd-util"),
Crate("unicode-width"),