Skip to content

Commit cae9c50

Browse files
authored
Rollup merge of #74464 - FedericoPonzi:fix-#67108, r=Manishearth
Use pathdiff crate I wanted to tackle a simple issue, and stumbled upon #67108: this pr removes the function which was exported to the external crate as required in the todo/issue. I've tested it with: ``` ./x.py build --stage 1 --keep-stage 1 src/librustc_codegen_ssa ``` And it looks like it's compiling
2 parents 5f76240 + c41db4c commit cae9c50

File tree

4 files changed

+11
-31
lines changed

4 files changed

+11
-31
lines changed

Cargo.lock

+7
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,12 @@ dependencies = [
21422142
"winapi 0.3.8",
21432143
]
21442144

2145+
[[package]]
2146+
name = "pathdiff"
2147+
version = "0.2.0"
2148+
source = "registry+https://github.com/rust-lang/crates.io-index"
2149+
checksum = "877630b3de15c0b64cc52f659345724fbf6bdad9bd9566699fc53688f3c34a34"
2150+
21452151
[[package]]
21462152
name = "percent-encoding"
21472153
version = "1.0.1"
@@ -3318,6 +3324,7 @@ dependencies = [
33183324
"log",
33193325
"memmap",
33203326
"num_cpus",
3327+
"pathdiff",
33213328
"rustc_apfloat",
33223329
"rustc_ast",
33233330
"rustc_attr",

src/librustc_codegen_ssa/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ log = "0.4.5"
1818
libc = "0.2.50"
1919
jobserver = "0.1.11"
2020
tempfile = "3.1"
21+
pathdiff = "0.2.0"
2122

2223
rustc_serialize = { path = "../librustc_serialize" }
2324
rustc_ast = { path = "../librustc_ast" }

src/librustc_codegen_ssa/back/rpath.rs

+2-31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use pathdiff::diff_paths;
12
use rustc_data_structures::fx::FxHashSet;
23
use std::env;
34
use std::fs;
@@ -109,37 +110,7 @@ fn get_rpath_relative_to_output(config: &mut RPathConfig<'_>, lib: &Path) -> Str
109110
// In particular, this handles the case on unix where both paths are
110111
// absolute but with only the root as the common directory.
111112
fn path_relative_from(path: &Path, base: &Path) -> Option<PathBuf> {
112-
use std::path::Component;
113-
114-
if path.is_absolute() != base.is_absolute() {
115-
path.is_absolute().then(|| PathBuf::from(path))
116-
} else {
117-
let mut ita = path.components();
118-
let mut itb = base.components();
119-
let mut comps: Vec<Component<'_>> = vec![];
120-
loop {
121-
match (ita.next(), itb.next()) {
122-
(None, None) => break,
123-
(Some(a), None) => {
124-
comps.push(a);
125-
comps.extend(ita.by_ref());
126-
break;
127-
}
128-
(None, _) => comps.push(Component::ParentDir),
129-
(Some(a), Some(b)) if comps.is_empty() && a == b => (),
130-
(Some(a), Some(b)) if b == Component::CurDir => comps.push(a),
131-
(Some(_), Some(b)) if b == Component::ParentDir => return None,
132-
(Some(a), Some(_)) => {
133-
comps.push(Component::ParentDir);
134-
comps.extend(itb.map(|_| Component::ParentDir));
135-
comps.push(a);
136-
comps.extend(ita.by_ref());
137-
break;
138-
}
139-
}
140-
}
141-
Some(comps.iter().map(|c| c.as_os_str()).collect())
142-
}
113+
diff_paths(path, base)
143114
}
144115

145116
fn get_install_prefix_rpath(config: &mut RPathConfig<'_>) -> String {

src/tools/tidy/src/deps.rs

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
123123
"opaque-debug",
124124
"parking_lot",
125125
"parking_lot_core",
126+
"pathdiff",
126127
"pkg-config",
127128
"polonius-engine",
128129
"ppv-lite86",

0 commit comments

Comments
 (0)