-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement RFC3137 trim-paths sysroot changes - take 2 #129687
Changes from 2 commits
8075ddb
61ef983
37ea27c
3a6c6ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1115,6 +1115,7 @@ fn expand_variables(mut value: String, config: &Config) -> String { | |
const CWD: &str = "{{cwd}}"; | ||
const SRC_BASE: &str = "{{src-base}}"; | ||
const BUILD_BASE: &str = "{{build-base}}"; | ||
const RUST_SRC_BASE: &str = "{{rust-src-base}}"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: we definitely want to update rustc-dev-guide's compiletest directive remarks to mention There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const SYSROOT_BASE: &str = "{{sysroot-base}}"; | ||
const TARGET_LINKER: &str = "{{target-linker}}"; | ||
const TARGET: &str = "{{target}}"; | ||
|
@@ -1144,6 +1145,13 @@ fn expand_variables(mut value: String, config: &Config) -> String { | |
value = value.replace(TARGET, &config.target); | ||
} | ||
|
||
if value.contains(RUST_SRC_BASE) { | ||
let src_base = config.sysroot_base.join("lib/rustlib/src/rust"); | ||
src_base.try_exists().expect(&*format!("{} should exists", src_base.display())); | ||
let src_base = src_base.read_link().unwrap_or(src_base); | ||
value = value.replace(RUST_SRC_BASE, &src_base.to_string_lossy()); | ||
} | ||
|
||
value | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//@ revisions: with-remap without-remap | ||
//@ compile-flags: -g -Ztranslate-remapped-path-to-local-path=yes | ||
//@ [with-remap]compile-flags: --remap-path-prefix={{rust-src-base}}=remapped | ||
//@ [without-remap]compile-flags: | ||
//@ error-pattern: E0507 | ||
|
||
// The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically | ||
// as the remapped revision will not begin with $SRC_DIR_REAL, | ||
// so we have to do it ourselves. | ||
//@ normalize-stderr-test: ".rs:\d+:\d+" -> ".rs:LL:COL" | ||
|
||
use std::thread; | ||
struct Worker { | ||
thread: thread::JoinHandle<()>, | ||
} | ||
|
||
impl Drop for Worker { | ||
fn drop(&mut self) { | ||
self.thread.join().unwrap(); | ||
} | ||
} | ||
|
||
pub fn main(){} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0507]: cannot move out of `self.thread` which is behind a mutable reference | ||
--> remapped/tests/ui/errors/remap-path-prefix-sysroot.rs:LL:COL | ||
| | ||
LL | self.thread.join().unwrap(); | ||
| ^^^^^^^^^^^ ------ `self.thread` moved due to this method call | ||
| | | ||
| move occurs because `self.thread` has type `JoinHandle<()>`, which does not implement the `Copy` trait | ||
| | ||
note: `JoinHandle::<T>::join` takes ownership of the receiver `self`, which moves `self.thread` | ||
--> remapped/library/std/src/thread/mod.rs:LL:COL | ||
| | ||
LL | pub fn join(self) -> Result<T> { | ||
| ^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0507`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0507]: cannot move out of `self.thread` which is behind a mutable reference | ||
--> $DIR/remap-path-prefix-sysroot.rs:LL:COL | ||
| | ||
LL | self.thread.join().unwrap(); | ||
| ^^^^^^^^^^^ ------ `self.thread` moved due to this method call | ||
| | | ||
| move occurs because `self.thread` has type `JoinHandle<()>`, which does not implement the `Copy` trait | ||
| | ||
note: `JoinHandle::<T>::join` takes ownership of the receiver `self`, which moves `self.thread` | ||
--> $SRC_DIR_REAL/std/src/thread/mod.rs:LL:COL | ||
| | ||
LL | pub fn join(self) -> Result<T> { | ||
| ^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0507`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: I think this is fine, though it might be interesting if stdlib ever adds/removes/renames specific crates. I also can't immediately think of a good way to add a test to make sure this list is always in sync.