Skip to content

File tree

13 files changed

+41
-16
lines changed

13 files changed

+41
-16
lines changed
 

‎src/Cargo.lock

+6
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,7 @@ dependencies = [
18871887
"rustc_apfloat 0.0.0",
18881888
"rustc_data_structures 0.0.0",
18891889
"rustc_errors 0.0.0",
1890+
"rustc_fs_util 0.0.0",
18901891
"rustc_target 0.0.0",
18911892
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
18921893
"serialize 0.0.0",
@@ -2185,6 +2186,10 @@ dependencies = [
21852186
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
21862187
]
21872188

2189+
[[package]]
2190+
name = "rustc_fs_util"
2191+
version = "0.0.0"
2192+
21882193
[[package]]
21892194
name = "rustc_incremental"
21902195
version = "0.0.0"
@@ -2194,6 +2199,7 @@ dependencies = [
21942199
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
21952200
"rustc 0.0.0",
21962201
"rustc_data_structures 0.0.0",
2202+
"rustc_fs_util 0.0.0",
21972203
"serialize 0.0.0",
21982204
"syntax 0.0.0",
21992205
"syntax_pos 0.0.0",

‎src/librustc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ backtrace = "0.3.3"
3232
parking_lot = "0.5.5"
3333
byteorder = { version = "1.1", features = ["i128"]}
3434
chalk-engine = { version = "0.6.0", default-features=false }
35+
rustc_fs_util = { path = "../librustc_fs_util" }
3536

3637
# Note that these dependencies are a lie, they're just here to get linkage to
3738
# work.

‎src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ extern crate syntax_pos;
9999
extern crate jobserver;
100100
extern crate proc_macro;
101101
extern crate chalk_engine;
102+
extern crate rustc_fs_util;
102103

103104
extern crate serialize as rustc_serialize; // used by deriving
104105

@@ -162,7 +163,6 @@ pub mod util {
162163
pub mod common;
163164
pub mod ppaux;
164165
pub mod nodemap;
165-
pub mod fs;
166166
pub mod time_graph;
167167
pub mod profiling;
168168
}

‎src/librustc/session/filesearch.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::fs;
1919
use std::path::{Path, PathBuf};
2020

2121
use session::search_paths::{SearchPaths, PathKind};
22-
use util::fs as rustcfs;
22+
use rustc_fs_util::fix_windows_verbatim_for_gcc;
2323

2424
#[derive(Copy, Clone)]
2525
pub enum FileMatch {
@@ -151,7 +151,7 @@ pub fn get_or_default_sysroot() -> PathBuf {
151151
// See comments on this target function, but the gist is that
152152
// gcc chokes on verbatim paths which fs::canonicalize generates
153153
// so we try to avoid those kinds of paths.
154-
Ok(canon) => Some(rustcfs::fix_windows_verbatim_for_gcc(&canon)),
154+
Ok(canon) => Some(fix_windows_verbatim_for_gcc(&canon)),
155155
Err(e) => bug!("failed to get realpath: {}", e),
156156
}
157157
})

‎src/librustc_codegen_llvm/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc::middle::cstore::{NativeLibrary, LibSource, NativeLibraryKind};
2626
use rustc::middle::dependency_format::Linkage;
2727
use {CodegenResults, CrateInfo};
2828
use rustc::util::common::time;
29-
use rustc::util::fs::fix_windows_verbatim_for_gcc;
29+
use rustc_fs_util::fix_windows_verbatim_for_gcc;
3030
use rustc::hir::def_id::CrateNum;
3131
use tempfile::{Builder as TempFileBuilder, TempDir};
3232
use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor};

‎src/librustc_codegen_llvm/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc::hir::def_id::{CrateNum, LOCAL_CRATE};
3131
use rustc::ty::TyCtxt;
3232
use rustc::util::common::{time_ext, time_depth, set_time_depth, print_time_passes_entry};
3333
use rustc::util::common::path2cstr;
34-
use rustc::util::fs::{link_or_copy};
34+
use rustc_fs_util::link_or_copy;
3535
use errors::{self, Handler, Level, DiagnosticBuilder, FatalError, DiagnosticId};
3636
use errors::emitter::{Emitter};
3737
use syntax::attr;

