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#106853 - TimNN:undo-remap, r=oli-obk
Heuristically undo path prefix mappings. Because the compiler produces better diagnostics if it can find the source of (potentially remapped) dependencies. The new test fails without the other changes in this PR. Let me know if you have better suggestions for the test directory. I moved the existing remapping test to be in the same location as the new one. Some more context: I'm exploring running UI tests with remapped paths by default in rust-lang#105924 and this was one of the issues discovered. This may also be useful in the context of rust-lang/rfcs#3127 ("New rustc and Cargo options to allow path sanitisation by default").
- Loading branch information
Showing
8 changed files
with
162 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// compile-flags: --remap-path-prefix={{src-base}}/errors/auxiliary=remapped-aux | ||
|
||
pub struct SomeStruct {} // This line should be show as part of the error. |
14 changes: 14 additions & 0 deletions
14
tests/ui/errors/remap-path-prefix-reverse.local-self.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,14 @@ | ||
error[E0423]: expected value, found struct `remapped_dep::SomeStruct` | ||
--> $DIR/remap-path-prefix-reverse.rs:22:13 | ||
| | ||
LL | let _ = remapped_dep::SomeStruct; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` | ||
| | ||
::: remapped-aux/remapped_dep.rs:3:1 | ||
| | ||
LL | pub struct SomeStruct {} // This line should be show as part of the error. | ||
| --------------------- `remapped_dep::SomeStruct` defined here | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0423`. |
14 changes: 14 additions & 0 deletions
14
tests/ui/errors/remap-path-prefix-reverse.remapped-self.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,14 @@ | ||
error[E0423]: expected value, found struct `remapped_dep::SomeStruct` | ||
--> remapped/errors/remap-path-prefix-reverse.rs:22:13 | ||
| | ||
LL | let _ = remapped_dep::SomeStruct; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` | ||
| | ||
::: remapped-aux/remapped_dep.rs:3:1 | ||
| | ||
LL | pub struct SomeStruct {} // This line should be show as part of the error. | ||
| --------------------- `remapped_dep::SomeStruct` defined here | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0423`. |
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 @@ | ||
// aux-build:remapped_dep.rs | ||
// compile-flags: --remap-path-prefix={{src-base}}/errors/auxiliary=remapped-aux | ||
|
||
// The remapped paths are not normalized by compiletest. | ||
// normalize-stderr-test: "\\(errors)" -> "/$1" | ||
|
||
// revisions: local-self remapped-self | ||
// [remapped-self]compile-flags: --remap-path-prefix={{src-base}}=remapped | ||
|
||
// The paths from `remapped-self` aren't recognized by compiletest, so we | ||
// cannot use line-specific patterns for the actual error. | ||
// error-pattern: E0423 | ||
|
||
// Verify that the expected source code is shown. | ||
// error-pattern: pub struct SomeStruct {} // This line should be show | ||
|
||
extern crate remapped_dep; | ||
|
||
fn main() { | ||
// The actual error is irrelevant. The important part it that is should show | ||
// a snippet of the dependency's source. | ||
let _ = remapped_dep::SomeStruct; | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/ui/remap-path-prefix.rs → tests/ui/errors/remap-path-prefix.rs
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
2 changes: 1 addition & 1 deletion
2
tests/ui/remap-path-prefix.stderr → tests/ui/errors/remap-path-prefix.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