Skip to content

Commit 1e67743

Browse files
authored
Rollup merge of rust-lang#140339 - petrochenkov:capanew, r=lqd
session: Cleanup `CanonicalizedPath::new` It wants an owned path, so pass an owned path.
2 parents 2575c7d + 86969db commit 1e67743

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

compiler/rustc_interface/src/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(rustc::bad_opt_access)]
2-
use std::collections::{BTreeMap, BTreeSet};
2+
use std::collections::BTreeMap;
33
use std::num::NonZero;
4-
use std::path::{Path, PathBuf};
4+
use std::path::PathBuf;
55
use std::sync::atomic::AtomicBool;
66

77
use rustc_abi::Align;
@@ -89,8 +89,8 @@ where
8989
S: Into<String>,
9090
I: IntoIterator<Item = S>,
9191
{
92-
let locations: BTreeSet<CanonicalizedPath> =
93-
locations.into_iter().map(|s| CanonicalizedPath::new(Path::new(&s.into()))).collect();
92+
let locations =
93+
locations.into_iter().map(|s| CanonicalizedPath::new(PathBuf::from(s.into()))).collect();
9494

9595
ExternEntry {
9696
location: ExternLocation::ExactPaths(locations),

compiler/rustc_session/src/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2323,14 +2323,13 @@ pub fn parse_externs(
23232323
let ExternOpt { crate_name: name, path, options } =
23242324
split_extern_opt(early_dcx, unstable_opts, &arg).unwrap_or_else(|e| e.emit());
23252325

2326-
let path = path.map(|p| CanonicalizedPath::new(p.as_path()));
2327-
23282326
let entry = externs.entry(name.to_owned());
23292327

23302328
use std::collections::btree_map::Entry;
23312329

23322330
let entry = if let Some(path) = path {
23332331
// --extern prelude_name=some_file.rlib
2332+
let path = CanonicalizedPath::new(path);
23342333
match entry {
23352334
Entry::Vacant(vacant) => {
23362335
let files = BTreeSet::from_iter(iter::once(path));

compiler/rustc_session/src/utils.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::path::{Path, PathBuf};
1+
use std::path::PathBuf;
22
use std::sync::OnceLock;
33

44
use rustc_data_structures::profiling::VerboseTimingGuard;
@@ -104,8 +104,8 @@ pub struct CanonicalizedPath {
104104
}
105105

106106
impl CanonicalizedPath {
107-
pub fn new(path: &Path) -> Self {
108-
Self { original: path.to_owned(), canonicalized: try_canonicalize(path).ok() }
107+
pub fn new(path: PathBuf) -> Self {
108+
Self { canonicalized: try_canonicalize(&path).ok(), original: path }
109109
}
110110

111111
pub fn canonicalized(&self) -> &PathBuf {

0 commit comments

Comments
 (0)