Skip to content

[StableMIR] API to retrieve definitions from crates - #132131

Merged
bors merged 1 commit into
rust-lang:masterfrom
celinval:smir-crate-defs
Nov 8, 2024
Merged

[StableMIR] API to retrieve definitions from crates#132131
bors merged 1 commit into
rust-lang:masterfrom
celinval:smir-crate-defs

Conversation

@celinval

Copy link
Copy Markdown
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!

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

Copy link
Copy Markdown
Collaborator

This PR changes Stable MIR

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

@jieyouxujieyouxu added the A-rustc_public Area: Crate rustc_public (formerly: Stable MIR, SMIR) label Oct 25, 2024
Comment threadcompiler/rustc_smir/src/rustc_smir/mod.rs Outdated
Comment threadcompiler/rustc_smir/src/rustc_smir/mod.rs Outdated
Comment threadcompiler/rustc_smir/src/rustc_smir/mod.rs Outdated
Comment threadcompiler/rustc_smir/src/rustc_smir/mod.rs Outdated
Comment threadcompiler/rustc_smir/src/rustc_smir/mod.rs Outdated
Comment threadcompiler/rustc_smir/src/rustc_smir/mod.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 Nov 4, 2024
@celinval

Copy link
Copy Markdown
ContributorAuthor

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

@rustbotrustbot 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
Comment threadcompiler/rustc_middle/src/hir/mod.rs Outdated
Comment threadcompiler/rustc_middle/src/query/mod.rs Outdated
@compiler-errors

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@bors r+ rollup

@bors

bors commented Nov 7, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit 0ce579f has been approved by compiler-errors

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 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 (Fixrust-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!
This was referenced Nov 8, 2024
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 (Fixrust-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:masterNov 8, 2024
@rustbotrustbot 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 (Fixrust-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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustc_publicArea: Crate rustc_public (formerly: Stable MIR, SMIR)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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@celinval@rustbot@compiler-errors@bors@jieyouxu