Uh oh!
There was an error while loading. Please reload this page.
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
commented
May 17, 2017
(rust_highfive has picked a reviewer for you, use r? to override) |
carols10cents
commented
May 22, 2017
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.
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.
nikomatsakis
commented
May 22, 2017
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. |
nikomatsakis
commented
May 22, 2017
@bors r+ |
bors
commented
May 22, 2017
📌 Commit b384b18 has been approved by |
…t-id, r=nikomatsakis Refactor: Move the mutable parts out of LintStore. Fixrust-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.
bors
commented
May 24, 2017
⌛ Testing commit b384b18 with merge 8fe49ee... |
bors
commented
May 24, 2017
💔 Test failed - status-appveyor |
Mark-Simulacrum
commented
May 24, 2017
@bors retry
|
…t-id, r=nikomatsakis Refactor: Move the mutable parts out of LintStore. Fixrust-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. Fixrust-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.
bors
commented
May 25, 2017
…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.
bors
commented
May 25, 2017
☀️ Test successful - status-appveyor, status-travis |
SessionLintStoreis emptied when linting.SessionLintStoreis 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
LintStoreinto a separate structureLintSession. The "check crates" methods can operate on&mut LintSessioninstead of&mut LintStore.This is a minor breaking change for lint writers since the
LintContexttrait is changed: themut_lintsandlevel_stackmethods are removed. But no one outside oflibrustc/lint/context.rsis using these functions, so it should be safe.