Rollup merge of #134420 - Integral-Tech:pathbuf-refactor, r=compiler-errors

refactor: replace &PathBuf with &Path to enhance generality

- According to [style.md](https://github.com/rust-lang/rust/blob/master/src/tools/rust-analyzer/docs/dev/style.md#useless-types):

> More generally, always prefer types on the left
```rust
// GOOD      BAD
&[T]         &Vec<T>
&str         &String
Option<&T>   &Option<T>
&Path        &PathBuf
```
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-12-18 22:56:56 +08:00 committed by GitHub
commit 099faa8beb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 15 additions and 18 deletions

View file

@ -209,7 +209,7 @@ pub fn setup(config: &Config, profile: Profile) {
setup_config_toml(path, profile, config);
}
fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) {
fn setup_config_toml(path: &Path, profile: Profile, config: &Config) {
if profile == Profile::None {
return;
}

View file

@ -1942,7 +1942,7 @@ impl Config {
);
let channel = config
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
.read_file_by_commit(Path::new("src/ci/channel"), commit)
.trim()
.to_owned();
@ -2383,12 +2383,10 @@ impl Config {
/// Return the version it would have used for the given commit.
pub(crate) fn artifact_version_part(&self, commit: &str) -> String {
let (channel, version) = if self.rust_info.is_managed_git_subrepository() {
let channel = self
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
.trim()
.to_owned();
let channel =
self.read_file_by_commit(Path::new("src/ci/channel"), commit).trim().to_owned();
let version =
self.read_file_by_commit(&PathBuf::from("src/version"), commit).trim().to_owned();
self.read_file_by_commit(Path::new("src/version"), commit).trim().to_owned();
(channel, version)
} else {
let channel = fs::read_to_string(self.src.join("src/ci/channel"));