As discussed in today's meeting, we need to get rustc bootstrapping with NLL enabled -- if there are problems, we should isolate them.
@lqd is going to try and push this through and report back.
Here's a summary of this adventure :)
I'll ignore the cases where MIR borrowck correctly adds new "unused mut" lint warnings which were previously not found by the AST borrowck: while they are new warnings, the unused muts were easily removed from the rustc code in order to keep building, so I marked them as ok (but can produce the list of cases if need be).
I tested by manually enabling the NLL feature in crates, #![cfg_attr(not(stage0), feature(nll))], and building. This doesn't test the submodules, stdsimd, and tools.
liballoc: doesn't build, already tracked as #48224 (https://github.com/rust-lang/rust/issues/48224#issuecomment-365952037 mentions Niko might have a fix already)
librustc_passes: doesn't build right now and seems correct (apparently this pattern comes up often, so maybe we can accept this in the future, with additions to 2-phase-borrows), minimized repro here for convenience.
librustc_typeck: doesn't build because of incorrect "unused mut" lint warnings #51830. and because of ICE cannot convert ... to a region vid which is #51351, and has a minimized repro.
libsyntax_ext: doesn't build because of "broken MIR" ICE #48071, which has a minimal repro here.
libcore: used to ICE with region_obligations not empty (known issue #51649).
This error has, after I started, become less prominent on master, and now 4 denied warnings prevent building. These are incorrect "unused mut" lint warnings when using move closures, and occurrences of known issue #51801 (which might be a more minimal reproduction of #50897)
librustc doesn't build because of incorrect "unused mut" lint warnings #51801 and #51830, the latter mentions removing a "mut" that doesn't exist in the surface code, and minimized in the issues and for convenience here
librustc_data_structures: used to ICE with region_obligations not empty (known issue #51649). Now doesn't build because of incorrect "unused mut" lint warnings #51801.
librustc_driver: doesn't build because of incorrect "unused mut" lint warnings #51801.
librustc_lint: doesn't build because of incorrect "unused mut" lint warnings #51830.
librustc_traits: doesn't build because of incorrect "unused mut" lint warnings #51830.
libserialize: doesn't build because of incorrect "unused mut" lint warnings #51801.
libsyntax: doesn't build because of incorrect "unused mut" lint warnings which I'm not sure we tracked so I filed it as #51904. A reduced repro is available here. The fact that there are 2 closures seem important here.
Crates without issues
region_obligations not empty (known issue #51649). Now ok.Tagging this meta bug as NLL-deferred until the following issues are fixed:
Now that all of those issues are fixed, I've added #52671 to the list since it is also blocking bootstrap.
With that fix bootstrapping still breaks due to the unused mut lint and a case where two phase borrows don't track activation through unsized coercions. I've created PRs for those.
Ok so rustc almost bootstraps, but changes since my last comment prevent it from doing so (more unused mut that AST misses, an issue with incorrect lifetime annotations). At this point I think that this will have to be checked with CI.
@Mark-Simulacrum @nikomatsakis @pnkfelix was there a decision on how we want to move rustc/CI towards nll?
I sort of presume that we can enable -Zborrowck=mir across all compilations in rust-lang/rust as soon as we believe the performance is good enough and the compiler works with it.
Or at least -Z borrowck=migrate -Z two-phase-borrows. I'm not sure about going all the way to -Z borrowck=mir -Z two-phase-borrows in our first step here.
Although, what am I talking about, we control our own code, we don't need to use the migration path.
Closing in favor of #53172
Most helpful comment
Here's a summary of this adventure :)
I'll ignore the cases where MIR borrowck correctly adds new "unused mut" lint warnings which were previously not found by the AST borrowck: while they are new warnings, the unused muts were easily removed from the rustc code in order to keep building, so I marked them as ok (but can produce the list of cases if need be).
I tested by manually enabling the NLL feature in crates,
#![cfg_attr(not(stage0), feature(nll))], and building. This doesn't test the submodules, stdsimd, and tools.Interesting cases
liballoc: doesn't build, already tracked as #48224 (https://github.com/rust-lang/rust/issues/48224#issuecomment-365952037 mentions Niko might have a fix already)
librustc_passes: doesn't build right now and seems correct (apparently this pattern comes up often, so maybe we can accept this in the future, with additions to 2-phase-borrows), minimized repro here for convenience.
librustc_typeck: doesn't build because of incorrect "unused mut" lint warnings #51830. and because of ICE
cannot convert ... to a region vidwhich is #51351, and has a minimized repro.libsyntax_ext: doesn't build because of "broken MIR" ICE #48071, which has a minimal repro here.
Cases of incorrect "unused mut" lint warnings
libcore: used to ICE with
region_obligations not empty(known issue #51649).This error has, after I started, become less prominent on master, and now 4 denied warnings prevent building. These are incorrect "unused mut" lint warnings when using move closures, and occurrences of known issue #51801 (which might be a more minimal reproduction of #50897)
librustc doesn't build because of incorrect "unused mut" lint warnings #51801 and #51830, the latter mentions removing a "mut" that doesn't exist in the surface code, and minimized in the issues and for convenience here
librustc_data_structures: used to ICE with
region_obligations not empty(known issue #51649). Now doesn't build because of incorrect "unused mut" lint warnings #51801.librustc_driver: doesn't build because of incorrect "unused mut" lint warnings #51801.
librustc_lint: doesn't build because of incorrect "unused mut" lint warnings #51830.
librustc_traits: doesn't build because of incorrect "unused mut" lint warnings #51830.
libserialize: doesn't build because of incorrect "unused mut" lint warnings #51801.
libsyntax: doesn't build because of incorrect "unused mut" lint warnings which I'm not sure we tracked so I filed it as #51904. A reduced repro is available here. The fact that there are 2 closures seem important here.
Crates without issues
region_obligations not empty(known issue #51649). Now ok.