Skip to content

Commit 563e49d

Browse files
committed
Auto merge of rust-lang#140180 - ChrisDenton:rollup-5pvs08u, r=ChrisDenton
Rollup of 7 pull requests Successful merges: - rust-lang#140142 (Some more graphviz tweaks) - rust-lang#140146 (Update `compiler_builtins` to 0.1.156) - rust-lang#140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.) - rust-lang#140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic) - rust-lang#140163 (Validate extension in `PathBuf::add_extension`) - rust-lang#140173 (Ping Mara when touching format_args!() internals.) - rust-lang#140175 (`rc""` more clear error message) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6532696 + 0d44c14 commit 563e49d

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bench = false
1616

1717
[dependencies]
1818
core = { path = "../core", public = true }
19-
compiler_builtins = { version = "=0.1.155", features = ['rustc-dep-of-std'] }
19+
compiler_builtins = { version = "=0.1.156", features = ['rustc-dep-of-std'] }
2020

2121
[features]
2222
compiler-builtins-mem = ['compiler_builtins/mem']

std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1818
panic_unwind = { path = "../panic_unwind", optional = true }
1919
panic_abort = { path = "../panic_abort" }
2020
core = { path = "../core", public = true }
21-
compiler_builtins = { version = "=0.1.155" }
21+
compiler_builtins = { version = "=0.1.156" }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.15", default-features = false, features = [
2424
'rustc-dep-of-std',

std/src/path.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,15 @@ fn split_file_at_dot(file: &OsStr) -> (&OsStr, Option<&OsStr>) {
353353
}
354354
}
355355

356+
/// Checks whether the string is valid as a file extension, or panics otherwise.
357+
fn validate_extension(extension: &OsStr) {
358+
for &b in extension.as_encoded_bytes() {
359+
if is_sep_byte(b) {
360+
panic!("extension cannot contain path separators: {extension:?}");
361+
}
362+
}
363+
}
364+
356365
////////////////////////////////////////////////////////////////////////////////
357366
// The core iterators
358367
////////////////////////////////////////////////////////////////////////////////
@@ -1507,13 +1516,7 @@ impl PathBuf {
15071516
}
15081517

15091518
fn _set_extension(&mut self, extension: &OsStr) -> bool {
1510-
for &b in extension.as_encoded_bytes() {
1511-
if b < 128 {
1512-
if is_separator(b as char) {
1513-
panic!("extension cannot contain path separators: {:?}", extension);
1514-
}
1515-
}
1516-
}
1519+
validate_extension(extension);
15171520

15181521
let file_stem = match self.file_stem() {
15191522
None => return false,
@@ -1541,6 +1544,11 @@ impl PathBuf {
15411544
/// Returns `false` and does nothing if [`self.file_name`] is [`None`],
15421545
/// returns `true` and updates the extension otherwise.
15431546
///
1547+
/// # Panics
1548+
///
1549+
/// Panics if the passed extension contains a path separator (see
1550+
/// [`is_separator`]).
1551+
///
15441552
/// # Caveats
15451553
///
15461554
/// The appended `extension` may contain dots and will be used in its entirety,
@@ -1582,6 +1590,8 @@ impl PathBuf {
15821590
}
15831591

15841592
fn _add_extension(&mut self, extension: &OsStr) -> bool {
1593+
validate_extension(extension);
1594+
15851595
let file_name = match self.file_name() {
15861596
None => return false,
15871597
Some(f) => f.as_encoded_bytes(),

0 commit comments

Comments
 (0)