sanity -> validation
Add test for `::super` in import prefix
This commit is contained in:
parent
c02c6e88e6
commit
731144b95a
@ -38,7 +38,7 @@ use rustc_privacy;
|
||||
use rustc_plugin::registry::Registry;
|
||||
use rustc_plugin as plugin;
|
||||
use rustc::hir::lowering::lower_crate;
|
||||
use rustc_passes::{ast_sanity, no_asm, loops, consts, rvalues, static_recursion};
|
||||
use rustc_passes::{ast_validation, no_asm, loops, consts, rvalues, static_recursion};
|
||||
use rustc_const_eval::check_match;
|
||||
use super::Compilation;
|
||||
|
||||
@ -167,8 +167,8 @@ pub fn compile_input(sess: &Session,
|
||||
|| lint::check_ast_crate(sess, &expanded_crate));
|
||||
|
||||
time(sess.time_passes(),
|
||||
"AST sanity checking",
|
||||
|| ast_sanity::check_crate(sess, &expanded_crate));
|
||||
"AST validation",
|
||||
|| ast_validation::check_crate(sess, &expanded_crate));
|
||||
|
||||
let (analysis, resolutions, mut hir_forest) = {
|
||||
lower_and_resolve(sess, &id, &mut defs, &expanded_crate,
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Sanity check AST before lowering it to HIR
|
||||
// Validate AST before lowering it to HIR
|
||||
//
|
||||
// This pass is supposed to catch things that fit into AST data structures,
|
||||
// but not permitted by the language. It runs after expansion when AST is frozen,
|
||||
@ -24,11 +24,11 @@ use syntax::errors;
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::visit::{self, Visitor};
|
||||
|
||||
struct SanityChecker<'a> {
|
||||
struct AstValidator<'a> {
|
||||
session: &'a Session,
|
||||
}
|
||||
|
||||
impl<'a> SanityChecker<'a> {
|
||||
impl<'a> AstValidator<'a> {
|
||||
fn err_handler(&self) -> &errors::Handler {
|
||||
&self.session.parse_sess.span_diagnostic
|
||||
}
|
||||
@ -57,7 +57,7 @@ impl<'a> SanityChecker<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for SanityChecker<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for AstValidator<'a> {
|
||||
fn visit_lifetime(&mut self, lt: &Lifetime) {
|
||||
if lt.name.as_str() == "'_" {
|
||||
self.session.add_lint(
|
||||
@ -72,9 +72,7 @@ impl<'a, 'v> Visitor<'v> for SanityChecker<'a> {
|
||||
fn visit_expr(&mut self, expr: &Expr) {
|
||||
match expr.node {
|
||||
ExprKind::While(_, _, Some(ident)) | ExprKind::Loop(_, Some(ident)) |
|
||||
ExprKind::WhileLet(_, _, _, Some(ident)) | ExprKind::ForLoop(_, _, _, Some(ident)) => {
|
||||
self.check_label(ident, expr.span, expr.id);
|
||||
}
|
||||
ExprKind::WhileLet(_, _, _, Some(ident)) | ExprKind::ForLoop(_, _, _, Some(ident)) |
|
||||
ExprKind::Break(Some(ident)) | ExprKind::Again(Some(ident)) => {
|
||||
self.check_label(ident.node, ident.span, expr.id);
|
||||
}
|
||||
@ -169,5 +167,5 @@ impl<'a, 'v> Visitor<'v> for SanityChecker<'a> {
|
||||
}
|
||||
|
||||
pub fn check_crate(session: &Session, krate: &Crate) {
|
||||
visit::walk_crate(&mut SanityChecker { session: session }, krate)
|
||||
visit::walk_crate(&mut AstValidator { session: session }, krate)
|
||||
}
|
@ -37,7 +37,7 @@ extern crate rustc_const_math;
|
||||
|
||||
pub mod diagnostics;
|
||||
|
||||
pub mod ast_sanity;
|
||||
pub mod ast_validation;
|
||||
pub mod consts;
|
||||
pub mod loops;
|
||||
pub mod no_asm;
|
||||
|
1
src/rustc/Cargo.lock
generated
1
src/rustc/Cargo.lock
generated
@ -246,7 +246,6 @@ dependencies = [
|
||||
name = "rustc_privacy"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"log 0.0.0",
|
||||
"rustc 0.0.0",
|
||||
"syntax 0.0.0",
|
||||
]
|
||||
|
@ -9,8 +9,15 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(unused_imports, dead_code)]
|
||||
|
||||
struct S;
|
||||
struct Z;
|
||||
|
||||
mod foo {
|
||||
use ::super::{S, Z}; //~ WARN global paths cannot start with `super`
|
||||
//~^ WARN this was previously accepted by the compiler but is being phased out
|
||||
|
||||
pub fn g() {
|
||||
use ::super::main; //~ WARN global paths cannot start with `super`
|
||||
//~^ WARN this was previously accepted by the compiler but is being phased out
|
||||
|
Loading…
x
Reference in New Issue
Block a user