Skip to content

Commit a8ecf21

Browse files
committed
---
yaml --- r: 127674 b: refs/heads/snap-stage3 c: 07aadc2 h: refs/heads/master v: v3
1 parent 4a36de2 commit a8ecf21

File tree

7 files changed

+76
-13
lines changed

7 files changed

+76
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 49a970f2449a78f28b6c301e542d38593094ca77
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: f3d88c320d4b08e5534f2193462e6a20e27b1d85
4+
refs/heads/snap-stage3: 07aadc2e8b1923b28595393922a816e46d3903f4
55
refs/heads/try: d9c23fcbaea89871667272a67ecb8d3a512162f3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/macros.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ macro_rules! fail(
3131
// because it's just a tiny wrapper. Small wins (156K to 149K in size)
3232
// were seen when forcing this to be inlined, and that number just goes
3333
// up with the number of calls to fail!()
34+
//
35+
// The leading _'s are to avoid dead code warnings if this is
36+
// used inside a dead function. Just `#[allow(dead_code)]` is
37+
// insufficient, since the user may have
38+
// `#[forbid(dead_code)]` and which cannot be overridden.
3439
#[inline(always)]
35-
fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
36-
static FILE_LINE: (&'static str, uint) = (file!(), line!());
37-
::core::failure::begin_unwind(fmt, &FILE_LINE)
40+
fn _run_fmt(fmt: &::std::fmt::Arguments) -> ! {
41+
static _FILE_LINE: (&'static str, uint) = (file!(), line!());
42+
::core::failure::begin_unwind(fmt, &_FILE_LINE)
3843
}
39-
format_args!(run_fmt, $fmt, $($arg)*)
44+
format_args!(_run_fmt, $fmt, $($arg)*)
4045
});
4146
)
4247

branches/snap-stage3/src/librustc/middle/dead.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use syntax::ast_util::{local_def, is_local, PostExpansionMethod};
2626
use syntax::attr::AttrMetaMethods;
2727
use syntax::attr;
2828
use syntax::codemap;
29-
use syntax::parse::token;
3029
use syntax::visit::Visitor;
3130
use syntax::visit;
3231

branches/snap-stage3/src/libstd/macros.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ macro_rules! fail(
4343
});
4444
($msg:expr) => ({
4545
// static requires less code at runtime, more constant data
46-
static FILE_LINE: (&'static str, uint) = (file!(), line!());
47-
::std::rt::begin_unwind($msg, &FILE_LINE)
46+
static _FILE_LINE: (&'static str, uint) = (file!(), line!());
47+
::std::rt::begin_unwind($msg, &_FILE_LINE)
4848
});
4949
($fmt:expr, $($arg:tt)*) => ({
5050
// a closure can't have return type !, so we need a full
@@ -58,12 +58,17 @@ macro_rules! fail(
5858
// because it's just a tiny wrapper. Small wins (156K to 149K in size)
5959
// were seen when forcing this to be inlined, and that number just goes
6060
// up with the number of calls to fail!()
61+
//
62+
// The leading _'s are to avoid dead code warnings if this is
63+
// used inside a dead function. Just `#[allow(dead_code)]` is
64+
// insufficient, since the user may have
65+
// `#[forbid(dead_code)]` and which cannot be overridden.
6166
#[inline(always)]
62-
fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
63-
static FILE_LINE: (&'static str, uint) = (file!(), line!());
64-
::std::rt::begin_unwind_fmt(fmt, &FILE_LINE)
67+
fn _run_fmt(fmt: &::std::fmt::Arguments) -> ! {
68+
static _FILE_LINE: (&'static str, uint) = (file!(), line!());
69+
::std::rt::begin_unwind_fmt(fmt, &_FILE_LINE)
6570
}
66-
format_args!(run_fmt, $fmt, $($arg)*)
71+
format_args!(_run_fmt, $fmt, $($arg)*)
6772
});
6873
)
6974

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(phase)]
12+
#![deny(dead_code)]
13+
#![allow(unreachable_code)]
14+
15+
#[phase(link, plugin)] extern crate core;
16+
17+
18+
fn foo() { //~ ERROR code is never used
19+
20+
// none of these should have any dead_code exposed to the user
21+
fail!();
22+
23+
fail!("foo");
24+
25+
fail!("bar {}", "baz")
26+
}
27+
28+
29+
fn main() {}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![deny(dead_code)]
12+
#![allow(unreachable_code)]
13+
14+
fn foo() { //~ ERROR code is never used
15+
16+
// none of these should have any dead_code exposed to the user
17+
fail!();
18+
19+
fail!("foo");
20+
21+
fail!("bar {}", "baz")
22+
}
23+
24+
25+
fn main() {}

branches/snap-stage3/src/test/run-pass/dead-code-leading-underscore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ extern {
3535
fn _abort() -> !;
3636
}
3737

38-
fn main() {}
38+
pub fn main() {}

0 commit comments

Comments
 (0)