Skip to content
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

Merged
merged 1 commit into from
May 25, 2017

Conversation

kennytm
Copy link
Member

@kennytm kennytm commented May 17, 2017

  • ICE: trivial_numeric_casts when using SDL on nightly #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-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
Copy link
Collaborator

r? @nikomatsakis

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

@aidanhs aidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 17, 2017
@carols10cents
Copy link
Member

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`
Copy link
Contributor

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.

@nikomatsakis
Copy link
Contributor

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

@bors r+

@bors
Copy link
Contributor

bors commented May 22, 2017

📌 Commit b384b18 has been approved by nikomatsakis

frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 23, 2017
…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.
@arielb1 arielb1 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 May 23, 2017
@bors
Copy link
Contributor

bors commented May 24, 2017

⌛ Testing commit b384b18 with merge 8fe49ee...

@bors
Copy link
Contributor

bors commented May 24, 2017

💔 Test failed - status-appveyor

@Mark-Simulacrum
Copy link
Member

@bors retry

  • timeout, presumably slow git on appveyor

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 24, 2017
…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.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 24, 2017
…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.
bors added a commit that referenced this pull request May 24, 2017
@bors
Copy link
Contributor

bors commented May 25, 2017

⌛ Testing commit b384b18 with merge deb90c3...

bors added a commit that referenced this pull request 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
Copy link
Contributor

bors commented May 25, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing deb90c3 to master...

@bors bors merged commit b384b18 into rust-lang:master May 25, 2017
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants