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

Add empty MIR pass for non-lexical lifetimes #43271

Merged
merged 1 commit into from
Jul 20, 2017
Merged

Conversation

Nashenas88
Copy link
Contributor

This is the first step for #43234.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@Nashenas88
Copy link
Contributor Author

r? @nikomatsakis

@Mark-Simulacrum Mark-Simulacrum added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 17, 2017
tcx: TyCtxt<'a, 'tcx, 'tcx>,
_: MirSource,
mir: &mut Mir<'tcx>) {
if tcx.sess.opts.debugging_opts.nll {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: It would probably be better to do

if !tcx.sess.opts.debugging_opts.nll {
  return;
}

So as to avoid indenting the more interesting code. =)

But I'm going to assume you can do this in follow-up PRs. 😄

@nikomatsakis
Copy link
Contributor

@bors r

@bors
Copy link
Contributor

bors commented Jul 17, 2017

📌 Commit 2a5a82b has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Jul 17, 2017

⌛ Testing commit 2a5a82b46474252b4183ed3e17c480230a942820 with merge 8e2a89060881d6f21bca929592ba017f1007a185...

@bors
Copy link
Contributor

bors commented Jul 17, 2017

💔 Test failed - status-travis

@Nashenas88
Copy link
Contributor Author

The failing test looks like a build that got stuck. Could this be related to my changes, or does it behave sporadically sometimes?

@nikomatsakis
Copy link
Contributor

@Nashenas88 there are sporadic failures. Hard to imagine how your code could be responsible.

@alexcrichton
Copy link
Member

@Nashenas88
Copy link
Contributor Author

Now it looks like homu is failing on the same test.

@Nashenas88
Copy link
Contributor Author

@bors: retry

@bors
Copy link
Contributor

bors commented Jul 18, 2017

@Nashenas88: 🔑 Insufficient privileges: and not in try users

@aidanhs
Copy link
Member

aidanhs commented Jul 18, 2017

@Nashenas88 your PR is in the queue already, it hasn't failed again since @alexcrichton retried it. See https://buildbot2.rust-lang.org/homu/queue/rust

@Nashenas88
Copy link
Contributor Author

I'm really sorry about that. It's been a while since I went through this process.

@aidanhs
Copy link
Member

aidanhs commented Jul 18, 2017

@Nashenas88 don't worry about it, no harm done! The queue is...unusually large at the moment, so it may be a while before yours gets tested and (hopefully) merged.

@bors
Copy link
Contributor

bors commented Jul 18, 2017

⌛ Testing commit 2a5a82b46474252b4183ed3e17c480230a942820 with merge 09ce3341914e493cf408959cd6f691e2630818a9...

@bors
Copy link
Contributor

bors commented Jul 18, 2017

💔 Test failed - status-travis

@est31
Copy link
Member

est31 commented Jul 18, 2017

@bors retry

@bors
Copy link
Contributor

bors commented Jul 19, 2017

☔ The latest upstream changes (presumably #43170) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Jul 19, 2017

🔒 Merge conflict

@arielb1
Copy link
Contributor

arielb1 commented Jul 19, 2017

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jul 19, 2017

📌 Commit 7a966b4 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Jul 20, 2017

⌛ Testing commit 7a966b4 with merge 9d54ebe...

bors added a commit that referenced this pull request Jul 20, 2017
Add empty MIR pass for non-lexical lifetimes

This is the first step for #43234.
@bors
Copy link
Contributor

bors commented Jul 20, 2017

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

@bors bors merged commit 7a966b4 into rust-lang:master Jul 20, 2017
@Nashenas88 Nashenas88 deleted the nll branch July 28, 2017 00:01
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 7, 2022
…matsakis

Remove migrate borrowck mode

Closes rust-lang#58781
Closes rust-lang#43234

# Stabilization proposal

This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile.

Tracking issue: rust-lang#43234
RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md
Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable).

## Motivation

Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors.

The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition.

In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker.

In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver.

While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is:open is:issue label:NLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff.

## What is stabilized

As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is:open is:issue label:NLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise.

There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](rust-lang#95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl.

As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions.

## What isn't stabilized

This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck.

## Tests

Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll`

## History

* On 2017-07-14, [tracking issue opened](rust-lang#43234)
* On 2017-07-20, [initial empty MIR pass added](rust-lang#43271)
* On 2017-08-29, [RFC opened](rust-lang/rfcs#2094)
* On 2017-11-16, [Integrate MIR type-checker with NLL](rust-lang#45825)
* On 2017-12-20, [NLL feature complete](rust-lang#46862)
* On 2018-07-07, [Don't run AST borrowck on mir mode](rust-lang#52083)
* On 2018-07-27, [Add migrate mode](rust-lang#52681)
* On 2019-04-22, [Enable migrate mode on 2015 edition](rust-lang#59114)
* On 2019-08-26, [Don't downgrade errors on 2015 edition](rust-lang#64221)
* On 2019-08-27, [Remove AST borrowck](rust-lang#64790)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Jun 16, 2022
Remove migrate borrowck mode

Closes #58781
Closes #43234

# Stabilization proposal

This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile.

Tracking issue: #43234
RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md
Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable).

## Motivation

Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors.

The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition.

In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker.

In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver.

While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is:open is:issue label:NLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff.

## What is stabilized

As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is:open is:issue label:NLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise.

There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](rust-lang/rust#95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl.

As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions.

## What isn't stabilized

This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck.

## Tests

Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll`

## History

* On 2017-07-14, [tracking issue opened](rust-lang/rust#43234)
* On 2017-07-20, [initial empty MIR pass added](rust-lang/rust#43271)
* On 2017-08-29, [RFC opened](rust-lang/rfcs#2094)
* On 2017-11-16, [Integrate MIR type-checker with NLL](rust-lang/rust#45825)
* On 2017-12-20, [NLL feature complete](rust-lang/rust#46862)
* On 2018-07-07, [Don't run AST borrowck on mir mode](rust-lang/rust#52083)
* On 2018-07-27, [Add migrate mode](rust-lang/rust#52681)
* On 2019-04-22, [Enable migrate mode on 2015 edition](rust-lang/rust#59114)
* On 2019-08-26, [Don't downgrade errors on 2015 edition](rust-lang/rust#64221)
* On 2019-08-27, [Remove AST borrowck](rust-lang/rust#64790)
workingjubilee pushed a commit to tcdi/postgrestd that referenced this pull request Sep 15, 2022
Remove migrate borrowck mode

Closes #58781
Closes #43234

# Stabilization proposal

This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile.

Tracking issue: #43234
RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md
Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable).

## Motivation

Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors.

The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition.

In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker.

In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver.

While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is:open is:issue label:NLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff.

## What is stabilized

As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is:open is:issue label:NLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise.

There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](rust-lang/rust#95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl.

As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions.

## What isn't stabilized

This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck.

## Tests

Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll`

## History

* On 2017-07-14, [tracking issue opened](rust-lang/rust#43234)
* On 2017-07-20, [initial empty MIR pass added](rust-lang/rust#43271)
* On 2017-08-29, [RFC opened](rust-lang/rfcs#2094)
* On 2017-11-16, [Integrate MIR type-checker with NLL](rust-lang/rust#45825)
* On 2017-12-20, [NLL feature complete](rust-lang/rust#46862)
* On 2018-07-07, [Don't run AST borrowck on mir mode](rust-lang/rust#52083)
* On 2018-07-27, [Add migrate mode](rust-lang/rust#52681)
* On 2019-04-22, [Enable migrate mode on 2015 edition](rust-lang/rust#59114)
* On 2019-08-26, [Don't downgrade errors on 2015 edition](rust-lang/rust#64221)
* On 2019-08-27, [Remove AST borrowck](rust-lang/rust#64790)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants