-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Include rmeta candidates in "multiple matching crates" error #89587
Conversation
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
51fb513
to
97a8e59
Compare
This comment has been minimized.
This comment has been minimized.
97a8e59
to
63efeab
Compare
crate_name, | ||
paths.next().unwrap().display() | ||
); | ||
let padding = 8 + crate_name.len(); |
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.
This padding doesn't seem correct to me. It's the same as before, but crate `
is 7 chars and `:
is 3 chars (backtick, colon, space). Together, that makes 10 characters, not 8. Additionally, I don't think the format specifier {:>padding$}
is correct for paths shorter than padding
.
Should I change it to push_str
the padding, and then push the path, rather than using format specifiers? I think that would be more correct.
This comment has been minimized.
This comment has been minimized.
9ace45d
to
78b352e
Compare
This comment has been minimized.
This comment has been minimized.
Looks like tests failed for two reasons: (1) #89587 (comment) and (2) inconsistent ordering of candidates. For (1), I just need to add |
78b352e
to
c578e27
Compare
(1) should be fixed now. |
c578e27
to
8a5e22e
Compare
This comment has been minimized.
This comment has been minimized.
8a5e22e
to
79b3ef8
Compare
Ok, (2) should be fixed as well now. |
I also reordered the commits so that the tests are added before the |
📌 Commit 359a3fdfc2d7f425c29155959643f7a5d46d732e has been approved by |
⌛ Testing commit 359a3fdfc2d7f425c29155959643f7a5d46d732e with merge 9abf6d9699ae26eec2c5a48bc6e610f6f97cc410... |
// error-pattern:multiple matching crates for `crateresolve1` | ||
|
||
// normalize-stderr-test: "\.nll/" -> "/" | ||
// normalize-stderr-test: "\\\?\\" -> "" |
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.
Why doesn't this issue appear with other tests printing $TEST_BUILD_DIR
paths?
Do verbatim paths (\\?
) appear because the path is fs::canonicalize
-d in this case?
This normalization looks like a compiletest's job (src\tools\compiletest\src\runtest.rs
-> fn normalize_output
).
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.
I agree that it's a bit odd, but I figured it's because the crate loader is showing absolute paths. I don't have time to look into whether this is a compiletest issue unfortunately.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This makes the error output deterministic and thus testable.
And remove E0464 from test-exemption list, since it now has a full test.
Only dylib and rlib candidates were included in the error. I think the reason is that at the time this error was originally implemented, rmeta crate sources were represented different from dylib and rlib sources. I wrote up more detailed analysis in [this comment][1]. The new version of the code is also a bit easier to read and should be more robust to future changes since it uses `CrateSources::paths()`. [1]: rust-lang#88675 (comment)
The test is copied from `src/test/ui/crate-loading/crateresolve1.rs` and its auxiliary tests. I added it to the `compile_fail` code example check exemption list since it's hard if not impossible to reproduce this error in a standalone code example.
359a3fd
to
cc6a090
Compare
@bors r=petrochenkov |
📌 Commit bf2d2e5 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (5728bd6): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Only dylib and rlib candidates were included in the error. I think the
reason is that at the time this error was originally implemented, rmeta
crate sources were represented different from dylib and rlib sources.
I wrote up more detailed analysis in this comment.
The new version of the code is also a bit easier to read and should be
more robust to future changes since it uses
CrateSources::paths()
.I also changed the code to sort the candidates to make the output deterministic;
added full stderr tests for the error; and added a long error code explanation.
cc @Mark-Simulacrum @jyn514