Skip to content

Commit 731144b

Browse files
committed
sanity -> validation
Add test for `::super` in import prefix
1 parent c02c6e8 commit 731144b

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

src/librustc_driver/driver.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use rustc_privacy;
3838
use rustc_plugin::registry::Registry;
3939
use rustc_plugin as plugin;
4040
use rustc::hir::lowering::lower_crate;
41-
use rustc_passes::{ast_sanity, no_asm, loops, consts, rvalues, static_recursion};
41+
use rustc_passes::{ast_validation, no_asm, loops, consts, rvalues, static_recursion};
4242
use rustc_const_eval::check_match;
4343
use super::Compilation;
4444

@@ -167,8 +167,8 @@ pub fn compile_input(sess: &Session,
167167
|| lint::check_ast_crate(sess, &expanded_crate));
168168

169169
time(sess.time_passes(),
170-
"AST sanity checking",
171-
|| ast_sanity::check_crate(sess, &expanded_crate));
170+
"AST validation",
171+
|| ast_validation::check_crate(sess, &expanded_crate));
172172

173173
let (analysis, resolutions, mut hir_forest) = {
174174
lower_and_resolve(sess, &id, &mut defs, &expanded_crate,

src/librustc_passes/ast_sanity.rs renamed to src/librustc_passes/ast_validation.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Sanity check AST before lowering it to HIR
11+
// Validate AST before lowering it to HIR
1212
//
1313
// This pass is supposed to catch things that fit into AST data structures,
1414
// but not permitted by the language. It runs after expansion when AST is frozen,
@@ -24,11 +24,11 @@ use syntax::errors;
2424
use syntax::parse::token::{self, keywords};
2525
use syntax::visit::{self, Visitor};
2626

27-
struct SanityChecker<'a> {
27+
struct AstValidator<'a> {
2828
session: &'a Session,
2929
}
3030

31-
impl<'a> SanityChecker<'a> {
31+
impl<'a> AstValidator<'a> {
3232
fn err_handler(&self) -> &errors::Handler {
3333
&self.session.parse_sess.span_diagnostic
3434
}
@@ -57,7 +57,7 @@ impl<'a> SanityChecker<'a> {
5757
}
5858
}
5959

60-
impl<'a, 'v> Visitor<'v> for SanityChecker<'a> {
60+
impl<'a, 'v> Visitor<'v> for AstValidator<'a> {
6161
fn visit_lifetime(&mut self, lt: &Lifetime) {
6262
if lt.name.as_str() == "'_" {
6363
self.session.add_lint(
@@ -72,9 +72,7 @@ impl<'a, 'v> Visitor<'v> for SanityChecker<'a> {
7272
fn visit_expr(&mut self, expr: &Expr) {
7373
match expr.node {
7474
ExprKind::While(_, _, Some(ident)) | ExprKind::Loop(_, Some(ident)) |
75-
ExprKind::WhileLet(_, _, _, Some(ident)) | ExprKind::ForLoop(_, _, _, Some(ident)) => {
76-
self.check_label(ident, expr.span, expr.id);
77-
}
75+
ExprKind::WhileLet(_, _, _, Some(ident)) | ExprKind::ForLoop(_, _, _, Some(ident)) |
7876
ExprKind::Break(Some(ident)) | ExprKind::Again(Some(ident)) => {
7977
self.check_label(ident.node, ident.span, expr.id);
8078
}
@@ -169,5 +167,5 @@ impl<'a, 'v> Visitor<'v> for SanityChecker<'a> {
169167
}
170168

171169
pub fn check_crate(session: &Session, krate: &Crate) {
172-
visit::walk_crate(&mut SanityChecker { session: session }, krate)
170+
visit::walk_crate(&mut AstValidator { session: session }, krate)
173171
}

src/librustc_passes/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extern crate rustc_const_math;
3737

3838
pub mod diagnostics;
3939

40-
pub mod ast_sanity;
40+
pub mod ast_validation;
4141
pub mod consts;
4242
pub mod loops;
4343
pub mod no_asm;

src/rustc/Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/compile-fail/use-super-global-path.rs

+7
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@
99
// except according to those terms.
1010

1111
#![feature(rustc_attrs)]
12+
#![allow(unused_imports, dead_code)]
13+
14+
struct S;
15+
struct Z;
1216

1317
mod foo {
18+
use ::super::{S, Z}; //~ WARN global paths cannot start with `super`
19+
//~^ WARN this was previously accepted by the compiler but is being phased out
20+
1421
pub fn g() {
1522
use ::super::main; //~ WARN global paths cannot start with `super`
1623
//~^ WARN this was previously accepted by the compiler but is being phased out

0 commit comments

Comments
 (0)