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
This commit is contained in:
bors 2023-05-21 14:14:29 +00:00
commit 965cf5c1f5
11 changed files with 180 additions and 55 deletions

View File

@ -2303,22 +2303,25 @@ fn draw_code_line(
// Colorize addition/replacements with green.
for &SubstitutionHighlight { start, end } in highlight_parts {
// Account for tabs when highlighting (#87972).
let tabs: usize = line_to_add
.chars()
.take(start)
.map(|ch| match ch {
'\t' => 3,
_ => 0,
})
.sum();
buffer.set_style_range(
*row_num,
max_line_num_len + 3 + start + tabs,
max_line_num_len + 3 + end + tabs,
Style::Addition,
true,
);
// This is a no-op for empty ranges
if start != end {
// Account for tabs when highlighting (#87972).
let tabs: usize = line_to_add
.chars()
.take(start)
.map(|ch| match ch {
'\t' => 3,
_ => 0,
})
.sum();
buffer.set_style_range(
*row_num,
max_line_num_len + 3 + start + tabs,
max_line_num_len + 3 + end + tabs,
Style::Addition,
true,
);
}
}
*row_num += 1;
}

View File

@ -330,12 +330,11 @@ fn push_trailing(
});
buf.push_str(&part.snippet);
let cur_hi = sm.lookup_char_pos(part.span.hi());
if cur_hi.line == cur_lo.line && !part.snippet.is_empty() {
// Account for the difference between the width of the current code and the
// snippet being suggested, so that the *later* suggestions are correctly
// aligned on the screen.
acc += len - (cur_hi.col.0 - cur_lo.col.0) as isize;
}
// Account for the difference between the width of the current code and the
// snippet being suggested, so that the *later* suggestions are correctly
// aligned on the screen. Note that cur_hi and cur_lo can be on different
// lines, so cur_hi.col can be smaller than cur_lo.col
acc += len - (cur_hi.col.0 as isize - cur_lo.col.0 as isize);
prev_hi = cur_hi;
prev_line = sf.get_line(prev_hi.line - 1);
for line in part.snippet.split('\n').skip(1) {

View File

@ -146,6 +146,22 @@ fn alias_and_path_for_library() {
);
}
#[test]
fn test_beta_rev_parsing() {
use crate::extract_beta_rev;
// single digit revision
assert_eq!(extract_beta_rev("1.99.9-beta.7 (xxxxxx)"), Some("7".to_string()));
// multiple digits
assert_eq!(extract_beta_rev("1.99.9-beta.777 (xxxxxx)"), Some("777".to_string()));
// nightly channel (no beta revision)
assert_eq!(extract_beta_rev("1.99.9-nightly (xxxxxx)"), None);
// stable channel (no beta revision)
assert_eq!(extract_beta_rev("1.99.9 (xxxxxxx)"), None);
// invalid string
assert_eq!(extract_beta_rev("invalid"), None);
}
mod defaults {
use super::{configure, first, run_build};
use crate::builder::*;

View File

@ -1324,7 +1324,7 @@ fn release(&self, num: &str) -> String {
match &self.config.channel[..] {
"stable" => num.to_string(),
"beta" => {
if self.rust_info().is_managed_git_subrepository() && !self.config.omit_git_hash {
if !self.config.omit_git_hash {
format!("{}-beta.{}", num, self.beta_prerelease_version())
} else {
format!("{}-beta", num)
@ -1336,18 +1336,28 @@ fn release(&self, num: &str) -> String {
}
fn beta_prerelease_version(&self) -> u32 {
fn extract_beta_rev_from_file<P: AsRef<Path>>(version_file: P) -> Option<String> {
let version = fs::read_to_string(version_file).ok()?;
extract_beta_rev(&version)
}
if let Some(s) = self.prerelease_version.get() {
return s;
}
// Figure out how many merge commits happened since we branched off master.
// That's our beta number!
// (Note that we use a `..` range, not the `...` symmetric difference.)
let count =
// First check if there is a version file available.
// If available, we read the beta revision from that file.
// This only happens when building from a source tarball when Git should not be used.
let count = extract_beta_rev_from_file(self.src.join("version")).unwrap_or_else(|| {
// Figure out how many merge commits happened since we branched off master.
// That's our beta number!
// (Note that we use a `..` range, not the `...` symmetric difference.)
output(self.config.git().arg("rev-list").arg("--count").arg("--merges").arg(format!(
"refs/remotes/origin/{}..HEAD",
self.config.stage0_metadata.config.nightly_branch
)));
)))
});
let n = count.trim().parse().unwrap();
self.prerelease_version.set(Some(n));
n
@ -1707,6 +1717,17 @@ fn colored_stream_inner<R, F, C>(&self, constructor: C, is_tty: bool, f: F) -> R
}
}
/// Extract the beta revision from the full version string.
///
/// The full version string looks like "a.b.c-beta.y". And we need to extract
/// the "y" part from the string.
pub fn extract_beta_rev(version: &str) -> Option<String> {
let parts = version.splitn(2, "-beta.").collect::<Vec<_>>();
let count = parts.get(1).and_then(|s| s.find(' ').map(|p| (&s[..p]).to_string()));
count
}
#[cfg(unix)]
fn chmod(path: &Path, perms: u32) {
use std::os::unix::fs::*;

View File

@ -620,6 +620,8 @@ fn run(self, builder: &Builder<'_>) {
cargo.env("MIRIFLAGS", "-O -Zmir-opt-level=4 -Cdebug-assertions=yes");
// Optimizations can change backtraces
cargo.env("MIRI_SKIP_UI_CHECKS", "1");
// `MIRI_SKIP_UI_CHECKS` and `MIRI_BLESS` are incompatible
cargo.env_remove("MIRI_BLESS");
// Optimizations can change error locations and remove UB so don't run `fail` tests.
cargo.args(&["tests/pass", "tests/panic"]);

View File

@ -75,35 +75,35 @@ call-function: (
"check-colors",
{
"theme": "ayu",
"main_color": "rgb(197, 197, 197)",
"title_color": "rgb(255, 255, 255)",
"main_heading_color": "rgb(255, 255, 255)",
"main_heading_type_color": "rgb(255, 160, 165)",
"src_link_color": "rgb(57, 175, 215)",
"sidebar_link_color": "rgb(83, 177, 219)",
"main_color": "#c5c5c5",
"title_color": "#fff",
"main_heading_color": "#fff",
"main_heading_type_color": "#ffa0a5",
"src_link_color": "#39afd7",
"sidebar_link_color": "#53b1db",
},
)
call-function: (
"check-colors",
{
"theme": "dark",
"main_color": "rgb(221, 221, 221)",
"title_color": "rgb(221, 221, 221)",
"main_heading_color": "rgb(221, 221, 221)",
"main_heading_type_color": "rgb(45, 191, 184)",
"src_link_color": "rgb(210, 153, 29)",
"sidebar_link_color": "rgb(253, 191, 53)",
"main_color": "#ddd",
"title_color": "#ddd",
"main_heading_color": "#ddd",
"main_heading_type_color": "#2dbfb8",
"src_link_color": "#d2991d",
"sidebar_link_color": "#fdbf35",
},
)
call-function: (
"check-colors",
{
"theme": "light",
"main_color": "rgb(0, 0, 0)",
"title_color": "rgb(0, 0, 0)",
"main_heading_color": "rgb(0, 0, 0)",
"main_heading_type_color": "rgb(173, 55, 138)",
"src_link_color": "rgb(56, 115, 173)",
"sidebar_link_color": "rgb(53, 109, 164)",
"main_color": "black",
"title_color": "black",
"main_heading_color": "black",
"main_heading_type_color": "#ad378a",
"src_link_color": "#3873ad",
"sidebar_link_color": "#356da4",
},
)

View File

@ -109,19 +109,19 @@ define-function: (
call-function: ("check-colors", {
"theme": "ayu",
"background": "rgb(15, 20, 25)",
"color": "rgb(197, 197, 197)",
"border": "rgb(92, 103, 115)",
"background": "#0f1419",
"color": "#c5c5c5",
"border": "#5c6773",
})
call-function: ("check-colors", {
"theme": "dark",
"background": "rgb(53, 53, 53)",
"color": "rgb(221, 221, 221)",
"border": "rgb(224, 224, 224)",
"background": "#353535",
"color": "#ddd",
"border": "#e0e0e0",
})
call-function: ("check-colors", {
"theme": "light",
"background": "rgb(255, 255, 255)",
"color": "rgb(0, 0, 0)",
"border": "rgb(224, 224, 224)",
"background": "white",
"color": "black",
"border": "#e0e0e0",
})

View File

@ -0,0 +1,12 @@
fn generate_setter() {
String::with_capacity(
//~^ ERROR this function takes 1 argument but 3 arguments were supplied
generate_setter,
r#"
pub(crate) struct Person<T: Clone> {}
"#,
r#""#,
);
}
fn main() {}

View File

@ -0,0 +1,31 @@
error[E0061]: this function takes 1 argument but 3 arguments were supplied
--> $DIR/issue-109854.rs:2:5
|
LL | String::with_capacity(
| ^^^^^^^^^^^^^^^^^^^^^
...
LL | / r#"
LL | | pub(crate) struct Person<T: Clone> {}
LL | | "#,
| |__- unexpected argument of type `&'static str`
LL | r#""#,
| ----- unexpected argument of type `&'static str`
|
note: expected `usize`, found fn item
--> $DIR/issue-109854.rs:4:5
|
LL | generate_setter,
| ^^^^^^^^^^^^^^^
= note: expected type `usize`
found fn item `fn() {generate_setter}`
note: associated function defined here
--> $SRC_DIR/alloc/src/string.rs:LL:COL
help: remove the extra arguments
|
LL - generate_setter,
LL + /* usize */,
|
error: aborting due to previous error
For more information about this error, try `rustc --explain E0061`.

View File

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

View File

@ -0,0 +1,36 @@
error: unknown start of token: `
--> $DIR/issue-94171.rs:2:5
|
LL | (; {`
| ^
|
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
LL | (; {'
| ~
error: mismatched closing delimiter: `]`
--> $DIR/issue-94171.rs:1:5
|
LL | fn L(]{match
| ^^ mismatched closing delimiter
| |
| unclosed delimiter
error: this file contains an unclosed delimiter
--> $DIR/issue-94171.rs:5:52
|
LL | fn L(]{match
| -- unclosed delimiter
| |
| missing open `[` for this delimiter
LL | (; {`
| - - unclosed delimiter
| |
| unclosed delimiter
...
LL |
| ^
error: aborting due to 3 previous errors