Skip to content

rustc: Use tcx.used_crates(()) more - #124976

Merged
bors merged 1 commit into
rust-lang:masterfrom
petrochenkov:usedcrates
May 23, 2024
Merged

rustc: Use tcx.used_crates(()) more#124976
bors merged 1 commit into
rust-lang:masterfrom
petrochenkov:usedcrates

Conversation

@petrochenkov

Copy link
Copy Markdown
Contributor

And explain when it should be used.

Addresses comments from #121167.

@rustbot

Copy link
Copy Markdown
Collaborator

r? @compiler-errors

rustbot has assigned @compiler-errors.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 10, 2024
@rustbot

Copy link
Copy Markdown
Collaborator

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

// `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] {

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
ContributorAuthor

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:

enumWhatCrateIsLoadedFor{ForRealThings,// Need to be encoded into metadata in any caseForDocLinksAndDiagnosticsOnly,// It may be possible to drop these ones from metadata, if we clean their traces from source map somehowForDiagnosticsOnly,}

Maybe even merge it with existing enum CrateDepKind which is sort of similar.

Let's keep its pre-existing naming for now.

Comment threadcompiler/rustc_middle/src/query/mod.rs Outdated
Comment threadsrc/tools/miri/src/helpers.rs Outdated
@compiler-errors

Copy link
Copy Markdown
Contributor

@rustbot author

@rustbotrustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 22, 2024
And explain when it should be used.
@oli-obk

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 22, 2024
@bors

bors commented May 22, 2024

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 0f35ba8 with merge 0cba80b...

bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2024
rustc: Use `tcx.used_crates(())` more
And explain when it should be used.
Addresses comments from rust-lang#121167.
@petrochenkov

Copy link
Copy Markdown
ContributorAuthor

I was just going to push an updated version.
@bors r-
Not sure if it's possible to cancel bors try.

@compiler-errors

Copy link
Copy Markdown
Contributor

If you push, then it'll cancel the try.

@petrochenkov

Copy link
Copy Markdown
ContributorAuthor

Also, in practice speculative crates are not common, so I don't expect much difference in perf.

@petrochenkov

Copy link
Copy Markdown
ContributorAuthor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@petrochenkovpetrochenkov removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 22, 2024
@bors

bors commented May 22, 2024

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 711338b with merge 20a9c4a...

bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2024
rustc: Use `tcx.used_crates(())` more
And explain when it should be used.
Addresses comments from rust-lang#121167.
@bors

bors commented May 23, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit 711338b has been approved by oli-obk

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 23, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 23, 2024
…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
@bors
bors merged commit eda4a35 into rust-lang:masterMay 23, 2024
@rustbotrustbot added this to the 1.80.0 milestone May 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 23, 2024
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

@lqdlqdMay 24, 2024

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
ContributorAuthor

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.

qinheping added a commit to model-checking/kani that referenced this pull request May 30, 2024
> 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.
@lqdlqd mentioned this pull request Jun 3, 2024
@lqd

lqd commented Jun 5, 2024

Copy link
Copy Markdown
Member

beta branches in a couple days, and so maybe we should revert this PR before then

@petrochenkov

Copy link
Copy Markdown
ContributorAuthor

I assumed #125493 had already been merged.

lqd added a commit to lqd/rust that referenced this pull request Jun 6, 2024
…=oli-obk"
This reverts commit eda4a35, reversing
changes made to eb6b35b.
lqd added a commit to lqd/rust that referenced this pull request Jun 6, 2024
…=oli-obk"
This reverts commit eda4a35, reversing
changes made to eb6b35b.
fmease added a commit to fmease/rust that referenced this pull request Jun 6, 2024
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.
fixesrust-lang#125474fixesrust-lang#125484fixesrust-lang#125646fixesrust-lang#125707fixesrust-lang#126066fixesrust-lang#125934fixesrust-lang#126021
r? `@petrochenkov`
`@bors` p=1
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jun 6, 2024
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.
fixesrust-lang#125474fixesrust-lang#125484fixesrust-lang#125646fixesrust-lang#125707fixesrust-lang#126066fixesrust-lang#125934fixesrust-lang#126021
r? ``@petrochenkov``
``@bors`` p=1
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 6, 2024
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.
fixesrust-lang#125474fixesrust-lang#125484fixesrust-lang#125646fixesrust-lang#125707fixesrust-lang#126066fixesrust-lang#125934fixesrust-lang#126021
r? `@petrochenkov`
`@bors` p=1
Oneirical pushed a commit to Oneirical/rust that referenced this pull request Jun 9, 2024
…=oli-obk"
This reverts commit eda4a35, reversing
changes made to eb6b35b.
lcnr pushed a commit to lcnr/rust that referenced this pull request Jun 12, 2024
…=oli-obk"
This reverts commit eda4a35, reversing
changes made to eb6b35b.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 13, 2024
…=oli-obk"
This reverts commit eda4a35, reversing
changes made to eb6b35b.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 13, 2024
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.
fixesrust-lang#125474fixesrust-lang#125484fixesrust-lang#125646fixesrust-lang#125707fixesrust-lang#126066fixesrust-lang#125934fixesrust-lang#126021
r? `@petrochenkov`
`@bors` p=1
@petrochenkov
petrochenkov deleted the usedcrates branch February 22, 2025 18:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@petrochenkov@rustbot@compiler-errors@oli-obk@rust-timer@bors@lqd@RalfJung