Skip to content

Fix "local crate" detection #3644

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

Merged
merged 3 commits into from
May 30, 2024

Conversation

narpfel
Copy link
Contributor

@narpfel narpfel commented May 28, 2024

PackageId is an opaque identifier whose internal format is subject to change, so looking up the names of local crates by ID is more robust than parsing the ID.

Resolves #3643.

`PackageId` is an opaque identifier whose internal format is subject to
change, so looking up the names of local crates by ID is more robust
than parsing the ID.

Resolves rust-lang#3643.
@narpfel narpfel force-pushed the local-crates-metadata-format-update branch 2 times, most recently from 3be956e to 8bb14dc Compare May 28, 2024 21:20
@saethlin
Copy link
Member

Doesn't cargo metadata have a --format-version flag to prevent silent breakage like this? is cargo_metadata not using that flag? If it's not, can we add it to prevent future issues like this?

@RalfJung
Copy link
Member

I think this cargo change was not considered a breaking change since there was never any guarantee about the format of that field. Some clients (Miri included) just used the field in ways that was never intended or supported.

@@ -0,0 +1,26 @@
subcrate,issue_1567,exported_symbol_dep,cargo_miri_test,cdylib,executable,library_with_dashes,exported_symbol,issue_1691,issue_1705,issue_rust_86261,proc_macro_crate
error: Undefined Behavior: entering unreachable code
--> /build/local-crate/library-with-dashes/src/lib.rs:6:14
Copy link
Member

@RalfJung RalfJung May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this path come from? It looks like an absolute path, which would be a problem -- the test is meant to work everywhere, not just on CI.

Also, this fails on Windows because there, some of the / become \.

Our test-cargo-miri isn't really set up to deal with error output I am afraid. Maybe it'd be easier to just test the contents of MIRI_LOCAL_CRATES rather than an actual error message? E.g. if we check that it contains issue_rust_86261, that should be enough, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this path come from? It looks like an absolute path, which would be a problem -- the test is meant to work everywhere, not just on CI.

The test runner uses --remap-path-prefix to replace the working directory with /build: 8bb14dc#diff-4fcb5764801672d83a446351eb4d6f44577f99d386d2632964e7a239bfbbb813R137

Maybe it'd be easier to just test the contents of MIRI_LOCAL_CRATES rather than an actual error message?

Yeah, that’s probably better.

@@ -17,6 +17,7 @@ issue_1567 = { path = "issue-1567" }
issue_1691 = { path = "issue-1691" }
issue_1705 = { path = "issue-1705" }
issue_rust_86261 = { path = "issue-rust-86261" }
executable = { path = "local-crate/executable" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs comments to explain what the test is about, and ideally a better name -- "executable" doesn't say much. The point is that this one has UB and we're checking what that looks like.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the test test-local-crate-detection. Is that better?

@narpfel narpfel force-pushed the local-crates-metadata-format-update branch from 8bb14dc to 449925b Compare May 29, 2024 19:04
@RalfJung
Copy link
Member

Looks good, thanks!
@bors r+

@bors
Copy link
Contributor

bors commented May 30, 2024

📌 Commit 0a58833 has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented May 30, 2024

⌛ Testing commit 0a58833 with merge 38e318c...

@bors
Copy link
Contributor

bors commented May 30, 2024

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 38e318c to master...

@bors bors merged commit 38e318c into rust-lang:master May 30, 2024
5 checks passed
@narpfel narpfel deleted the local-crates-metadata-format-update branch May 31, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"local crate" detection does not work any more
4 participants