-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Verify build-std resolve against original lockfile #13916
base: master
Are you sure you want to change the base?
Verify build-std resolve against original lockfile #13916
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
r? @ehuss (nvm, I forgot a file 🙃) |
Co-authored-by: Lawrence Tang <lawrence.tang@arm.com>
4f5aa4d
to
eda17f3
Compare
let pkg_name = resolved_pkg.name().to_string(); | ||
let pkg_ver = resolved_pkg.version().to_string(); |
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 do we need to to_string
these?
let lockfile_pkg = lockfile_packages.binary_search_by_key( | ||
&(pkg_name.as_str(), pkg_ver.as_str()), | ||
|p| (p.name(), p.version()) | ||
) |
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.
Shouldn't we also be checking the source
?
let encoded_lockfile: EncodableResolve = toml::from_str(&lockfile).unwrap(); | ||
let lockfile_packages = encoded_lockfile.package().expect("libstd has no packages!"); | ||
|
||
for resolved_pkg in resolve.targeted_resolve.iter() { |
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.
resolved_pkg
is a PackageId, right? Could we clarify that by renaming it to resolved_pkgid
?
// If the lockfile wasn't sorted then the binary search result can be nonsensical | ||
assert!(lockfile_pkg.name() == pkg_name); | ||
|
||
for (dep, _) in resolve.targeted_resolve.deps(resolved_pkg) { |
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.
ditto about dep
-> dep_id
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.
Maybe even resolved_dep_id
What does this PR try to resolve?
Ensures that the resolve of the standard library when using build-std is a subset of the lockfile from the library source, as per discussion on rust-lang/wg-cargo-std-aware#38. It is a runtime version of the test added here: #13404
Fixes rust-lang/wg-cargo-std-aware#38
How should we test and review this PR?
It can be manually tested by running cargo build -Zbuild-std --target=[host] and seeing the command succeed. I'm not sure what behaviour can exercise the negative test case.
Additional information
Co-authored-by: Lawrence Tang lawrence.tang@arm.com