Skip to content

Commit 965cf5c

Browse files
committed
Auto merge of #111820 - matthiaskrgr:rollup-9sb2lw9, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #111745 (Fix overflow in error emitter) - #111770 (Read beta version from the version file if building from a source tarball) - #111797 (Migrate GUI colors test to original CSS color format) - #111809 (Unset MIRI_BLESS for mir-opt-level 4 miri tests) - #111817 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0634557 + 7358166 commit 965cf5c

File tree

11 files changed

+180
-55
lines changed

11 files changed

+180
-55
lines changed

Diff for: compiler/rustc_errors/src/emitter.rs

+19-16
Original file line numberDiff line numberDiff line change
@@ -2303,22 +2303,25 @@ impl EmitterWriter {
23032303

23042304
// Colorize addition/replacements with green.
23052305
for &SubstitutionHighlight { start, end } in highlight_parts {
2306-
// Account for tabs when highlighting (#87972).
2307-
let tabs: usize = line_to_add
2308-
.chars()
2309-
.take(start)
2310-
.map(|ch| match ch {
2311-
'\t' => 3,
2312-
_ => 0,
2313-
})
2314-
.sum();
2315-
buffer.set_style_range(
2316-
*row_num,
2317-
max_line_num_len + 3 + start + tabs,
2318-
max_line_num_len + 3 + end + tabs,
2319-
Style::Addition,
2320-
true,
2321-
);
2306+
// This is a no-op for empty ranges
2307+
if start != end {
2308+
// Account for tabs when highlighting (#87972).
2309+
let tabs: usize = line_to_add
2310+
.chars()
2311+
.take(start)
2312+
.map(|ch| match ch {
2313+
'\t' => 3,
2314+
_ => 0,
2315+
})
2316+
.sum();
2317+
buffer.set_style_range(
2318+
*row_num,
2319+
max_line_num_len + 3 + start + tabs,
2320+
max_line_num_len + 3 + end + tabs,
2321+
Style::Addition,
2322+
true,
2323+
);
2324+
}
23222325
}
23232326
*row_num += 1;
23242327
}

Diff for: compiler/rustc_errors/src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,11 @@ impl CodeSuggestion {
330330
});
331331
buf.push_str(&part.snippet);
332332
let cur_hi = sm.lookup_char_pos(part.span.hi());
333-
if cur_hi.line == cur_lo.line && !part.snippet.is_empty() {
334-
// Account for the difference between the width of the current code and the
335-
// snippet being suggested, so that the *later* suggestions are correctly
336-
// aligned on the screen.
337-
acc += len - (cur_hi.col.0 - cur_lo.col.0) as isize;
338-
}
333+
// Account for the difference between the width of the current code and the
334+
// snippet being suggested, so that the *later* suggestions are correctly
335+
// aligned on the screen. Note that cur_hi and cur_lo can be on different
336+
// lines, so cur_hi.col can be smaller than cur_lo.col
337+
acc += len - (cur_hi.col.0 as isize - cur_lo.col.0 as isize);
339338
prev_hi = cur_hi;
340339
prev_line = sf.get_line(prev_hi.line - 1);
341340
for line in part.snippet.split('\n').skip(1) {

Diff for: src/bootstrap/builder/tests.rs

+16
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,22 @@ fn alias_and_path_for_library() {
146146
);
147147
}
148148

149+
#[test]
150+
fn test_beta_rev_parsing() {
151+
use crate::extract_beta_rev;
152+
153+
// single digit revision
154+
assert_eq!(extract_beta_rev("1.99.9-beta.7 (xxxxxx)"), Some("7".to_string()));
155+
// multiple digits
156+
assert_eq!(extract_beta_rev("1.99.9-beta.777 (xxxxxx)"), Some("777".to_string()));
157+
// nightly channel (no beta revision)
158+
assert_eq!(extract_beta_rev("1.99.9-nightly (xxxxxx)"), None);
159+
// stable channel (no beta revision)
160+
assert_eq!(extract_beta_rev("1.99.9 (xxxxxxx)"), None);
161+
// invalid string
162+
assert_eq!(extract_beta_rev("invalid"), None);
163+
}
164+
149165
mod defaults {
150166
use super::{configure, first, run_build};
151167
use crate::builder::*;

Diff for: src/bootstrap/lib.rs

+27-6
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ impl Build {
13241324
match &self.config.channel[..] {
13251325
"stable" => num.to_string(),
13261326
"beta" => {
1327-
if self.rust_info().is_managed_git_subrepository() && !self.config.omit_git_hash {
1327+
if !self.config.omit_git_hash {
13281328
format!("{}-beta.{}", num, self.beta_prerelease_version())
13291329
} else {
13301330
format!("{}-beta", num)
@@ -1336,18 +1336,28 @@ impl Build {
13361336
}
13371337

13381338
fn beta_prerelease_version(&self) -> u32 {
1339+
fn extract_beta_rev_from_file<P: AsRef<Path>>(version_file: P) -> Option<String> {
1340+
let version = fs::read_to_string(version_file).ok()?;
1341+
1342+
extract_beta_rev(&version)
1343+
}
1344+
13391345
if let Some(s) = self.prerelease_version.get() {
13401346
return s;
13411347
}
13421348

1343-
// Figure out how many merge commits happened since we branched off master.
1344-
// That's our beta number!
1345-
// (Note that we use a `..` range, not the `...` symmetric difference.)
1346-
let count =
1349+
// First check if there is a version file available.
1350+
// If available, we read the beta revision from that file.
1351+
// This only happens when building from a source tarball when Git should not be used.
1352+
let count = extract_beta_rev_from_file(self.src.join("version")).unwrap_or_else(|| {
1353+
// Figure out how many merge commits happened since we branched off master.
1354+
// That's our beta number!
1355+
// (Note that we use a `..` range, not the `...` symmetric difference.)
13471356
output(self.config.git().arg("rev-list").arg("--count").arg("--merges").arg(format!(
13481357
"refs/remotes/origin/{}..HEAD",
13491358
self.config.stage0_metadata.config.nightly_branch
1350-
)));
1359+
)))
1360+
});
13511361
let n = count.trim().parse().unwrap();
13521362
self.prerelease_version.set(Some(n));
13531363
n
@@ -1707,6 +1717,17 @@ to download LLVM rather than building it.
17071717
}
17081718
}
17091719

1720+
/// Extract the beta revision from the full version string.
1721+
///
1722+
/// The full version string looks like "a.b.c-beta.y". And we need to extract
1723+
/// the "y" part from the string.
1724+
pub fn extract_beta_rev(version: &str) -> Option<String> {
1725+
let parts = version.splitn(2, "-beta.").collect::<Vec<_>>();
1726+
let count = parts.get(1).and_then(|s| s.find(' ').map(|p| (&s[..p]).to_string()));
1727+
1728+
count
1729+
}
1730+
17101731
#[cfg(unix)]
17111732
fn chmod(path: &Path, perms: u32) {
17121733
use std::os::unix::fs::*;

Diff for: src/bootstrap/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ impl Step for Miri {
620620
cargo.env("MIRIFLAGS", "-O -Zmir-opt-level=4 -Cdebug-assertions=yes");
621621
// Optimizations can change backtraces
622622
cargo.env("MIRI_SKIP_UI_CHECKS", "1");
623+
// `MIRI_SKIP_UI_CHECKS` and `MIRI_BLESS` are incompatible
624+
cargo.env_remove("MIRI_BLESS");
623625
// Optimizations can change error locations and remove UB so don't run `fail` tests.
624626
cargo.args(&["tests/pass", "tests/panic"]);
625627

Diff for: tests/rustdoc-gui/anchors.goml

+18-18
Original file line numberDiff line numberDiff line change
@@ -75,35 +75,35 @@ call-function: (
7575
"check-colors",
7676
{
7777
"theme": "ayu",
78-
"main_color": "rgb(197, 197, 197)",
79-
"title_color": "rgb(255, 255, 255)",
80-
"main_heading_color": "rgb(255, 255, 255)",
81-
"main_heading_type_color": "rgb(255, 160, 165)",
82-
"src_link_color": "rgb(57, 175, 215)",
83-
"sidebar_link_color": "rgb(83, 177, 219)",
78+
"main_color": "#c5c5c5",
79+
"title_color": "#fff",
80+
"main_heading_color": "#fff",
81+
"main_heading_type_color": "#ffa0a5",
82+
"src_link_color": "#39afd7",
83+
"sidebar_link_color": "#53b1db",
8484
},
8585
)
8686
call-function: (
8787
"check-colors",
8888
{
8989
"theme": "dark",
90-
"main_color": "rgb(221, 221, 221)",
91-
"title_color": "rgb(221, 221, 221)",
92-
"main_heading_color": "rgb(221, 221, 221)",
93-
"main_heading_type_color": "rgb(45, 191, 184)",
94-
"src_link_color": "rgb(210, 153, 29)",
95-
"sidebar_link_color": "rgb(253, 191, 53)",
90+
"main_color": "#ddd",
91+
"title_color": "#ddd",
92+
"main_heading_color": "#ddd",
93+
"main_heading_type_color": "#2dbfb8",
94+
"src_link_color": "#d2991d",
95+
"sidebar_link_color": "#fdbf35",
9696
},
9797
)
9898
call-function: (
9999
"check-colors",
100100
{
101101
"theme": "light",
102-
"main_color": "rgb(0, 0, 0)",
103-
"title_color": "rgb(0, 0, 0)",
104-
"main_heading_color": "rgb(0, 0, 0)",
105-
"main_heading_type_color": "rgb(173, 55, 138)",
106-
"src_link_color": "rgb(56, 115, 173)",
107-
"sidebar_link_color": "rgb(53, 109, 164)",
102+
"main_color": "black",
103+
"title_color": "black",
104+
"main_heading_color": "black",
105+
"main_heading_type_color": "#ad378a",
106+
"src_link_color": "#3873ad",
107+
"sidebar_link_color": "#356da4",
108108
},
109109
)

Diff for: tests/rustdoc-gui/codeblock-tooltip.goml

+9-9
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ define-function: (
109109

110110
call-function: ("check-colors", {
111111
"theme": "ayu",
112-
"background": "rgb(15, 20, 25)",
113-
"color": "rgb(197, 197, 197)",
114-
"border": "rgb(92, 103, 115)",
112+
"background": "#0f1419",
113+
"color": "#c5c5c5",
114+
"border": "#5c6773",
115115
})
116116
call-function: ("check-colors", {
117117
"theme": "dark",
118-
"background": "rgb(53, 53, 53)",
119-
"color": "rgb(221, 221, 221)",
120-
"border": "rgb(224, 224, 224)",
118+
"background": "#353535",
119+
"color": "#ddd",
120+
"border": "#e0e0e0",
121121
})
122122
call-function: ("check-colors", {
123123
"theme": "light",
124-
"background": "rgb(255, 255, 255)",
125-
"color": "rgb(0, 0, 0)",
126-
"border": "rgb(224, 224, 224)",
124+
"background": "white",
125+
"color": "black",
126+
"border": "#e0e0e0",
127127
})

Diff for: tests/ui/suggestions/issue-109854.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn generate_setter() {
2+
String::with_capacity(
3+
//~^ ERROR this function takes 1 argument but 3 arguments were supplied
4+
generate_setter,
5+
r#"
6+
pub(crate) struct Person<T: Clone> {}
7+
"#,
8+
r#""#,
9+
);
10+
}
11+
12+
fn main() {}

Diff for: tests/ui/suggestions/issue-109854.stderr

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0061]: this function takes 1 argument but 3 arguments were supplied
2+
--> $DIR/issue-109854.rs:2:5
3+
|
4+
LL | String::with_capacity(
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
...
7+
LL | / r#"
8+
LL | | pub(crate) struct Person<T: Clone> {}
9+
LL | | "#,
10+
| |__- unexpected argument of type `&'static str`
11+
LL | r#""#,
12+
| ----- unexpected argument of type `&'static str`
13+
|
14+
note: expected `usize`, found fn item
15+
--> $DIR/issue-109854.rs:4:5
16+
|
17+
LL | generate_setter,
18+
| ^^^^^^^^^^^^^^^
19+
= note: expected type `usize`
20+
found fn item `fn() {generate_setter}`
21+
note: associated function defined here
22+
--> $SRC_DIR/alloc/src/string.rs:LL:COL
23+
help: remove the extra arguments
24+
|
25+
LL - generate_setter,
26+
LL + /* usize */,
27+
|
28+
29+
error: aborting due to previous error
30+
31+
For more information about this error, try `rustc --explain E0061`.

Diff for: tests/ui/suggestions/issue-94171.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn L(]{match
2+
(; {`
3+
//~^^ ERROR mismatched closing delimiter
4+
//~^^ ERROR unknown start of token
5+
//~ ERROR this file contains an unclosed delimiter

Diff for: tests/ui/suggestions/issue-94171.stderr

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error: unknown start of token: `
2+
--> $DIR/issue-94171.rs:2:5
3+
|
4+
LL | (; {`
5+
| ^
6+
|
7+
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
8+
|
9+
LL | (; {'
10+
| ~
11+
12+
error: mismatched closing delimiter: `]`
13+
--> $DIR/issue-94171.rs:1:5
14+
|
15+
LL | fn L(]{match
16+
| ^^ mismatched closing delimiter
17+
| |
18+
| unclosed delimiter
19+
20+
error: this file contains an unclosed delimiter
21+
--> $DIR/issue-94171.rs:5:52
22+
|
23+
LL | fn L(]{match
24+
| -- unclosed delimiter
25+
| |
26+
| missing open `[` for this delimiter
27+
LL | (; {`
28+
| - - unclosed delimiter
29+
| |
30+
| unclosed delimiter
31+
...
32+
LL |
33+
| ^
34+
35+
error: aborting due to 3 previous errors
36+

0 commit comments

Comments
 (0)