Skip to content
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

[StableMIR] API to retrieve definitions from crates #132131

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

celinval
Copy link
Contributor

Add functions to retrieve function definitions and static items from all crates (local and external).

For external crates, we're still missing items from trait implementation and primitives.

r? @compiler-errors: Do you know what is the best way to retrieve the associated items for primitives and trait implementations for external crates? Thanks!

@rustbot rustbot 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. labels Oct 25, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 25, 2024

This PR changes Stable MIR

cc @oli-obk, @celinval, @ouz-a

@jieyouxu jieyouxu added the A-stable-MIR Area: stable MIR label Oct 25, 2024
@compiler-errors
Copy link
Member

@rustbot author

@rustbot rustbot 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 Nov 4, 2024
@celinval
Copy link
Contributor Author

celinval commented Nov 5, 2024

I implemented the suggested flow. So much cleaner! Thank you

I wanted to double check two things:

  1. Should expose the number of definitions as a query or as an untracked method? The latter would require extending CrateStoreDyn. I noticed the following comment in this trait:

/// Note that this trait should probably not be expanding today. All new
/// functionality should be driven through queries instead!

So I implemented as a query for now. Since this code is not used during codegen, it may still be OK to add it to the trait, so let me know if you have any preference. Changing it shouldn't be hard though.

  1. Should we implement the query for the local crate or panic? I opt for the first for completeness for now.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 5, 2024
compiler/rustc_middle/src/hir/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/query/mod.rs Outdated Show resolved Hide resolved
@compiler-errors
Copy link
Member

Please squash this into one commit. We don't typically need PRs with this much granularity, especially since the latter basically reimplements the approach in the first half of this PR.

Add functions to retrieve function definitions and static items from
all crates (local and external).

For external crates, add a query to retrieve the number of defs in a
foreign crate.
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 7, 2024

📌 Commit 0ce579f has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors 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 Nov 7, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 7, 2024
…er-errors

[StableMIR] API to retrieve definitions from crates

Add functions to retrieve function definitions and static items from all crates (local and external).

For external crates, we're still missing items from trait implementation and primitives.

r? `@compiler-errors:` Do you know what is the best way to retrieve the associated items for primitives and trait implementations for external crates? Thanks!
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 7, 2024
…er-errors

[StableMIR] API to retrieve definitions from crates

Add functions to retrieve function definitions and static items from all crates (local and external).

For external crates, we're still missing items from trait implementation and primitives.

r? ``@compiler-errors:`` Do you know what is the best way to retrieve the associated items for primitives and trait implementations for external crates? Thanks!
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 7, 2024
…llaumeGomez

Rollup of 8 pull requests

Successful merges:

 - rust-lang#130586 (Set "symbol name" in raw-dylib import libraries to the decorated name)
 - rust-lang#131913 (Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support)
 - rust-lang#132095 (Fix rust-lang#131977 parens mangled in shared mut static lint suggestion)
 - rust-lang#132131 ([StableMIR] API to retrieve definitions from crates)
 - rust-lang#132696 (Compile `test_num_f128` conditionally on `reliable_f128_math` config)
 - rust-lang#132738 (Initialize channel `Block`s directly on the heap)
 - rust-lang#132739 (Fix `librustdoc/scrape_examples.rs` formatting)
 - rust-lang#132740 (Update test for LLVM 20's new vector splat syntax)

r? `@ghost`
`@rustbot` modify labels: rollup
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Nov 8, 2024
…er-errors

[StableMIR] API to retrieve definitions from crates

Add functions to retrieve function definitions and static items from all crates (local and external).

For external crates, we're still missing items from trait implementation and primitives.

r? ```@compiler-errors:``` Do you know what is the best way to retrieve the associated items for primitives and trait implementations for external crates? Thanks!
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 8, 2024
…kingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#130586 (Set "symbol name" in raw-dylib import libraries to the decorated name)
 - rust-lang#131913 (Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support)
 - rust-lang#132095 (Fix rust-lang#131977 parens mangled in shared mut static lint suggestion)
 - rust-lang#132131 ([StableMIR] API to retrieve definitions from crates)
 - rust-lang#132639 (core: move intrinsics.rs into intrinsics folder)
 - rust-lang#132696 (Compile `test_num_f128` conditionally on `reliable_f128_math` config)
 - rust-lang#132737 (bootstrap: Print better message if lock pid isn't available)
 - rust-lang#132739 (Fix `librustdoc/scrape_examples.rs` formatting)
 - rust-lang#132740 (Update test for LLVM 20's new vector splat syntax)
 - rust-lang#132741 (Update mips64 data layout to match LLVM 20 change)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4036472 into rust-lang:master Nov 8, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 8, 2024
Rollup merge of rust-lang#132131 - celinval:smir-crate-defs, r=compiler-errors

[StableMIR] API to retrieve definitions from crates

Add functions to retrieve function definitions and static items from all crates (local and external).

For external crates, we're still missing items from trait implementation and primitives.

r? ````@compiler-errors:```` Do you know what is the best way to retrieve the associated items for primitives and trait implementations for external crates? Thanks!
mati865 pushed a commit to mati865/rust that referenced this pull request Nov 12, 2024
…er-errors

[StableMIR] API to retrieve definitions from crates

Add functions to retrieve function definitions and static items from all crates (local and external).

For external crates, we're still missing items from trait implementation and primitives.

r? ````@compiler-errors:```` Do you know what is the best way to retrieve the associated items for primitives and trait implementations for external crates? Thanks!
mati865 pushed a commit to mati865/rust that referenced this pull request Nov 12, 2024
…kingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#130586 (Set "symbol name" in raw-dylib import libraries to the decorated name)
 - rust-lang#131913 (Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support)
 - rust-lang#132095 (Fix rust-lang#131977 parens mangled in shared mut static lint suggestion)
 - rust-lang#132131 ([StableMIR] API to retrieve definitions from crates)
 - rust-lang#132639 (core: move intrinsics.rs into intrinsics folder)
 - rust-lang#132696 (Compile `test_num_f128` conditionally on `reliable_f128_math` config)
 - rust-lang#132737 (bootstrap: Print better message if lock pid isn't available)
 - rust-lang#132739 (Fix `librustdoc/scrape_examples.rs` formatting)
 - rust-lang#132740 (Update test for LLVM 20's new vector splat syntax)
 - rust-lang#132741 (Update mips64 data layout to match LLVM 20 change)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stable-MIR Area: stable MIR S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants