Auto merge of #94845 - Dylan-DPC:rollup-3phylaq, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #93283 (Fix for localized windows editions in testcase fn read_link() Issue#93211) - #94592 (Fallback to top-level config.toml if not present in current directory, and remove fallback for env vars and CLI flags) - #94776 (Optimize ascii::escape_default) - #94840 (update `replace_bound_vars_with_placeholders` doc comment) - #94842 (Remove unnecessary try_opt for operations that cannot fail) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
af8604fadd
@ -58,14 +58,11 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
/// Replaces all regions (resp. types) bound by `binder` with placeholder
|
/// Replaces all bound variables (lifetimes, types, and constants) bound by
|
||||||
/// regions (resp. types) and return a map indicating which bound-region
|
/// `binder` with placeholder variables.
|
||||||
/// placeholder region. This is the first step of checking subtyping
|
|
||||||
/// when higher-ranked things are involved.
|
|
||||||
///
|
///
|
||||||
/// **Important:** You have to be careful to not leak these placeholders,
|
/// This is the first step of checking subtyping when higher-ranked things are involved.
|
||||||
/// for more information about how placeholders and HRTBs work, see
|
/// For more details visit the relevant sections of the [rustc dev guide].
|
||||||
/// the [rustc dev guide].
|
|
||||||
///
|
///
|
||||||
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
|
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
|
||||||
pub fn replace_bound_vars_with_placeholders<T>(&self, binder: ty::Binder<'tcx, T>) -> T
|
pub fn replace_bound_vars_with_placeholders<T>(&self, binder: ty::Binder<'tcx, T>) -> T
|
||||||
|
@ -98,22 +98,20 @@ pub fn escape_default(c: u8) -> EscapeDefault {
|
|||||||
b'\'' => ([b'\\', b'\'', 0, 0], 2),
|
b'\'' => ([b'\\', b'\'', 0, 0], 2),
|
||||||
b'"' => ([b'\\', b'"', 0, 0], 2),
|
b'"' => ([b'\\', b'"', 0, 0], 2),
|
||||||
b'\x20'..=b'\x7e' => ([c, 0, 0, 0], 1),
|
b'\x20'..=b'\x7e' => ([c, 0, 0, 0], 1),
|
||||||
_ => ([b'\\', b'x', hexify(c >> 4), hexify(c & 0xf)], 4),
|
_ => {
|
||||||
|
let hex_digits: &[u8; 16] = b"0123456789abcdef";
|
||||||
|
([b'\\', b'x', hex_digits[(c >> 4) as usize], hex_digits[(c & 0xf) as usize]], 4)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return EscapeDefault { range: 0..len, data };
|
return EscapeDefault { range: 0..len, data };
|
||||||
|
|
||||||
fn hexify(b: u8) -> u8 {
|
|
||||||
match b {
|
|
||||||
0..=9 => b'0' + b,
|
|
||||||
_ => b'a' + b - 10,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl Iterator for EscapeDefault {
|
impl Iterator for EscapeDefault {
|
||||||
type Item = u8;
|
type Item = u8;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn next(&mut self) -> Option<u8> {
|
fn next(&mut self) -> Option<u8> {
|
||||||
self.range.next().map(|i| self.data[i as usize])
|
self.range.next().map(|i| self.data[i as usize])
|
||||||
}
|
}
|
||||||
|
@ -2166,7 +2166,8 @@ macro_rules! int_impl {
|
|||||||
|
|
||||||
let r = try_opt!(self.checked_rem(rhs));
|
let r = try_opt!(self.checked_rem(rhs));
|
||||||
let m = if (r > 0 && rhs < 0) || (r < 0 && rhs > 0) {
|
let m = if (r > 0 && rhs < 0) || (r < 0 && rhs > 0) {
|
||||||
try_opt!(r.checked_add(rhs))
|
// r + rhs cannot overflow because they have opposite signs
|
||||||
|
r + rhs
|
||||||
} else {
|
} else {
|
||||||
r
|
r
|
||||||
};
|
};
|
||||||
@ -2174,7 +2175,8 @@ macro_rules! int_impl {
|
|||||||
if m == 0 {
|
if m == 0 {
|
||||||
Some(self)
|
Some(self)
|
||||||
} else {
|
} else {
|
||||||
self.checked_add(try_opt!(rhs.checked_sub(m)))
|
// rhs - m cannot overflow because m has the same sign as rhs
|
||||||
|
self.checked_add(rhs - m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2119,7 +2119,8 @@ macro_rules! uint_impl {
|
|||||||
pub const fn checked_next_multiple_of(self, rhs: Self) -> Option<Self> {
|
pub const fn checked_next_multiple_of(self, rhs: Self) -> Option<Self> {
|
||||||
match try_opt!(self.checked_rem(rhs)) {
|
match try_opt!(self.checked_rem(rhs)) {
|
||||||
0 => Some(self),
|
0 => Some(self),
|
||||||
r => self.checked_add(try_opt!(rhs.checked_sub(r)))
|
// rhs - r cannot overflow because r is smaller than rhs
|
||||||
|
r => self.checked_add(rhs - r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::io::prelude::*;
|
use crate::io::prelude::*;
|
||||||
|
|
||||||
|
use crate::env;
|
||||||
use crate::fs::{self, File, OpenOptions};
|
use crate::fs::{self, File, OpenOptions};
|
||||||
use crate::io::{ErrorKind, SeekFrom};
|
use crate::io::{ErrorKind, SeekFrom};
|
||||||
use crate::path::Path;
|
use crate::path::Path;
|
||||||
@ -906,7 +907,14 @@ fn read_link() {
|
|||||||
// junction
|
// junction
|
||||||
assert_eq!(check!(fs::read_link(r"C:\Users\Default User")), Path::new(r"C:\Users\Default"));
|
assert_eq!(check!(fs::read_link(r"C:\Users\Default User")), Path::new(r"C:\Users\Default"));
|
||||||
// junction with special permissions
|
// junction with special permissions
|
||||||
assert_eq!(check!(fs::read_link(r"C:\Documents and Settings\")), Path::new(r"C:\Users"));
|
// Since not all localized windows versions contain the folder "Documents and Settings" in english,
|
||||||
|
// we will briefly check, if it exists and otherwise skip the test. Except during CI we will always execute the test.
|
||||||
|
if Path::new(r"C:\Documents and Settings\").exists() || env::var_os("CI").is_some() {
|
||||||
|
assert_eq!(
|
||||||
|
check!(fs::read_link(r"C:\Documents and Settings\")),
|
||||||
|
Path::new(r"C:\Users")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let tmpdir = tmpdir();
|
let tmpdir = tmpdir();
|
||||||
let link = tmpdir.join("link");
|
let link = tmpdir.join("link");
|
||||||
|
@ -1233,16 +1233,18 @@ def bootstrap(help_triggered):
|
|||||||
build.verbose = args.verbose
|
build.verbose = args.verbose
|
||||||
build.clean = args.clean
|
build.clean = args.clean
|
||||||
|
|
||||||
# Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then fallback to `config.toml` (if it
|
# Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./config.toml`,
|
||||||
# exists).
|
# then `config.toml` in the root directory.
|
||||||
toml_path = args.config or os.getenv('RUST_BOOTSTRAP_CONFIG')
|
toml_path = args.config or os.getenv('RUST_BOOTSTRAP_CONFIG')
|
||||||
if not toml_path and os.path.exists('config.toml'):
|
using_default_path = toml_path is None
|
||||||
|
if using_default_path:
|
||||||
toml_path = 'config.toml'
|
toml_path = 'config.toml'
|
||||||
|
|
||||||
if toml_path:
|
|
||||||
if not os.path.exists(toml_path):
|
if not os.path.exists(toml_path):
|
||||||
toml_path = os.path.join(build.rust_root, toml_path)
|
toml_path = os.path.join(build.rust_root, toml_path)
|
||||||
|
|
||||||
|
# Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path,
|
||||||
|
# but not if `config.toml` hasn't been created.
|
||||||
|
if not using_default_path or os.path.exists(toml_path):
|
||||||
with open(toml_path) as config:
|
with open(toml_path) as config:
|
||||||
build.config_toml = config.read()
|
build.config_toml = config.read()
|
||||||
|
|
||||||
|
@ -647,7 +647,8 @@ impl Config {
|
|||||||
let get_toml = |file: &Path| {
|
let get_toml = |file: &Path| {
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
let contents = t!(fs::read_to_string(file), "`include` config not found");
|
let contents =
|
||||||
|
t!(fs::read_to_string(file), format!("config file {} not found", file.display()));
|
||||||
match toml::from_str(&contents) {
|
match toml::from_str(&contents) {
|
||||||
Ok(table) => table,
|
Ok(table) => table,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@ -657,14 +658,24 @@ impl Config {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// check --config first, then `$RUST_BOOTSTRAP_CONFIG` first, then `config.toml`
|
// Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./config.toml`, then `config.toml` in the root directory.
|
||||||
let toml_path = flags
|
let toml_path = flags
|
||||||
.config
|
.config
|
||||||
.clone()
|
.clone()
|
||||||
.or_else(|| env::var_os("RUST_BOOTSTRAP_CONFIG").map(PathBuf::from))
|
.or_else(|| env::var_os("RUST_BOOTSTRAP_CONFIG").map(PathBuf::from));
|
||||||
.unwrap_or_else(|| PathBuf::from("config.toml"));
|
let using_default_path = toml_path.is_none();
|
||||||
let mut toml =
|
let mut toml_path = toml_path.unwrap_or_else(|| PathBuf::from("config.toml"));
|
||||||
if toml_path.exists() { get_toml(&toml_path) } else { TomlConfig::default() };
|
if using_default_path && !toml_path.exists() {
|
||||||
|
toml_path = config.src.join(toml_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path,
|
||||||
|
// but not if `config.toml` hasn't been created.
|
||||||
|
let mut toml = if !using_default_path || toml_path.exists() {
|
||||||
|
get_toml(&toml_path)
|
||||||
|
} else {
|
||||||
|
TomlConfig::default()
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(include) = &toml.profile {
|
if let Some(include) = &toml.profile {
|
||||||
let mut include_path = config.src.clone();
|
let mut include_path = config.src.clone();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user