panic!("explicit panic")
);
($msg:expr) => ({
- static _MSG_FILE_LINE: (&'static str, &'static str, usize) =
- ($msg, file!(), line!() as usize);
+ #[cfg(stage0)]
+ static _MSG_FILE_LINE: (&'static str, &'static str, usize) = ($msg, file!(), line!());
+ #[cfg(not(stage0))]
+ static _MSG_FILE_LINE: (&'static str, &'static str, u32) = ($msg, file!(), line!());
::core::panicking::panic(&_MSG_FILE_LINE)
});
($fmt:expr, $($arg:tt)*) => ({
// used inside a dead function. Just `#[allow(dead_code)]` is
// insufficient, since the user may have
// `#[forbid(dead_code)]` and which cannot be overridden.
- static _FILE_LINE: (&'static str, usize) = (file!(), line!() as usize);
+ #[cfg(stage0)]
+ static _FILE_LINE: (&'static str, usize) = (file!(), line!());
+ #[cfg(not(stage0))]
+ static _FILE_LINE: (&'static str, u32) = (file!(), line!());
::core::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE)
});
}
#[cold] #[inline(never)] // this is the slow path, always
#[lang="panic"]
-pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
+#[cfg(stage0)]
+pub fn panic(expr_file_line: &(&'static str, &'static str, usize)) -> ! {
+ let (expr, file, line) = *expr_file_line;
+ panic_fmt(format_args!("{}", expr), &(file, line))
+}
+#[cold] #[inline(never)] // this is the slow path, always
+#[lang="panic"]
+#[cfg(not(stage0))]
+pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! {
let (expr, file, line) = *expr_file_line;
panic_fmt(format_args!("{}", expr), &(file, line))
}
#[cold] #[inline(never)]
#[lang="panic_bounds_check"]
-fn panic_bounds_check(file_line: &(&'static str, uint),
- index: uint, len: uint) -> ! {
+#[cfg(stage0)]
+fn panic_bounds_check(file_line: &(&'static str, usize),
+ index: usize, len: usize) -> ! {
+ panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}",
+ len, index), file_line)
+}
+#[cold] #[inline(never)]
+#[lang="panic_bounds_check"]
+#[cfg(not(stage0))]
+fn panic_bounds_check(file_line: &(&'static str, u32),
+ index: usize, len: usize) -> ! {
panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}",
len, index), file_line)
}
#[cold] #[inline(never)]
-pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
+#[cfg(stage0)]
+pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, usize)) -> ! {
+ #[allow(improper_ctypes)]
+ extern {
+ #[lang = "panic_fmt"]
+ fn panic_impl(fmt: fmt::Arguments, file: &'static str, line: uint) -> !;
+ }
+ let (file, line) = *file_line;
+ unsafe { panic_impl(fmt, file, line as uint) }
+}
+#[cold] #[inline(never)]
+#[cfg(not(stage0))]
+pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, u32)) -> ! {
#[allow(improper_ctypes)]
extern {
#[lang = "panic_fmt"]
fn panic_impl(fmt: fmt::Arguments, file: &'static str, line: uint) -> !;
}
let (file, line) = *file_line;
- unsafe { panic_impl(fmt, file, line) }
+ unsafe { panic_impl(fmt, file, line as uint) }
}
pub file: &'a str,
/// The line number of where the LogRecord originated.
- pub line: uint,
+ pub line: u32,
}
#[doc(hidden)]
pub struct LogLocation {
pub module_path: &'static str,
pub file: &'static str,
- pub line: uint,
+ pub line: u32,
}
/// Tests whether a given module's name is enabled for a particular level of
#[macro_export]
macro_rules! log {
($lvl:expr, $($arg:tt)+) => ({
+ #[cfg(stage0)]
static LOC: ::log::LogLocation = ::log::LogLocation {
- line: line!() as usize,
+ line: line!() as u32,
+ file: file!(),
+ module_path: module_path!(),
+ };
+ #[cfg(not(stage0))]
+ static LOC: ::log::LogLocation = ::log::LogLocation {
+ line: line!(),
file: file!(),
module_path: module_path!(),
};
C_integral(Type::i32(ccx), i as u64, true)
}
+pub fn C_u32(ccx: &CrateContext, i: u32) -> ValueRef {
+ C_integral(Type::i32(ccx), i as u64, false)
+}
+
pub fn C_u64(ccx: &CrateContext, i: u64) -> ValueRef {
C_integral(Type::i64(ccx), i, false)
}
let loc = bcx.sess().codemap().lookup_char_pos(call_info.span.lo);
let filename = token::intern_and_get_ident(&loc.file.name[]);
let filename = C_str_slice(ccx, filename);
- let line = C_uint(ccx, loc.line);
+ let line = C_u32(ccx, loc.line as u32);
let expr_file_line_const = C_struct(ccx, &[v_str, filename, line], false);
let expr_file_line = consts::addr_of(ccx, expr_file_line_const,
"panic_loc", call_info.id);
// Invoke the lang item
let filename = C_str_slice(ccx, filename);
- let line = C_uint(ccx, loc.line);
+ let line = C_u32(ccx, loc.line as u32);
let file_line_const = C_struct(ccx, &[filename, line], false);
let file_line = consts::addr_of(ccx, file_line_const,
"panic_bounds_check_loc", call_info.id);
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr>;
fn expr_int(&self, sp: Span, i: isize) -> P<ast::Expr>;
+ fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr>;
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr>;
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr>;
self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs(false),
ast::Sign::new(i))))
}
+ fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
+ self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU8)))
+ }
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU32)))
}
{
assert!(file!().ends_with("includeme.fragment"));
- assert!(line!() == 5_u32);
+ assert!(line!() == 5u32);
format!("victory robot {}", line!())
}
pub fn main() {
assert_eq!(line!(), 25);
- assert!((column!() == 4_u32));
+ assert!((column!() == 4u32));
assert_eq!(indirect_line!(), 27);
assert!((file!().ends_with("syntax-extension-source-utils.rs")));
assert_eq!(stringify!((2*3) + 5).to_string(), "( 2 * 3 ) + 5".to_string());