Description
alternative title: -Z simulate-remapped-rust-src-base
is not working as expected with remap-debuginfo = true
Hello! We are running the compiler test with a compiler configured with remap-debuginfo = true
and after a recent PR merge we observed that the src/test/ui
test suite is no longer passing. After looking into the issue I think a (test only?) -Z
compiler flag may not be working as intended. Details below and apologies for not using one of the issue templates!
Observations
./x.py test src/test/ui
worked fine before PR #97504 with remap-debuginfo = true
set in config.toml
$ git clone https://github.com/rust-lang/rust
$ cd rust
$ git checkout 946a88a # before PR 97504
$ git submodule update
$ cp config.toml.example config.toml
$ # enable remap-debuginfo
$ sed -i '/remap-debuginfo/c\remap-debuginfo = true' config.toml
$ ./x.py test src/test/ui && echo OK
(..)
OK
./x.py test src/test/ui
stopped working after #97504 was merged.
$ git checkout e810f75 # after PR 97504
$ git submodule update
$ cp config.toml.example config.toml
$ # enable remap-debuginfo
$ sed -i '/remap-debuginfo/c\remap-debuginfo = true' config.toml
$ ./x.py test src/test/ui
(..)
---- [ui] src/test/ui/span/issue-71363.rs stdout ----
diff of stderr:
1 error[E0277]: `MyError` doesn't implement `std::fmt::Display`
- --> $DIR/issue-71363.rs:6:6
- |
- 6 | 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
+ --> $DIR/issue-71363.rs:6:6
+ |
+ 6 | 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
9 note: required by a bound in `std::error::Error`
+ --> $SRC_DIR/std/src/error.rs:LL:COL
+ |
+ 193 | pub trait Error: Debug + Display {
+ | ^^^^^^^ required by this bound in `std::error::Error`
10
11 error[E0277]: `MyError` doesn't implement `Debug`
- --> $DIR/issue-71363.rs:6:6
- |
- 6 | 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`
+ --> $DIR/issue-71363.rs:6:6
+ |
+ 6 | 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`
19 note: required by a bound in `std::error::Error`
+ --> $SRC_DIR/std/src/error.rs:LL:COL
+ |
+ 193 | pub trait Error: Debug + Display {
+ | ^^^^^ required by this bound in `std::error::Error`
20 help: consider annotating `MyError` with `#[derive(Debug)]`
- |
- 5 | #[derive(Debug)]
- |
+ |
+ 5 | #[derive(Debug)]
+ |
24
25 error: aborting due to 2 previous errors
26
(..)
more concretely, the UI test issue-71363
added in PR #97504 fails. the error message looks like the one that was reported by CI in the original PR #89268. see rust-log-analyzer
disabling remap-debuginfo
makes test issue-71363
and the test suite pass:
$ # disable remap-debuginfo
$ sed -i '/remap-debuginfo/c\remap-debuginfo = false' config.toml
$ ./x.py test src/test/ui && echo OK
(..)
OK
Hypotheses
-Z simulate-remapped-rust-src-base
is not working as intended withremap-debuginfo = true
.
AIUI, the goal of -Z simulate-remapped-rust-src-base=/rustc/xyz
is to make it as if there was no rust-src
component installed but it's not working when the compiler is built with remap-debuginfo = true
. This can be observed in the above test failure: the location of trait Error
is reported. It can also be observed on nightly (shown below):
$ rustup default nightly-2022-06-02
$ rustup component add rust-src
$ cd src/test/ui/span # within rust-lang/rust repo
$ rustc -Z ui-testing=no -Z simulate-remapped-rust-src-base=/rustc/xyz issue-71363.rs
(..)
note: required by a bound in `std::error::Error`
--> $RUST_SRC/library/std/src/error.rs:193:18
|
193 | pub trait Error: Debug + Display {
only removing the rust-src
component makes that pub trait
note disappear.
$ rustup component remove rust-src
$ rustc -Z ui-testing=no -Z simulate-remapped-rust-src-base=/rustc/xyz issue-71363.rs 2>&1 | rg 'pub trait' || echo not found
not found
$ rustc issue-71363.rs 2>&1 | rg 'pub trait' || echo not found
not found
issue-71363
is not being exercised withremap-debuginfo = true
in CI
PR #97504 rebased PR #89268 but added // only-x86_64-unknown-linux-gnu
. with that change the issue-71363
test is run in the auto (x86_64-gnu, ubuntu-20.04-xl)
builder which is configured with the default of remap-debuginfo = false
. (see temporary logs)
I couldn't figure where in the source code remap-debuginfo
is set for CI builders but for example auto (dist-x86_64-linux, ubuntu-20.04-xl)
is configured with remap-debuginfo = true
(see temporary logs) but that builder does not run the src/test/ui
tests.
OTOH, auto (dist-i586-gnu-i586-i686-musl, ubuntu-20.04-xl)
is configured with remap-debuginfo = true
(see temporary logs) and does run the src/test/ui
tests. However, it will not run issue-71363
(see temp logs) because the test has a // only-x86_64-unknown-linux-gnu
directive. This dist-i586
builder is the one that failed in the original PR #89268 (again, see rust-log-analyzer); that original PR did not have the // only-
directive.
Conclusions
-Z simulate-remapped-rust-src-base
is not working as intended withremap-debuginfo = true
.- because of (1),
issue-71363
is a hazard because it will fail if theremap-debuginfo
configuration of the CI builders is tweaked in the future
Suggestions
I would suggest:
- remove / disable the UI test
issue-71363
- re-open issue Regression in spacing of left margin in diagnostics #71363 and label it with
needs-test
. note that the actual issue is already fixed - open an issue about fixing
-Z simulate-remapped-rust-src-base
(or re-purporse this issue for that) - re-add / re-enable test
issue-71363
once (3) is sorted out
cc @JohnTitor (author of PR #97504)