-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc: Use tcx.used_crates(())
more
#124976
Conversation
rustbot has assigned @compiler-errors. Use |
The Miri subtree was changed cc @rust-lang/miri Some changes occurred in src/librustdoc/clean/types.rs cc @camelid Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
// FIXME: This is currently only used for collecting lang items, but should be used instead of | ||
// `crates` in most other cases too. | ||
// Should be used to maintain observable language behavior, for example when collecting lang | ||
// items or impls from all crates, or collecting libraries to link. | ||
query used_crates(_: ()) -> &'tcx [CrateNum] { |
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.
"used" kind of sounds like if I add a crate as a dependency but don't use it, it doesn't show up.
Maybe required_crates
?
Also all_crates
could maybe need a more scary name, like crates_including_speculative
or so?
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.
crates_including_speculative
looks fine to me.
Not sure about required_crates
.
Ideally I'd turn the used
bool in crate loader into a 3-variant enum:
enum WhatCrateIsLoadedFor {
ForRealThings,
// Need to be encoded into metadata in any case
ForDocLinksAndDiagnosticsOnly,
// It may be possible to drop these ones from metadata, if we clean their traces from source map somehow
ForDiagnosticsOnly,
}
Maybe even merge it with existing enum CrateDepKind
which is sort of similar.
Let's keep its pre-existing naming for now.
@rustbot author |
And explain when it should be used.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
rustc: Use `tcx.used_crates(())` more And explain when it should be used. Addresses comments from rust-lang#121167.
I was just going to push an updated version. |
If you push, then it'll cancel the try. |
Also, in practice speculative crates are not common, so I don't expect much difference in perf. |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
rustc: Use `tcx.used_crates(())` more And explain when it should be used. Addresses comments from rust-lang#121167.
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#124297 (Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type) - rust-lang#124516 (Allow monomorphization time const eval failures if the cause is a type layout issue) - rust-lang#124976 (rustc: Use `tcx.used_crates(())` more) - rust-lang#125210 (Cleanup: Fix up some diagnostics) - rust-lang#125409 (Rename `FrameworkOnlyWindows` to `RawDylibOnlyWindows`) - rust-lang#125416 (Use correct param-env in `MissingCopyImplementations`) - rust-lang#125421 (Rewrite `core-no-oom-handling`, `issue-24445` and `issue-38237` `run-make` tests to new `rmake.rs` format) - rust-lang#125438 (Remove unneeded string conversion) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#124976 - petrochenkov:usedcrates, r=oli-obk rustc: Use `tcx.used_crates(())` more And explain when it should be used. Addresses comments from rust-lang#121167.
error: requires `sized` lang_item | ||
|
||
error: aborting due to 4 previous errors | ||
error: aborting due to 2 previous errors |
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.
Was this diagnostics change expected? (I'm analyzing the regressions caused by this PR)
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.
Yes, during my review I assumed this is the weak lang item check that now only looks at crates that are actually used, so we aren't speculatively looking at weak lang items of unused crates anymore
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.
From what I see libcore is loaded speculatively in this test (missing_core
in fn resolve_crate
) and this error happens due to (weak) lang items in core.
> Please ensure your PR description includes the following: > 1. A description of how your changes improve Kani. > 2. Some context on the problem you are solving. > 3. A list of issues that are resolved by this PR. > 4. If you had to perform any manual test, please describe them. > > **Make sure you remove this list from the final PR description.** Fix usage of `tcx.crates()`: rust-lang/rust#124976. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
beta branches in a couple days, and so maybe we should revert this PR before then |
I assumed #125493 had already been merged. |
Revert "use `tcx.used_crates(())` more" before it reaches beta There are more open issues caused by rust-lang#124976 than will be fixed by rust-lang#125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time. fixes rust-lang#125474 fixes rust-lang#125484 fixes rust-lang#125646 fixes rust-lang#125707 fixes rust-lang#126066 fixes rust-lang#125934 fixes rust-lang#126021 r? `@petrochenkov` `@bors` p=1
Revert "use `tcx.used_crates(())` more" before it reaches beta There are more open issues caused by rust-lang#124976 than will be fixed by rust-lang#125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time. fixes rust-lang#125474 fixes rust-lang#125484 fixes rust-lang#125646 fixes rust-lang#125707 fixes rust-lang#126066 fixes rust-lang#125934 fixes rust-lang#126021 r? ``@petrochenkov`` ``@bors`` p=1
Revert "use `tcx.used_crates(())` more" before it reaches beta There are more open issues caused by rust-lang#124976 than will be fixed by rust-lang#125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time. fixes rust-lang#125474 fixes rust-lang#125484 fixes rust-lang#125646 fixes rust-lang#125707 fixes rust-lang#126066 fixes rust-lang#125934 fixes rust-lang#126021 r? `@petrochenkov` `@bors` p=1
Revert "use `tcx.used_crates(())` more" before it reaches beta There are more open issues caused by rust-lang#124976 than will be fixed by rust-lang#125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time. fixes rust-lang#125474 fixes rust-lang#125484 fixes rust-lang#125646 fixes rust-lang#125707 fixes rust-lang#126066 fixes rust-lang#125934 fixes rust-lang#126021 r? `@petrochenkov` `@bors` p=1
And explain when it should be used.
Addresses comments from #121167.