forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#118149 - cbeuw:rfc3127-sysroot, r=b-naber
Implement RFC 3127 sysroot path handling changes Fix rust-lang#105907 Fix rust-lang#85463 Implement parts of rust-lang#111540 Right now, backtraces into sysroot always shows /rustc/$hash in diagnostics, e.g. ``` thread 'main' panicked at 'hello world', map-panic.rs:2:50 stack backtrace: 0: std::panicking::begin_panic at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:616:12 1: map_panic::main::{{closure}} at ./map-panic.rs:2:50 2: core::option::Option<T>::map at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/option.rs:929:29 3: map_panic::main at ./map-panic.rs:2:30 4: core::ops::function::FnOnce::call_once at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:248:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. ``` [RFC 3127 said](https://rust-lang.github.io/rfcs/3127-trim-paths.html#changing-handling-of-sysroot-path-in-rustc) > We want to change this behaviour such that, when rust-src source files can be discovered, the virtual path is discarded and therefore the local path will be embedded, unless there is a --remap-path-prefix that causes this local path to be remapped in the usual way. This PR implements this behaviour. When `rust-src` is present at compile time, rustc replaces /rustc/$hash with a real path into local rust-src with best effort. To sanitise this, users must explicitly supply `--remap-path-prefix=<path to rust-src>=foo`.
- Loading branch information
Showing
6 changed files
with
132 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(){} |
17 changes: 17 additions & 0 deletions
17
tests/ui/errors/remap-path-prefix-sysroot.with-remap.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
17 changes: 17 additions & 0 deletions
17
tests/ui/errors/remap-path-prefix-sysroot.without-remap.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |