Skip to content

rustc: Move crate_types and stable_crate_id from Session to GlobalCtxt #114622

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Aug 11, 2023

Conversation

petrochenkov
Copy link
Contributor

Removes two pieces of mutable state.
Follow up to #114578.

@rustbot
Copy link
Collaborator

rustbot commented Aug 8, 2023

r? @TaKO8Ki

(rustbot has picked a reviewer for you, use r? to override)

@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 Aug 8, 2023
@rustbot
Copy link
Collaborator

rustbot commented Aug 8, 2023

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 8, 2023

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned TaKO8Ki Aug 8, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Aug 8, 2023

r=me with fallout fixed

Removes a piece of mutable state.
Follow up to rust-lang#114578.
Removes a piece of mutable state.
Follow up to rust-lang#114578.
@petrochenkov
Copy link
Contributor Author

@rustbot ready

@oli-obk
Copy link
Contributor

oli-obk commented Aug 9, 2023

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 9, 2023

📌 Commit 907aa44 has been approved by oli-obk

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 Aug 9, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 11, 2023
…mpiler-errors

Rollup of 7 pull requests

Successful merges:

 - rust-lang#114599 (Add impl trait declarations to SMIR)
 - rust-lang#114622 (rustc: Move `crate_types` and `stable_crate_id` from `Session` to `GlobalCtxt`)
 - rust-lang#114662 (Unlock trailing where-clauses for lazy type aliases)
 - rust-lang#114693 (Remove myself from the review rotation)
 - rust-lang#114694 (make the provisional cache slightly less broken)
 - rust-lang#114705 (Add spastorino to mailmap)
 - rust-lang#114712 (Fix a couple of bad comments)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 94533d9 into rust-lang:master Aug 11, 2023
@rustbot rustbot added this to the 1.73.0 milestone Aug 11, 2023
petrochenkov added a commit to petrochenkov/rust that referenced this pull request Aug 11, 2023
Removes two pieces of mutable state.
Follow up to rust-lang#114622.
@RalfJung
Copy link
Member

This seems to be part of a general push to remove interior mutability from Session? Is the high-level plan/motivation described/tracked anywhere?

@petrochenkov
Copy link
Contributor Author

@RalfJung
There's not much of a plan, only 3 such fields were discovered in #114578, and all of them are already moved.

@RalfJung
Copy link
Member

Ah I see. :) I was just curious why interior mutability in Session is a problem. But anyway, looks like a nice cleanup. :D

@bjorn3
Copy link
Member

bjorn3 commented Aug 11, 2023

Interior mutability in Session bypasses the incremental compilation system. And in case of a field that is not immediately initialized it can mean that accessing those fields too early results in a crash at runtime rather than a compile time error.

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 13, 2023
rustc: Move `features` from `Session` to `GlobalCtxt`

Removes one more piece of mutable state.
Follow up to rust-lang#114622.

The rule I used for passing feature in function signatures:
- if a crate already depends on `rustc_middle`, then `Session` is replaced with `TyCtxt`
- otherwise session and features are passed as a pair `sess: &Session, features: &Features`

The code in `rustc_lint` is ultimately used for implementing a trait from `rustc_expand`, so it also doesn't use tcx despite the dependency on `rustc_middle`.
bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Sep 6, 2023
rustc: Move `crate_types` and `stable_crate_id` from `Session` to `GlobalCtxt`

Removes two pieces of mutable state.
Follow up to rust-lang#114578.
@petrochenkov petrochenkov deleted the noplugin branch February 22, 2025 18:39
# for free to join this conversation on GitHub. Already have an account? # 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.

8 participants