rust/src/librustc_passes
bors c2cab1fd58 Auto merge of #33794 - petrochenkov:sanity, r=nrc
Add AST validation pass and move some checks to it

The purpose of this pass is to catch constructions that fit into AST data structures, but not permitted by the language. As an example, `impl`s don't have visibilities, but for convenience and uniformity with other items they are represented with a structure `Item` which has `Visibility` field.

This pass is intended to run after expansion of macros and syntax extensions (and before lowering to HIR), so it can catch erroneous constructions that were generated by them. This pass allows to remove ad hoc semantic checks from the parser, which can be overruled by syntax extensions and occasionally macros.

The checks can be put here if they are simple, local, don't require results of any complex analysis like name resolution or type checking and maybe don't logically fall into other passes. I expect most of errors generated by this pass to be non-fatal and allowing the compilation to proceed.

I intend to move some more checks to this pass later and maybe extend it with new checks, like, for example, identifier validity. Given that syntax extensions are going to be stabilized in the measurable future, it's important that they would not be able to subvert usual language rules.

In this patch I've added two new checks - a check for labels named `'static` and a check for lifetimes and labels named `'_`. The first one gives a hard error, the second one - a future compatibility warning.
Fixes https://github.com/rust-lang/rust/issues/33059 ([breaking-change])
cc https://github.com/rust-lang/rfcs/pull/1177

r? @nrc
2016-06-01 06:21:53 -07:00
..
ast_validation.rs sanity -> validation 2016-05-28 20:52:49 +03:00
Cargo.toml update Cargo.toml for rustbuild 2016-04-27 10:47:46 +02:00
consts.rs rustc: Split local type contexts interners from the global one. 2016-05-11 04:14:58 +03:00
diagnostics.rs Auto merge of #33794 - petrochenkov:sanity, r=nrc 2016-06-01 06:21:53 -07:00
lib.rs sanity -> validation 2016-05-28 20:52:49 +03:00
loops.rs thread tighter span for closures around 2016-04-24 18:10:57 +05:30
no_asm.rs
rvalues.rs rustc: Split local type contexts interners from the global one. 2016-05-11 04:14:58 +03:00
static_recursion.rs rustc: move middle::{def,def_id,pat_util} to hir. 2016-04-06 09:14:21 +03:00