-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Refactor: Move the mutable parts out of LintStore. Fix #42007. #42052
Refactor: Move the mutable parts out of LintStore. Fix #42007. #42052
Conversation
* rust-lang#42007 happens because the Session LintStore is emptied when linting. * The Session LintStore is emptied because the checker (Early/LateContext) wants ownership. * The checker wants ownership because it wants to mutate the pass objects and lint levels. The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the LintStore into a separate structure `LintSession`. The "check crates" methods can operate on `&mut LintSession` instead of `&mut LintStore`. This is a minor BREAKING CHANGE for lint writers since the `LintContext` trait is changed: the `mut_lints` and `level_stack` methods are removed. But no one outside of `librustc/lint/context.rs` is using these functions, so it should be safe.
(rust_highfive has picked a reviewer for you, use r? to override) |
ping @nikomatsakis! pinging you on irc too :) |
|
||
impl<'a, PassObject: LintPassObject> LintSession<'a, PassObject> { | ||
/// Creates a new `LintSession`, by moving out the `LintStore`'s initial | ||
/// lint levels and pass objects. These can be restored using the `restore` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I guess we're doing this "take and replace" dance because it's more robust? Otherwise, I'd say let's just clone()
the LintLevels
.
This seems like a net win. The lint setup still feels a bit baroque to me, and I'd like to refactor it more broadly (as I mentioned on IRC) to be better integrated with incremental compilation, but I think we can land this in the meantime. |
@bors r+ |
📌 Commit b384b18 has been approved by |
…t-id, r=nikomatsakis Refactor: Move the mutable parts out of LintStore. Fix rust-lang#42007. * rust-lang#42007 happens because the `Session` `LintStore` is emptied when linting. * The `Session` `LintStore` is emptied because the checker (`Early`/`LateContext`) wants ownership. * The checker wants ownership because it wants to mutate the pass objects and lint levels. The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the `LintStore` into a separate structure `LintSession`. The "check crates" methods can operate on `&mut LintSession` instead of `&mut LintStore`. This is a minor *breaking change* for lint writers since the `LintContext` trait is changed: the `mut_lints` and `level_stack` methods are removed. But no one outside of `librustc/lint/context.rs` is using these functions, so it should be safe.
⌛ Testing commit b384b18 with merge 8fe49ee... |
💔 Test failed - status-appveyor |
@bors retry
|
…t-id, r=nikomatsakis Refactor: Move the mutable parts out of LintStore. Fix rust-lang#42007. * rust-lang#42007 happens because the `Session` `LintStore` is emptied when linting. * The `Session` `LintStore` is emptied because the checker (`Early`/`LateContext`) wants ownership. * The checker wants ownership because it wants to mutate the pass objects and lint levels. The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the `LintStore` into a separate structure `LintSession`. The "check crates" methods can operate on `&mut LintSession` instead of `&mut LintStore`. This is a minor *breaking change* for lint writers since the `LintContext` trait is changed: the `mut_lints` and `level_stack` methods are removed. But no one outside of `librustc/lint/context.rs` is using these functions, so it should be safe.
…t-id, r=nikomatsakis Refactor: Move the mutable parts out of LintStore. Fix rust-lang#42007. * rust-lang#42007 happens because the `Session` `LintStore` is emptied when linting. * The `Session` `LintStore` is emptied because the checker (`Early`/`LateContext`) wants ownership. * The checker wants ownership because it wants to mutate the pass objects and lint levels. The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the `LintStore` into a separate structure `LintSession`. The "check crates" methods can operate on `&mut LintSession` instead of `&mut LintStore`. This is a minor *breaking change* for lint writers since the `LintContext` trait is changed: the `mut_lints` and `level_stack` methods are removed. But no one outside of `librustc/lint/context.rs` is using these functions, so it should be safe.
…omatsakis Refactor: Move the mutable parts out of LintStore. Fix #42007. * #42007 happens because the `Session` `LintStore` is emptied when linting. * The `Session` `LintStore` is emptied because the checker (`Early`/`LateContext`) wants ownership. * The checker wants ownership because it wants to mutate the pass objects and lint levels. The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the `LintStore` into a separate structure `LintSession`. The "check crates" methods can operate on `&mut LintSession` instead of `&mut LintStore`. This is a minor *breaking change* for lint writers since the `LintContext` trait is changed: the `mut_lints` and `level_stack` methods are removed. But no one outside of `librustc/lint/context.rs` is using these functions, so it should be safe.
☀️ Test successful - status-appveyor, status-travis |
Session
LintStore
is emptied when linting.Session
LintStore
is emptied because the checker (Early
/LateContext
) wants ownership.The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the
LintStore
into a separate structureLintSession
. The "check crates" methods can operate on&mut LintSession
instead of&mut LintStore
.This is a minor breaking change for lint writers since the
LintContext
trait is changed: themut_lints
andlevel_stack
methods are removed. But no one outside oflibrustc/lint/context.rs
is using these functions, so it should be safe.