about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2015-09-19 00:42:57 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2015-09-19 17:04:27 +0200
commit1adcfb8c13a2c224ae78178350de2e0fba8291c4 (patch)
treea706e5fdacfc709e65d160477160d71e5ce6becf /src
parent7badafa593400b272ff05efd26a8fabb5c9d4cdd (diff)
downloadrust-1adcfb8c13a2c224ae78178350de2e0fba8291c4.tar.gz
rust-1adcfb8c13a2c224ae78178350de2e0fba8291c4.zip
Add librustc_trans error codes
Diffstat (limited to 'src')
-rw-r--r--src/librustc_borrowck/diagnostics.rs2
-rw-r--r--src/librustc_trans/diagnostics.rs21
-rw-r--r--src/librustc_trans/lib.rs2
-rw-r--r--src/librustc_trans/trans/intrinsic.rs32
4 files changed, 45 insertions, 12 deletions
diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs
index 2ae998841d9..a5b313e2dd6 100644
--- a/src/librustc_borrowck/diagnostics.rs
+++ b/src/librustc_borrowck/diagnostics.rs
@@ -289,7 +289,7 @@ let mut x = &mut i; // ok!
 let mut i = 0;
 let a = &i; // ok!
 let b = &i; // still ok!
-let c = &i; // super still ok!
+let c = &i; // still ok!
 ```
 "##,
 
diff --git a/src/librustc_trans/diagnostics.rs b/src/librustc_trans/diagnostics.rs
new file mode 100644
index 00000000000..dd7c3834e56
--- /dev/null
+++ b/src/librustc_trans/diagnostics.rs
@@ -0,0 +1,21 @@
+// 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.
+
+#![allow(non_snake_case)]
+
+register_long_diagnostics! {
+
+}
+
+register_diagnostics! {
+    E0510, // invalid use of `return_address` intrinsic: function does not use out pointer
+    E0511, // invalid monomorphization of `{}` intrinsic
+    E0512, // transmute called on types with potentially different sizes...
+}
diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs
index a7fb3af1384..049d8fbe390 100644
--- a/src/librustc_trans/lib.rs
+++ b/src/librustc_trans/lib.rs
@@ -80,6 +80,8 @@ pub mod back {
     pub mod msvc;
 }
 
+pub mod diagnostics;
+
 pub mod trans;
 pub mod save;
 
diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs
index bcfd44d8835..b43a4b3fc88 100644
--- a/src/librustc_trans/trans/intrinsic.rs
+++ b/src/librustc_trans/trans/intrinsic.rs
@@ -44,6 +44,9 @@ use syntax::ast;
 use syntax::ptr::P;
 use syntax::parse::token;
 
+use rustc::session::Session;
+use syntax::codemap::Span;
+
 use std::cmp::Ordering;
 
 pub fn get_simple_intrinsic(ccx: &CrateContext, item: &hir::ForeignItem) -> Option<ValueRef> {
@@ -99,6 +102,10 @@ pub fn get_simple_intrinsic(ccx: &CrateContext, item: &hir::ForeignItem) -> Opti
     Some(ccx.get_intrinsic(&name))
 }
 
+pub fn span_transmute_size_error(a: &Session, b: Span, msg: &str) {
+    span_err!(a, b, E0512, "{}", msg);
+}
+
 /// Performs late verification that intrinsics are used correctly. At present,
 /// the only intrinsic that needs such verification is `transmute`.
 pub fn check_intrinsics(ccx: &CrateContext) {
@@ -127,8 +134,7 @@ pub fn check_intrinsics(ccx: &CrateContext) {
             last_failing_id = Some(transmute_restriction.id);
 
             if transmute_restriction.original_from != transmute_restriction.substituted_from {
-                ccx.sess().span_err(
-                    transmute_restriction.span,
+                span_transmute_size_error(ccx.sess(), transmute_restriction.span,
                     &format!("transmute called on types with potentially different sizes: \
                               {} (could be {} bit{}) to {} (could be {} bit{})",
                              transmute_restriction.original_from,
@@ -138,8 +144,7 @@ pub fn check_intrinsics(ccx: &CrateContext) {
                              to_type_size as usize,
                              if to_type_size == 1 {""} else {"s"}));
             } else {
-                ccx.sess().span_err(
-                    transmute_restriction.span,
+                span_transmute_size_error(ccx.sess(), transmute_restriction.span,
                     &format!("transmute called on types with different sizes: \
                               {} ({} bit{}) to {} ({} bit{})",
                              transmute_restriction.original_from,
@@ -798,9 +803,9 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
 
         (_, "return_address") => {
             if !fcx.caller_expects_out_pointer {
-                tcx.sess.span_err(call_info.span,
-                                  "invalid use of `return_address` intrinsic: function \
-                                   does not use out pointer");
+                span_err!(tcx.sess, call_info.span, E0510,
+                          "invalid use of `return_address` intrinsic: function \
+                           does not use out pointer");
                 C_null(Type::i8p(ccx))
             } else {
                 PointerCast(bcx, llvm::get_param(fcx.llfn, 0), Type::i8p(ccx))
@@ -1439,6 +1444,10 @@ fn get_rust_try_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
     return rust_try
 }
 
+fn span_invalid_monomorphization_error(a: &Session, b: Span, c: &str) {
+    span_err!(a, b, E0511, "{}", c);
+}
+
 fn generic_simd_intrinsic<'blk, 'tcx, 'a>
     (bcx: Block<'blk, 'tcx>,
      name: &str,
@@ -1457,10 +1466,11 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
             emit_error!($msg, )
         };
         ($msg: tt, $($fmt: tt)*) => {
-            bcx.sess().span_err(call_info.span,
-                                &format!(concat!("invalid monomorphization of `{}` intrinsic: ",
-                                                 $msg),
-                                         name, $($fmt)*));
+            span_invalid_monomorphization_error(
+                bcx.sess(), call_info.span,
+                &format!(concat!("invalid monomorphization of `{}` intrinsic: ",
+                                 $msg),
+                         name, $($fmt)*));
         }
     }
     macro_rules! require {