Skip to content

Document rustc_public lib.rs and update README#159347

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
celinval:docs/rpub-lib
Jul 19, 2026
Merged

Document rustc_public lib.rs and update README#159347
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
celinval:docs/rpub-lib

Conversation

@celinval

@celinval celinval commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Add module-level documentation with usage example, crate discovery guide, and status section. Document all public types, methods, and free functions in lib.rs. Update README to reflect the crate rename from stable_mir/rustc_smir to rustc_public/rustc_public_bridge.

Disclaimer: I used AI to help me generate the documentation.

Add module-level documentation with usage example, crate discovery
guide, and status section. Document all public types, methods, and
free functions in lib.rs. Update README to reflect the crate rename
from stable_mir/rustc_smir to rustc_public/rustc_public_bridge.
@rustbot

rustbot commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

This PR changes rustc_public

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

@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 Jul 15, 2026
@rustbot

rustbot commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

r? @scottmcm

rustbot has assigned @scottmcm.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: project-rustc-public
  • project-rustc-public expanded to celinval, makai410, oli-obk, scottmcm
  • Random selection from makai410, oli-obk, scottmcm

pub mod ty;
pub mod visitor;

/// Use String for now but we should replace it.

@mejrs mejrs Jul 15, 2026

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.

Does this no longer need replacing? It reads like it should be a FIXME

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true... let me expand this. I was actually thinking of changing it to be an opaque type for now. But I didn't want to change it as part of this PR.

Comment thread compiler/rustc_public/src/lib.rs Outdated
Comment thread compiler/rustc_public/src/lib.rs Outdated
Comment on lines +237 to +239
/// Returns `true` if this item, or any of its parent definitions, has type
/// or const generic parameters. This applies to functions, constants, statics,
/// and any item nested inside a generic context.

@mejrs mejrs Jul 15, 2026

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.

What is a parent definition precisely?🤔

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.

I'd say a parent definition is the DefId of the enclosing item of this item, and this item inherits the enclosing item's generic parameters.

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.

Hmm, maybe:

Suggested change
/// Returns `true` if this item, or any of its parent definitions, has type
/// or const generic parameters. This applies to functions, constants, statics,
/// and any item nested inside a generic context.
/// Returns `true` if this item has type or const generic parameters or is
/// defined inside an item that does. This applies to functions, constants, statics,
/// and any item nested inside a generic context.

//! access to the API within a callback. All queries must be performed inside this callback
//! since the data structures are tied to the compiler's thread-local state.
//!
//! ```rust,ignore (requires compiler session)

@mejrs mejrs Jul 15, 2026

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.

Suggested change
//! ```rust,ignore (requires compiler session)
//! ```rust,no_run (requires compiler session)

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will compile either

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.

I'm quite wary of untested doc examples, especially here...from my experience they eventually bitrot away.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example can't be tested as a doctest today because it requires linking against the stage2 of the rustc_driver library. As part of publishing rustc_public, we are working on CI improvements of the rustc_public repository. There we should be able to configure CI to keep examples tested.

For now I'll keep it simple with ignore, or would you rather I drop it entirely until we can properly test it?

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.

maybe leave a fixme then?

//! // ... analyze items ...
//! ControlFlow::Continue(())
//! });
//! ```

@mejrs mejrs Jul 15, 2026

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.

Can this example actually do something? Considering the other items documented in this pr, maybe a check that you aren't using multiple versions of the same crate? See https://github.com/TheBevyFlock/bevy_cli/blob/main/bevy_lint/src/lints/nursery/duplicate_bevy_dependencies.rs for example.

View changes since the review

Comment thread compiler/rustc_public/README.md Outdated
Comment thread compiler/rustc_public/src/lib.rs Outdated
Comment on lines +237 to +239
/// Returns `true` if this item, or any of its parent definitions, has type
/// or const generic parameters. This applies to functions, constants, statics,
/// and any item nested inside a generic context.

@mejrs mejrs Jul 15, 2026

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.

What is a parent definition precisely?🤔

@makai410 makai410 left a comment

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.

The overall changes look good to me

View changes since this review

Comment thread compiler/rustc_public/src/lib.rs Outdated
Comment on lines +237 to +239
/// Returns `true` if this item, or any of its parent definitions, has type
/// or const generic parameters. This applies to functions, constants, statics,
/// and any item nested inside a generic context.

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.

I'd say a parent definition is the DefId of the enclosing item of this item, and this item inherits the enclosing item's generic parameters.

- Add a concrete code example (duplicate crate detection)
- Clarify requires_monomorphization doc
- Add FIXME for Symbol type alias

Co-authored-by: Bruno Kolenbrander <[email protected]>

@mejrs mejrs left a comment

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.

Thanks!

r? me @bors r+ rollup

View changes since this review

@rust-bors

rust-bors Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit adac776 has been approved by mejrs

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jul 19, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 19, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #159524 (Gather PGO profiles in parallel)
 - #158850 (Avoid underflow for splatted rust-call receivers)
 - #159215 ([compiletest] Differentiate between LLVM LLDB and Apple LLDB)
 - #159347 (Document rustc_public lib.rs and update README)
 - #159469 (Reorganize `tests/ui/issues` [27/N])
 - #159512 (Add regression tests for fixed dead-code issues)
@rust-bors
rust-bors Bot merged commit 44765b6 into rust-lang:main Jul 19, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 19, 2026
rust-timer added a commit that referenced this pull request Jul 19, 2026
Rollup merge of #159347 - celinval:docs/rpub-lib, r=mejrs

Document rustc_public lib.rs and update README

Add module-level documentation with usage example, crate discovery guide, and status section. Document all public types, methods, and free functions in lib.rs. Update README to reflect the crate rename from `stable_mir`/`rustc_smir` to `rustc_public`/`rustc_public_bridge`.

Disclaimer: I used AI to help me generate the documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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