Avoid calling the column!() macro in panic
This commit is contained in:
@@ -8,6 +8,16 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
// This stability attribute is totally useless.
|
||||||
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[cfg(stage0)]
|
||||||
|
macro_rules! __rust_unstable_column {
|
||||||
|
() => {
|
||||||
|
column!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Entry point of thread panic, for details, see std::macros
|
/// Entry point of thread panic, for details, see std::macros
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[allow_internal_unstable]
|
#[allow_internal_unstable]
|
||||||
@@ -18,7 +28,7 @@ macro_rules! panic {
|
|||||||
);
|
);
|
||||||
($msg:expr) => ({
|
($msg:expr) => ({
|
||||||
static _MSG_FILE_LINE_COL: (&'static str, &'static str, u32, u32) =
|
static _MSG_FILE_LINE_COL: (&'static str, &'static str, u32, u32) =
|
||||||
($msg, file!(), line!(), column!());
|
($msg, file!(), line!(), __rust_unstable_column!());
|
||||||
$crate::panicking::panic(&_MSG_FILE_LINE_COL)
|
$crate::panicking::panic(&_MSG_FILE_LINE_COL)
|
||||||
});
|
});
|
||||||
($fmt:expr, $($arg:tt)*) => ({
|
($fmt:expr, $($arg:tt)*) => ({
|
||||||
@@ -27,7 +37,7 @@ macro_rules! panic {
|
|||||||
// insufficient, since the user may have
|
// insufficient, since the user may have
|
||||||
// `#[forbid(dead_code)]` and which cannot be overridden.
|
// `#[forbid(dead_code)]` and which cannot be overridden.
|
||||||
static _MSG_FILE_LINE_COL: (&'static str, u32, u32) =
|
static _MSG_FILE_LINE_COL: (&'static str, u32, u32) =
|
||||||
(file!(), line!(), column!());
|
(file!(), line!(), __rust_unstable_column!());
|
||||||
$crate::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_MSG_FILE_LINE_COL)
|
$crate::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_MSG_FILE_LINE_COL)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,16 @@
|
|||||||
//! library. Each macro is available for use when linking against the standard
|
//! library. Each macro is available for use when linking against the standard
|
||||||
//! library.
|
//! library.
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
// This stability attribute is totally useless.
|
||||||
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[cfg(stage0)]
|
||||||
|
macro_rules! __rust_unstable_column {
|
||||||
|
() => {
|
||||||
|
column!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The entry point for panic of Rust threads.
|
/// The entry point for panic of Rust threads.
|
||||||
///
|
///
|
||||||
/// This macro is used to inject panic into a Rust thread, causing the thread to
|
/// This macro is used to inject panic into a Rust thread, causing the thread to
|
||||||
@@ -48,7 +58,8 @@ macro_rules! panic {
|
|||||||
($msg:expr) => ({
|
($msg:expr) => ({
|
||||||
$crate::rt::begin_panic($msg, {
|
$crate::rt::begin_panic($msg, {
|
||||||
// static requires less code at runtime, more constant data
|
// static requires less code at runtime, more constant data
|
||||||
static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(), column!());
|
static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(),
|
||||||
|
__rust_unstable_column!());
|
||||||
&_FILE_LINE_COL
|
&_FILE_LINE_COL
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -58,7 +69,8 @@ macro_rules! panic {
|
|||||||
// used inside a dead function. Just `#[allow(dead_code)]` is
|
// used inside a dead function. Just `#[allow(dead_code)]` is
|
||||||
// insufficient, since the user may have
|
// insufficient, since the user may have
|
||||||
// `#[forbid(dead_code)]` and which cannot be overridden.
|
// `#[forbid(dead_code)]` and which cannot be overridden.
|
||||||
static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(), column!());
|
static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(),
|
||||||
|
__rust_unstable_column!());
|
||||||
&_FILE_LINE_COL
|
&_FILE_LINE_COL
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ pub fn register_builtins(resolver: &mut syntax::ext::base::Resolver,
|
|||||||
use syntax::ext::source_util::*;
|
use syntax::ext::source_util::*;
|
||||||
register! {
|
register! {
|
||||||
line: expand_line,
|
line: expand_line,
|
||||||
|
__rust_unstable_column: expand_column,
|
||||||
column: expand_column,
|
column: expand_column,
|
||||||
file: expand_file,
|
file: expand_file,
|
||||||
stringify: expand_stringify,
|
stringify: expand_stringify,
|
||||||
|
|||||||
23
src/test/run-pass/issue-43057.rs
Normal file
23
src/test/run-pass/issue-43057.rs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2017 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(unused)]
|
||||||
|
|
||||||
|
macro_rules! column {
|
||||||
|
($i:ident) => {
|
||||||
|
$i
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo() -> ! {
|
||||||
|
panic!();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
Reference in New Issue
Block a user