about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-01-13 23:13:49 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-01-13 23:35:11 +0300
commit318cf22bd1955ba870a0a3189cb5dfdbce31b53e (patch)
tree78d8ecc32c4f981040c66a31830c8869f6a02243
parente6072a7b3835f1875e81c9fd27799f9b20a0770c (diff)
downloadrust-318cf22bd1955ba870a0a3189cb5dfdbce31b53e.tar.gz
rust-318cf22bd1955ba870a0a3189cb5dfdbce31b53e.zip
Move "no asm" check into AST validation
-rw-r--r--src/librustc_driver/driver.rs6
-rw-r--r--src/librustc_passes/ast_validation.rs3
-rw-r--r--src/librustc_passes/lib.rs1
-rw-r--r--src/librustc_passes/no_asm.rs47
4 files changed, 4 insertions, 53 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index b7265762208..75a7f990841 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -37,7 +37,7 @@ use rustc_typeck as typeck;
 use rustc_privacy;
 use rustc_plugin::registry::Registry;
 use rustc_plugin as plugin;
-use rustc_passes::{self, ast_validation, no_asm, loops, consts, static_recursion, hir_stats};
+use rustc_passes::{self, ast_validation, loops, consts, static_recursion, hir_stats};
 use rustc_const_eval::{self, check_match};
 use super::Compilation;
 use ::DefaultTransCrate;
@@ -857,10 +857,6 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
     }
 
     time(time_passes,
-         "checking for inline asm in case the target doesn't support it",
-         || no_asm::check_crate(sess, &krate));
-
-    time(time_passes,
          "AST validation",
          || ast_validation::check_crate(sess, &krate));
 
diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs
index 61f54774163..dbad82ed977 100644
--- a/src/librustc_passes/ast_validation.rs
+++ b/src/librustc_passes/ast_validation.rs
@@ -149,6 +149,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
             ExprKind::Continue(Some(ident)) => {
                 self.check_label(ident.node, ident.span);
             }
+            ExprKind::InlineAsm(..) if !self.session.target.target.options.allow_asm => {
+                span_err!(self.session, expr.span, E0472, "asm! is unsupported on this target");
+            }
             _ => {}
         }
 
diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs
index 754c3bbd074..73c71ec0b2f 100644
--- a/src/librustc_passes/lib.rs
+++ b/src/librustc_passes/lib.rs
@@ -42,7 +42,6 @@ pub mod consts;
 pub mod hir_stats;
 pub mod loops;
 mod mir_stats;
-pub mod no_asm;
 pub mod static_recursion;
 
 #[cfg(not(stage0))] // remove after the next snapshot
diff --git a/src/librustc_passes/no_asm.rs b/src/librustc_passes/no_asm.rs
deleted file mode 100644
index 4dbf57a99bc..00000000000
--- a/src/librustc_passes/no_asm.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/// Run over the whole crate and check for ExprInlineAsm.
-/// Inline asm isn't allowed on virtual ISA based targets, so we reject it
-/// here.
-
-use rustc::session::Session;
-
-use syntax::ast;
-use syntax::visit::Visitor;
-use syntax::visit;
-
-pub fn check_crate(sess: &Session, krate: &ast::Crate) {
-    if sess.target.target.options.allow_asm {
-        return;
-    }
-
-    visit::walk_crate(&mut CheckNoAsm { sess: sess }, krate);
-}
-
-#[derive(Copy, Clone)]
-struct CheckNoAsm<'a> {
-    sess: &'a Session,
-}
-
-impl<'a> Visitor<'a> for CheckNoAsm<'a> {
-    fn visit_expr(&mut self, e: &'a ast::Expr) {
-        match e.node {
-            ast::ExprKind::InlineAsm(_) => {
-                span_err!(self.sess,
-                          e.span,
-                          E0472,
-                          "asm! is unsupported on this target")
-            }
-            _ => {}
-        }
-        visit::walk_expr(self, e)
-    }
-}