rust/src/librustc_passes
bors 2400ebfe76 Auto merge of #43522 - alexcrichton:rewrite-lints, r=michaelwoerister
rustc: Rearchitect lints to be emitted more eagerly

In preparation for incremental compilation this commit refactors the lint
handling infrastructure in the compiler to be more "eager" and overall more
incremental-friendly. Many passes of the compiler can emit lints at various
points but before this commit all lints were buffered in a table to be emitted
at the very end of compilation. This commit changes these lints to be emitted
immediately during compilation using pre-calculated lint level-related data
structures.

Linting today is split into two phases, one set of "early" lints run on the
`syntax::ast` and a "late" set of lints run on the HIR. This commit moves the
"early" lints to running as late as possible in compilation, just before HIR
lowering. This notably means that we're catching resolve-related lints just
before HIR lowering. The early linting remains a pass very similar to how it was
before, maintaining context of the current lint level as it walks the tree.

Post-HIR, however, linting is structured as a method on the `TyCtxt` which
transitively executes a query to calculate lint levels. Each request to lint on
a `TyCtxt` will query the entire crate's 'lint level data structure' and then go
from there about whether the lint should be emitted or not.

The query depends on the entire HIR crate but should be very quick to calculate
(just a quick walk of the HIR) and the red-green system should notice that the
lint level data structure rarely changes, and should hopefully preserve
incrementality.

Overall this resulted in a pretty big change to the test suite now that lints
are emitted much earlier in compilation (on-demand vs only at the end). This in
turn necessitated the addition of many `#![allow(warnings)]` directives
throughout the compile-fail test suite and a number of updates to the UI test
suite.

Closes https://github.com/rust-lang/rust/issues/42511
2017-08-10 11:20:15 +00:00
..
ast_validation.rs rustc: Rearchitect lints to be emitted more eagerly 2017-08-09 09:13:51 -07:00
Cargo.toml Remove internal liblog 2017-03-23 11:28:00 -07:00
consts.rs rustc: Rearchitect lints to be emitted more eagerly 2017-08-09 09:13:51 -07:00
diagnostics.rs extended information for E0571 break with value in non-loop loop 2017-08-09 01:33:49 -07:00
hir_stats.rs Pass crate attributes in visit.rs 2017-05-12 07:15:29 +12:00
lib.rs de-orphan extended information 2017-08-06 21:29:05 -07:00
loops.rs Remove need for &format!(...) or &&"" dances in span_label calls 2017-05-08 12:56:15 +02:00
mir_stats.rs add new instructions for asserting when values are valid, and to describe when we can rely on them being locked in memory 2017-07-30 01:11:59 -07:00
no_asm.rs annotate stricter lifetimes on LateLintPass methods to allow them to forward to a Visitor 2016-12-06 11:28:51 +01:00
static_recursion.rs report the total number of errors on compilation failure 2017-07-02 16:16:44 +03:00