Skip to content

Rollup of 5 pull requests #111812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed
35 changes: 19 additions & 16 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2303,22 +2303,25 @@ impl EmitterWriter {

// 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;
}
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,11 @@ impl CodeSuggestion {
});
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) {
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ version = "0.1.0"

[[package]]
name = "cc"
version = "1.0.73"
version = "1.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"

[[package]]
name = "cfg-if"
Expand Down
16 changes: 16 additions & 0 deletions src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
33 changes: 27 additions & 6 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ impl Build {
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)
Expand All @@ -1336,18 +1336,28 @@ impl Build {
}

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
Expand Down Expand Up @@ -1707,6 +1717,17 @@ to download LLVM rather than building it.
}
}

/// 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::*;
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ impl Step for Miri {
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"]);

Expand Down
18 changes: 9 additions & 9 deletions tests/rustdoc-gui/codeblock-tooltip.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
12 changes: 12 additions & 0 deletions tests/ui/suggestions/issue-109854.rs
Original file line number Diff line number Diff line change
@@ -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() {}
31 changes: 31 additions & 0 deletions tests/ui/suggestions/issue-109854.stderr
Original file line number Diff line number Diff line change
@@ -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`.
5 changes: 5 additions & 0 deletions tests/ui/suggestions/issue-94171.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn L(]{match
(; {`
//~^^ ERROR mismatched closing delimiter
//~^^ ERROR unknown start of token
//~ ERROR this file contains an unclosed delimiter
36 changes: 36 additions & 0 deletions tests/ui/suggestions/issue-94171.stderr
Original file line number Diff line number Diff line change
@@ -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