Skip to content

Commit f17cb6a

Browse files
committed
use unstable gate and unify with_extra_extension impls
Signed-off-by: tison <[email protected]>
1 parent e0da99f commit f17cb6a

File tree

4 files changed

+4
-24
lines changed

4 files changed

+4
-24
lines changed

library/std/src/path.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ impl PathBuf {
15601560
/// p.add_extension("");
15611561
/// assert_eq!(Path::new("/feel/the.formatted.dark"), p.as_path());
15621562
/// ```
1563-
#[stable(feature = "rust1", since = "1.0.0")]
1563+
#[unstable(feature = "path_add_extension", issue = "127292")]
15641564
pub fn add_extension<S: AsRef<OsStr>>(&mut self, extension: S) -> bool {
15651565
self._add_extension(extension.as_ref())
15661566
}
@@ -2743,7 +2743,7 @@ impl Path {
27432743
/// assert_eq!(path.with_extra_extension("xz"), PathBuf::from("foo.tar.gz.xz"));
27442744
/// assert_eq!(path.with_extra_extension("").with_extra_extension("txt"), PathBuf::from("foo.tar.gz.txt"));
27452745
/// ```
2746-
#[stable(feature = "rust1", since = "1.0.0")]
2746+
#[unstable(feature = "path_add_extension", issue = "127292")]
27472747
pub fn with_extra_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
27482748
let mut new_path = self.to_path_buf();
27492749
new_path.add_extension(extension);

src/tools/compiletest/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::process::Command;
88
use std::str::FromStr;
99
use std::sync::OnceLock;
1010

11-
use crate::util::{add_dylib_path, PathBufExt};
11+
use crate::util::add_dylib_path;
1212
use build_helper::git::GitConfig;
1313
use serde::de::{Deserialize, Deserializer, Error as _};
1414
use std::collections::{HashMap, HashSet};

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::errors::{self, Error, ErrorKind};
1515
use crate::header::TestProps;
1616
use crate::json;
1717
use crate::read2::{read2_abbreviated, Truncated};
18-
use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, static_regex, PathBufExt};
18+
use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, static_regex};
1919
use crate::ColorConfig;
2020
use colored::Colorize;
2121
use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile};

src/tools/compiletest/src/util.rs

-20
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,6 @@ pub fn logv(config: &Config, s: String) {
3333
}
3434
}
3535

36-
pub trait PathBufExt {
37-
/// Append an extension to the path, even if it already has one.
38-
fn with_extra_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf;
39-
}
40-
41-
impl PathBufExt for PathBuf {
42-
fn with_extra_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
43-
if extension.as_ref().is_empty() {
44-
self.clone()
45-
} else {
46-
let mut fname = self.file_name().unwrap().to_os_string();
47-
if !extension.as_ref().to_str().unwrap().starts_with('.') {
48-
fname.push(".");
49-
}
50-
fname.push(extension);
51-
self.with_file_name(fname)
52-
}
53-
}
54-
}
55-
5636
/// The name of the environment variable that holds dynamic library locations.
5737
pub fn dylib_env_var() -> &'static str {
5838
if cfg!(windows) {

0 commit comments

Comments
 (0)