‎src/librustc_codegen_llvm/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extern crate rustc_incremental;
5555
extern crate rustc_llvm;
5656
extern crate rustc_platform_intrinsics as intrinsics;
5757
extern crate rustc_codegen_utils;
58+
extern crate rustc_fs_util;
5859

5960
#[macro_use] extern crate log;
6061
#[macro_use] extern crate syntax;

‎src/librustc_fs_util/Cargo.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
authors = ["The Rust Project Developers"]
3+
name = "rustc_fs_util"
4+
version = "0.0.0"
5+
6+
[lib]
7+
name = "rustc_fs_util"
8+
path = "lib.rs"
9+
crate-type = ["dylib"]
10+
11+
[dependencies]

‎src/librustc/util/fs.rs ‎src/librustc_fs_util/lib.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::path::{self, Path, PathBuf};
12-
use std::ffi::OsString;
11+
use std::path::{Path, PathBuf};
1312
use std::fs;
1413
use std::io;
1514

@@ -29,10 +28,10 @@ use std::io;
2928
//
3029
// For some more information, see this comment:
3130
// https://github.com/rust-lang/rust/issues/25505#issuecomment-102876737
31+
#[cfg(windows)]
3232
pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
33-
if !cfg!(windows) {
34-
return p.to_path_buf();
35-
}
33+
use std::path;
34+
use std::ffi::OsString;
3635
let mut components = p.components();
3736
let prefix = match components.next() {
3837
Some(path::Component::Prefix(p)) => p,
@@ -56,6 +55,11 @@ pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
5655
}
5756
}
5857

58+
#[cfg(not(windows))]
59+
pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
60+
p.to_path_buf()
61+
}
62+
5963
pub enum LinkOrCopy {
6064
Link,
6165
Copy,

‎src/librustc_incremental/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ rustc_data_structures = { path = "../librustc_data_structures" }
1717
serialize = { path = "../libserialize" }
1818
syntax = { path = "../libsyntax" }
1919
syntax_pos = { path = "../libsyntax_pos" }
20+
rustc_fs_util = { path = "../librustc_fs_util" }

‎src/librustc_incremental/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern crate graphviz;
2323
extern crate rustc_data_structures;
2424
extern crate serialize as rustc_serialize;
2525
extern crate rand;
26+
extern crate rustc_fs_util;
2627

2728
#[macro_use] extern crate log;
2829
extern crate syntax;

‎src/librustc_incremental/persist/fs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
//! implemented.
116116
117117
use rustc::session::{Session, CrateDisambiguator};
118-
use rustc::util::fs as fs_util;
118+
use rustc_fs_util::{link_or_copy, LinkOrCopy};
119119
use rustc_data_structures::{flock, base_n};
120120
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
121121
use rustc_data_structures::svh::Svh;
@@ -429,11 +429,11 @@ fn copy_files(sess: &Session,
429429
let source_path = entry.path();
430430

431431
debug!("copying into session dir: {}", source_path.display());
432-
match fs_util::link_or_copy(source_path, target_file_path) {
433-
Ok(fs_util::LinkOrCopy::Link) => {
432+
match link_or_copy(source_path, target_file_path) {
433+
Ok(LinkOrCopy::Link) => {
434434
files_linked += 1
435435
}
436-
Ok(fs_util::LinkOrCopy::Copy) => {
436+
Ok(LinkOrCopy::Copy) => {
437437
files_copied += 1
438438
}
439439
Err(_) => return Err(())

‎src/librustc_incremental/persist/work_product.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use persist::fs::*;
1414
use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind};
1515
use rustc::session::Session;
16-
use rustc::util::fs::link_or_copy;
16+
use rustc_fs_util::link_or_copy;
1717
use std::path::PathBuf;
1818
use std::fs as std_fs;
1919

0 commit comments

Comments
 (0)
Please sign in to comment.