Skip to content

Commit 60ffbad

Browse files
committed
---
yaml --- r: 127676 b: refs/heads/snap-stage3 c: 81241dc h: refs/heads/master v: v3
1 parent 6740712 commit 60ffbad

File tree

8 files changed

+36
-124
lines changed

8 files changed

+36
-124
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: 5e720f0e5453e7b113f313df7827f3ad0a6dbe46
4+
refs/heads/snap-stage3: 81241dce8036c6e84e5640c179f53bf8cfc038a6
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: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,12 @@ 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.
3934
#[inline(always)]
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)
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)
4338
}
44-
format_args!(_run_fmt, $fmt, $($arg)*)
39+
format_args!(run_fmt, $fmt, $($arg)*)
4540
});
4641
)
4742

branches/snap-stage3/src/liblog/directive.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn parse_logging_spec(spec: &str) -> Vec<LogDirective> {
3838
for s in spec.split(',') {
3939
if s.len() == 0 { continue }
4040
let mut parts = s.split('=');
41-
let (log_level, name) = match (parts.next(), parts.next(), parts.next()) {
41+
let (log_level, name) = match (parts.next(), parts.next().map(|s| s.trim()), parts.next()) {
4242
(Some(part0), None, None) => {
4343
// if the single argument is a log-level string or number,
4444
// treat that as a global fallback
@@ -47,6 +47,7 @@ pub fn parse_logging_spec(spec: &str) -> Vec<LogDirective> {
4747
None => (::MAX_LOG_LEVEL, Some(part0)),
4848
}
4949
}
50+
(Some(part0), Some(""), None) => (::MAX_LOG_LEVEL, Some(part0)),
5051
(Some(part0), Some(part1), None) => {
5152
match parse_log_level(part1) {
5253
Some(num) => (num, Some(part0)),
@@ -120,6 +121,16 @@ mod tests {
120121
assert_eq!(dirs[0].level, ::WARN);
121122
}
122123

124+
#[test]
125+
fn parse_logging_spec_empty_log_level() {
126+
// test parse_logging_spec with '' as log level
127+
let dirs = parse_logging_spec("crate1::mod1=wrong,crate2=");
128+
let dirs = dirs.as_slice();
129+
assert_eq!(dirs.len(), 1);
130+
assert_eq!(dirs[0].name, Some("crate2".to_string()));
131+
assert_eq!(dirs[0].level, ::MAX_LOG_LEVEL);
132+
}
133+
123134
#[test]
124135
fn parse_logging_spec_global() {
125136
// test parse_logging_spec with no crate

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ 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;
2930
use syntax::visit::Visitor;
3031
use syntax::visit;
3132

@@ -411,14 +412,18 @@ struct DeadVisitor<'a> {
411412

412413
impl<'a> DeadVisitor<'a> {
413414
fn should_warn_about_field(&mut self, node: &ast::StructField_) -> bool {
414-
let is_named = node.ident().is_some();
415+
let (is_named, has_leading_underscore) = match node.ident() {
416+
Some(ref ident) => (true, token::get_ident(*ident).get().as_bytes()[0] == ('_' as u8)),
417+
_ => (false, false)
418+
};
415419
let field_type = ty::node_id_to_type(self.tcx, node.id);
416420
let is_marker_field = match ty::ty_to_def_id(field_type) {
417421
Some(def_id) => self.tcx.lang_items.items().any(|(_, item)| *item == Some(def_id)),
418422
_ => false
419423
};
420424
is_named
421425
&& !self.symbol_is_live(node.id, None)
426+
&& !has_leading_underscore
422427
&& !is_marker_field
423428
&& !has_allow_dead_code_or_lang_attr(node.attrs.as_slice())
424429
}
@@ -463,15 +468,13 @@ impl<'a> DeadVisitor<'a> {
463468
id: ast::NodeId,
464469
span: codemap::Span,
465470
ident: ast::Ident) {
466-
let name = ident.as_str();
467-
if !name.starts_with("_") {
468-
self.tcx
469-
.sess
470-
.add_lint(lint::builtin::DEAD_CODE,
471-
id,
472-
span,
473-
format!("code is never used: `{}`", name));
474-
}
471+
self.tcx
472+
.sess
473+
.add_lint(lint::builtin::DEAD_CODE,
474+
id,
475+
span,
476+
format!("code is never used: `{}`",
477+
token::get_ident(ident)));
475478
}
476479
}
477480

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

Lines changed: 6 additions & 11 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,17 +58,12 @@ 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.
6661
#[inline(always)]
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)
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)
7065
}
71-
format_args!(_run_fmt, $fmt, $($arg)*)
66+
format_args!(run_fmt, $fmt, $($arg)*)
7267
});
7368
)
7469

branches/snap-stage3/src/test/compile-fail/fail-no-dead-code-core.rs

Lines changed: 0 additions & 29 deletions
This file was deleted.

branches/snap-stage3/src/test/compile-fail/fail-no-dead-code.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)