Skip to content
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

Fix #71363's test by adding -Z translate-remapped-path-to-local-path=no #97789

Merged
merged 1 commit into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(thinlto, Some(true));
tracked!(thir_unsafeck, true);
tracked!(tls_model, Some(TlsModel::GeneralDynamic));
tracked!(translate_remapped_path_to_local_path, false);
tracked!(trap_unreachable, Some(false));
tracked!(treat_err_as_bug, NonZeroUsize::new(1));
tracked!(tune_cpu, Some(String::from("abc")));
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
.filter(|_| {
// Only spend time on further checks if we have what to translate *to*.
sess.opts.real_rust_source_base_dir.is_some()
// Some tests need the translation to be always skipped.
&& sess.opts.debugging_opts.translate_remapped_path_to_local_path
})
.filter(|virtual_dir| {
// Don't translate away `/rustc/$hash` if we're still remapping to it,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,8 @@ options! {
"choose the TLS model to use (`rustc --print tls-models` for details)"),
trace_macros: bool = (false, parse_bool, [UNTRACKED],
"for every macro invocation, print its name and arguments (default: no)"),
translate_remapped_path_to_local_path: bool = (true, parse_bool, [TRACKED],
"translate remapped paths into local paths when possible (default: yes)"),
trap_unreachable: Option<bool> = (None, parse_opt_bool, [TRACKED],
"generate trap instructions for unreachable intrinsics (default: use target setting, usually yes)"),
treat_err_as_bug: Option<NonZeroUsize> = (None, parse_treat_err_as_bug, [TRACKED],
Expand Down
15 changes: 12 additions & 3 deletions src/test/ui/span/issue-71363.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
// compile-flags: -Z simulate-remapped-rust-src-base=/rustc/xyz -Z ui-testing=no
// only-x86_64-unknown-linux-gnu
//---^ Limiting target as the above unstable flags don't play well on some environment.
// compile-flags: -Z simulate-remapped-rust-src-base=/rustc/xyz -Z translate-remapped-path-to-local-path=no -Z ui-testing=no

struct MyError;
impl std::error::Error for MyError {}
//~^ ERROR: `MyError` doesn't implement `std::fmt::Display`
//~| ERROR: `MyError` doesn't implement `Debug`

fn main() {}

// This test relies on library/std/src/error.rs *not* being included in the error message, so that
// we can test whether a file not included in the error message affects it (more specifically
// whether the line number of the excluded file affects the indentation of the other line numbers).
//
// To test this we're simulating a remap of the rust src base (so that library/std/src/error.rs
// does not point to a local file) *and* we're disabling the code to try mapping a remapped path to
// a local file (which would defeat the purpose of the former flag).
//
// Note that this comment is at the bottom of the file intentionally, as we need the line number of
// the impl to be lower than 10.
10 changes: 5 additions & 5 deletions src/test/ui/span/issue-71363.stderr
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
error[E0277]: `MyError` doesn't implement `std::fmt::Display`
--> $DIR/issue-71363.rs:6:6
--> $DIR/issue-71363.rs:4:6
|
6 | impl std::error::Error for MyError {}
4 | impl std::error::Error for MyError {}
| ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `MyError`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
note: required by a bound in `std::error::Error`

error[E0277]: `MyError` doesn't implement `Debug`
--> $DIR/issue-71363.rs:6:6
--> $DIR/issue-71363.rs:4:6
|
6 | impl std::error::Error for MyError {}
4 | impl std::error::Error for MyError {}
| ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted using `{:?}`
|
= help: the trait `Debug` is not implemented for `MyError`
= note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError`
note: required by a bound in `std::error::Error`
help: consider annotating `MyError` with `#[derive(Debug)]`
|
5 | #[derive(Debug)]
3 | #[derive(Debug)]
|

error: aborting due to 2 previous errors
Expand Down