Skip to content

Commit dfc5ffa

Browse files
authored
Rollup merge of #118756 - jyn514:colors, r=estebank
use bold magenta instead of bold white for highlighting according to a poll of gay people in my phone, purple is the most popular color to use for highlighting | color | percentage | | ---------- | ---------- | | bold white | 6% | | blue | 14% | | cyan | 26% | | purple | 37% | | magenta | 17% | unfortunately, purple is not supported by 16-color terminals, which rustc apparently wants to support for some reason. until we require support for full 256-color terms (e.g. by doing the same feature detection as we currently do for urls), we can't use it. instead, i have collapsed the purple votes into magenta on the theory that they're close, and also because magenta is pretty. before: ![image](https://github.com/rust-lang/rust/assets/23638587/9a89eee2-8b89-422e-8554-812827bb2a23) after: ![image](https://github.com/rust-lang/rust/assets/23638587/5bf3a917-8a20-4afd-af3e-f9491d0d57f5) other colors for comparison: blue: ![image](https://github.com/rust-lang/rust/assets/23638587/6f199c7b-d598-4009-8ffc-6b7b1d0d1f8c) cyan: ![image](https://github.com/rust-lang/rust/assets/23638587/a77e4fe3-563e-4aa5-ae92-745bb67287d1) purple: ![image](https://github.com/rust-lang/rust/assets/23638587/ffe603fb-d811-4106-95a9-4dd4c955924c) magenta without bolding: ![image](https://github.com/rust-lang/rust/assets/23638587/cf927e5f-8b25-4dc2-b8e7-32905a11a459) r? ``@estebank``
2 parents 1ee8327 + 32e48fc commit dfc5ffa

8 files changed

+144
-23
lines changed

compiler/rustc_errors/src/emitter.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,14 @@ fn from_stderr(color: ColorConfig) -> Destination {
26742674
}
26752675
}
26762676

2677+
/// On Windows, BRIGHT_BLUE is hard to read on black. Use cyan instead.
2678+
///
2679+
/// See #36178.
2680+
#[cfg(windows)]
2681+
const BRIGHT_BLUE: Color = Color::Cyan;
2682+
#[cfg(not(windows))]
2683+
const BRIGHT_BLUE: Color = Color::Blue;
2684+
26772685
impl Style {
26782686
fn color_spec(&self, lvl: Level) -> ColorSpec {
26792687
let mut spec = ColorSpec::new();
@@ -2688,11 +2696,7 @@ impl Style {
26882696
Style::LineNumber => {
26892697
spec.set_bold(true);
26902698
spec.set_intense(true);
2691-
if cfg!(windows) {
2692-
spec.set_fg(Some(Color::Cyan));
2693-
} else {
2694-
spec.set_fg(Some(Color::Blue));
2695-
}
2699+
spec.set_fg(Some(BRIGHT_BLUE));
26962700
}
26972701
Style::Quotation => {}
26982702
Style::MainHeaderMsg => {
@@ -2707,19 +2711,15 @@ impl Style {
27072711
}
27082712
Style::UnderlineSecondary | Style::LabelSecondary => {
27092713
spec.set_bold(true).set_intense(true);
2710-
if cfg!(windows) {
2711-
spec.set_fg(Some(Color::Cyan));
2712-
} else {
2713-
spec.set_fg(Some(Color::Blue));
2714-
}
2714+
spec.set_fg(Some(BRIGHT_BLUE));
27152715
}
27162716
Style::HeaderMsg | Style::NoStyle => {}
27172717
Style::Level(lvl) => {
27182718
spec = lvl.color();
27192719
spec.set_bold(true);
27202720
}
27212721
Style::Highlight => {
2722-
spec.set_bold(true);
2722+
spec.set_bold(true).set_fg(Some(Color::Magenta));
27232723
}
27242724
}
27252725
spec

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
1111
const ENTRY_LIMIT: usize = 900;
1212
// FIXME: The following limits should be reduced eventually.
1313
const ISSUES_ENTRY_LIMIT: usize = 1852;
14-
const ROOT_ENTRY_LIMIT: usize = 866;
14+
const ROOT_ENTRY_LIMIT: usize = 867;
1515

1616
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
1717
"rs", // test source files
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0308]: mismatched types
2+
 --> $DIR/highlighting.rs:26:11
3+
 |
4+
LL |  query(wrapped_fn);
5+
 |  ----- ^^^^^^^^^^ one type is more general than the other
6+
 |  |
7+
 |  arguments to this function are incorrect
8+
 |
9+
 = note: expected fn pointer `for<'a> fn(Box<(dyn Any + Send + 'a)>) -> Pin<_>`
10+
 found fn item `fn(Box<(dyn Any + Send + 'static)>) -> Pin<_> {wrapped_fn}`
11+
note: function defined here
12+
 --> $DIR/highlighting.rs:15:4
13+
 |
14+
LL | fn query(_: fn(Box<(dyn Any + Send + '_)>) -> Pin<Box<(
15+
 |  ____^^^^^_-
16+
LL | |  dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
17+
LL | | )>>) {}
18+
 | |___-
19+
20+
error: aborting due to 1 previous error
21+
22+
For more information about this error, try `rustc --explain E0308`.
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Make sure "highlighted" code is colored purple
2+
3+
// compile-flags: --error-format=human --color=always
4+
// error-pattern:for<'a> 
5+
// edition:2018
6+
7+
// revisions: windows not-windows
8+
// [windows]only-windows
9+
// [not-windows]ignore-windows
10+
11+
use core::pin::Pin;
12+
use core::future::Future;
13+
use core::any::Any;
14+
15+
fn query(_: fn(Box<(dyn Any + Send + '_)>) -> Pin<Box<(
16+
dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
17+
)>>) {}
18+
19+
fn wrapped_fn<'a>(_: Box<(dyn Any + Send)>) -> Pin<Box<(
20+
dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
21+
)>> {
22+
Box::pin(async { Err("nope".into()) })
23+
}
24+
25+
fn main() {
26+
query(wrapped_fn);
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0308]: mismatched types
2+
 --> $DIR/highlighting.rs:26:11
3+
 |
4+
LL |  query(wrapped_fn);
5+
 |  ----- ^^^^^^^^^^ one type is more general than the other
6+
 |  |
7+
 |  arguments to this function are incorrect
8+
 |
9+
 = note: expected fn pointer `for<'a> fn(Box<(dyn Any + Send + 'a)>) -> Pin<_>`
10+
 found fn item `fn(Box<(dyn Any + Send + 'static)>) -> Pin<_> {wrapped_fn}`
11+
note: function defined here
12+
 --> $DIR/highlighting.rs:15:4
13+
 |
14+
LL | fn query(_: fn(Box<(dyn Any + Send + '_)>) -> Pin<Box<(
15+
 |  ____^^^^^_-
16+
LL | |  dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
17+
LL | | )>>) {}
18+
 | |___-
19+
20+
error: aborting due to 1 previous error
21+
22+
For more information about this error, try `rustc --explain E0308`.

tests/ui/suggestions/multiline-multipart-suggestion.stderr renamed to tests/ui/error-emitter/multiline-multipart-suggestion.not-windows.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0106]: missing lifetime specifier
2-
 --> $DIR/multiline-multipart-suggestion.rs:4:34
2+
 --> $DIR/multiline-multipart-suggestion.rs:8:34
33
 |
4-
LL | fn short(foo_bar: &Vec<&i32>) -> &i32 {
4+
LL | fn short(foo_bar: &Vec<&i32>) -> &i32 {
55
 |  ---------- ^ expected named lifetime parameter
66
 |
77
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
88
help: consider introducing a named lifetime parameter
99
 |
10-
LL | fn short<'a>(foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
10+
LL | fn short<'a>(foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
1111
 | ++++ ++ ++ ++
1212

1313
error[E0106]: missing lifetime specifier
14-
 --> $DIR/multiline-multipart-suggestion.rs:11:6
14+
 --> $DIR/multiline-multipart-suggestion.rs:15:6
1515
 |
1616
LL |  foo_bar: &Vec<&i32>,
1717
 |  ----------
@@ -22,22 +22,22 @@
2222
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
2323
help: consider introducing a named lifetime parameter
2424
 |
25-
LL ~ fn long<'a>(
25+
LL ~ fn long<'a>(
2626
LL ~  foo_bar: &'a Vec<&'a i32>,
2727
LL |  something_very_long_so_that_the_line_will_wrap_around__________: i32,
2828
LL ~ ) -> &'a i32 {
2929
 |
3030

3131
error[E0106]: missing lifetime specifier
32-
 --> $DIR/multiline-multipart-suggestion.rs:16:29
32+
 --> $DIR/multiline-multipart-suggestion.rs:20:29
3333
 |
3434
LL |  foo_bar: &Vec<&i32>) -> &i32 {
3535
 |  ---------- ^ expected named lifetime parameter
3636
 |
3737
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
3838
help: consider introducing a named lifetime parameter
3939
 |
40-
LL ~ fn long2<'a>(
40+
LL ~ fn long2<'a>(
4141
LL ~  foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
4242
 |
4343

tests/ui/suggestions/multiline-multipart-suggestion.rs renamed to tests/ui/error-emitter/multiline-multipart-suggestion.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
// compile-flags: --error-format=human --color=always
2-
// ignore-windows
2+
// error-pattern: missing lifetime specifier
33

4-
fn short(foo_bar: &Vec<&i32>) -> &i32 { //~ ERROR missing lifetime specifier
4+
// revisions: windows not-windows
5+
// [windows]only-windows
6+
// [not-windows]ignore-windows
7+
8+
fn short(foo_bar: &Vec<&i32>) -> &i32 {
59
&12
610
}
711

8-
fn long( //~ ERROR missing lifetime specifier
12+
fn long(
913
foo_bar: &Vec<&i32>,
1014
something_very_long_so_that_the_line_will_wrap_around__________: i32,
1115
) -> &i32 {
1216
&12
1317
}
1418

15-
fn long2( //~ ERROR missing lifetime specifier
19+
fn long2(
1620
foo_bar: &Vec<&i32>) -> &i32 {
1721
&12
1822
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
error[E0106]: missing lifetime specifier
2+
 --> $DIR/multiline-multipart-suggestion.rs:8:34
3+
 |
4+
LL | fn short(foo_bar: &Vec<&i32>) -> &i32 {
5+
 |  ---------- ^ expected named lifetime parameter
6+
 |
7+
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
8+
help: consider introducing a named lifetime parameter
9+
 |
10+
LL | fn short<'a>(foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
11+
 | ++++ ++ ++ ++
12+
13+
error[E0106]: missing lifetime specifier
14+
 --> $DIR/multiline-multipart-suggestion.rs:15:6
15+
 |
16+
LL |  foo_bar: &Vec<&i32>,
17+
 |  ----------
18+
LL |  something_very_long_so_that_the_line_will_wrap_around__________: i32,
19+
LL | ) -> &i32 {
20+
 |  ^ expected named lifetime parameter
21+
 |
22+
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
23+
help: consider introducing a named lifetime parameter
24+
 |
25+
LL ~ fn long<'a>(
26+
LL ~  foo_bar: &'a Vec<&'a i32>,
27+
LL |  something_very_long_so_that_the_line_will_wrap_around__________: i32,
28+
LL ~ ) -> &'a i32 {
29+
 |
30+
31+
error[E0106]: missing lifetime specifier
32+
 --> $DIR/multiline-multipart-suggestion.rs:20:29
33+
 |
34+
LL |  foo_bar: &Vec<&i32>) -> &i32 {
35+
 |  ---------- ^ expected named lifetime parameter
36+
 |
37+
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
38+
help: consider introducing a named lifetime parameter
39+
 |
40+
LL ~ fn long2<'a>(
41+
LL ~  foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
42+
 |
43+
44+
error: aborting due to 3 previous errors
45+
46+
For more information about this error, try `rustc --explain E0106`.

0 commit comments

Comments
 (0)