Skip to content

Commit 4c53ad9

Browse files
committed
---
yaml --- r: 144859 b: refs/heads/try2 c: 3eaf750 h: refs/heads/master i: 144857: 90c13ef 144855: 76ddf2e v: v3
1 parent 3bb340f commit 4c53ad9

File tree

6 files changed

+56
-158
lines changed

6 files changed

+56
-158
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 82b6ef66c22ac876cfc319eae7010648468919b9
8+
refs/heads/try2: 3eaf750a0de8acd5662d725b651e366fb703e5fa
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3385,11 +3385,9 @@ The path to a module consists of the crate name, any parent modules,
33853385
then the module itself, all separated by double colons (`::`). The
33863386
optional log level can be appended to the module path with an equals
33873387
sign (`=`) followed by the log level, from 1 to 4, inclusive. Level 1
3388-
is the error level, 2 is warning, 3 info, and 4 debug. You can also
3389-
use the symbolic constants `error`, `warn`, `info`, and `debug`. Any
3390-
logs less than or equal to the specified level will be output. If not
3391-
specified then log level 4 is assumed. However, debug messages are
3392-
only available if `--cfg=debug` is passed to `rustc`.
3388+
is the error level, 2 is warning, 3 info, and 4 debug. Any logs
3389+
less than or equal to the specified level will be output. If not
3390+
specified then log level 4 is assumed.
33933391

33943392
As an example, to see all the logs generated by the compiler, you would set
33953393
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `link`

branches/try2/mk/rt.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export PYTHONPATH := $(PYTHONPATH):$$(S)src/gyp/pylib
178178

179179
$$(LIBUV_MAKEFILE_$(1)_$(2)):
180180
(cd $(S)src/libuv/ && \
181-
$$(CFG_PYTHON) ./gyp_uv -f make -Dtarget_arch=$$(LIBUV_ARCH_$(1)) -D ninja \
181+
./gyp_uv -f make -Dtarget_arch=$$(LIBUV_ARCH_$(1)) -D ninja \
182182
-Goutput_dir=$$(@D) --generator-output $$(@D))
183183

184184
# XXX: Shouldn't need platform-specific conditions here

branches/try2/src/libextra/uuid.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl Uuid {
210210
///
211211
/// # Arguments
212212
/// * `b` An array or slice of 16 bytes
213-
pub fn from_utf8(b: &[u8]) -> Option<Uuid> {
213+
pub fn from_bytes(b: &[u8]) -> Option<Uuid> {
214214
if b.len() != 16 {
215215
return None
216216
}
@@ -413,7 +413,7 @@ impl Uuid {
413413
ub[i] = FromStrRadix::from_str_radix(vs.slice(i*2, (i+1)*2), 16).unwrap();
414414
}
415415

416-
Ok(Uuid::from_utf8(ub).unwrap())
416+
Ok(Uuid::from_bytes(ub).unwrap())
417417
}
418418
}
419419

@@ -705,11 +705,11 @@ mod test {
705705
}
706706

707707
#[test]
708-
fn test_from_utf8() {
708+
fn test_from_bytes() {
709709
let b = ~[ 0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2,
710710
0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 ];
711711

712-
let u = Uuid::from_utf8(b).unwrap();
712+
let u = Uuid::from_bytes(b).unwrap();
713713
let expected = ~"a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8";
714714

715715
assert!(u.to_simple_str() == expected);
@@ -729,7 +729,7 @@ mod test {
729729
let b_in: [u8, ..16] = [ 0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2,
730730
0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 ];
731731

732-
let u = Uuid::from_utf8(b_in.clone()).unwrap();
732+
let u = Uuid::from_bytes(b_in.clone()).unwrap();
733733

734734
let b_out = u.to_bytes();
735735

branches/try2/src/libstd/rt/logging.rs

Lines changed: 46 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use cast::transmute;
1111
use either::*;
1212
use libc::{c_void, uintptr_t, c_char, exit, STDERR_FILENO};
13-
use option::{Some, None, Option};
13+
use option::{Some, None};
1414
use rt::util::dumb_println;
1515
use str::StrSlice;
1616
use str::raw::from_c_str;
@@ -20,7 +20,7 @@ use vec::ImmutableVector;
2020

2121

2222
struct LogDirective {
23-
name: Option<~str>,
23+
name: ~str,
2424
level: u32
2525
}
2626

@@ -30,6 +30,7 @@ struct ModEntry{
3030
log_level: *mut u32
3131
}
3232

33+
static MAX_LOG_DIRECTIVES: u32 = 255;
3334
static MAX_LOG_LEVEL: u32 = 255;
3435
static DEFAULT_LOG_LEVEL: u32 = 1;
3536

@@ -67,82 +68,42 @@ fn iter_crate_map(map: *u8, f: &fn(*mut ModEntry)) {
6768
data: *c_void);
6869
}
6970
}
70-
static log_level_names : &'static[&'static str] = &'static["error", "warn", "info", "debug"];
71-
72-
/// Parse an individual log level that is either a number or a symbolic log level
73-
fn parse_log_level(level: &str) -> Option<u32> {
74-
let num = u32::from_str(level);
75-
let mut log_level;
76-
match num {
77-
Some(num) => {
78-
if num < MAX_LOG_LEVEL {
79-
log_level = Some(num);
80-
} else {
81-
log_level = Some(MAX_LOG_LEVEL);
82-
}
83-
}
84-
_ => {
85-
let position = log_level_names.iter().position(|&name| name == level);
86-
match position {
87-
Some(position) => {
88-
log_level = Some(u32::min(MAX_LOG_LEVEL, (position + 1) as u32))
89-
},
90-
_ => {
91-
log_level = None;
92-
}
93-
}
94-
}
95-
}
96-
log_level
97-
}
98-
9971

10072
/// Parse a logging specification string (e.g: "crate1,crate2::mod3,crate3::x=1")
10173
/// and return a vector with log directives.
102-
/// Valid log levels are 0-255, with the most likely ones being 1-4 (defined in std::).
103-
/// Also supports string log levels of error, warn, info, and debug
104-
74+
/// Valid log levels are 0-255, with the most likely ones being 0-3 (defined in std::).
10575
fn parse_logging_spec(spec: ~str) -> ~[LogDirective]{
10676
let mut dirs = ~[];
10777
for s in spec.split_iter(',') {
10878
let parts: ~[&str] = s.split_iter('=').collect();
109-
let mut log_level;
110-
let mut name = Some(parts[0].to_owned());
79+
let mut loglevel;
11180
match parts.len() {
112-
1 => {
113-
//if the single argument is a log-level string or number,
114-
//treat that as a global fallback
115-
let possible_log_level = parse_log_level(parts[0]);
116-
match possible_log_level {
117-
Some(num) => {
118-
name = None;
119-
log_level = num;
120-
},
121-
_ => {
122-
log_level = MAX_LOG_LEVEL
123-
}
124-
}
125-
}
81+
1 => loglevel = MAX_LOG_LEVEL,
12682
2 => {
127-
let possible_log_level = parse_log_level(parts[1]);
128-
match possible_log_level {
83+
let num = u32::from_str(parts[1]);
84+
match (num) {
12985
Some(num) => {
130-
log_level = num;
131-
},
86+
if num < MAX_LOG_LEVEL {
87+
loglevel = num;
88+
} else {
89+
loglevel = MAX_LOG_LEVEL;
90+
}
91+
}
13292
_ => {
133-
dumb_println(fmt!("warning: invalid logging spec \
134-
'%s', ignoring it", parts[1]));
135-
loop;
93+
dumb_println(fmt!("warning: invalid logging spec \
94+
'%s', ignoring it", s));
95+
loop;
13696
}
13797
}
98+
if loglevel > MAX_LOG_LEVEL { loglevel = MAX_LOG_LEVEL}
13899
},
139100
_ => {
140101
dumb_println(fmt!("warning: invalid logging spec '%s',\
141102
ignoring it", s));
142103
loop;
143104
}
144105
}
145-
let dir = LogDirective {name: name, level: log_level};
106+
let dir = LogDirective {name: parts[0].to_owned(), level: loglevel};
146107
dirs.push(dir);
147108
}
148109
return dirs;
@@ -152,30 +113,18 @@ fn parse_logging_spec(spec: ~str) -> ~[LogDirective]{
152113
/// of log directives
153114
fn update_entry(dirs: &[LogDirective], entry: *mut ModEntry) -> u32 {
154115
let mut new_lvl: u32 = DEFAULT_LOG_LEVEL;
155-
let mut longest_match = -1i;
116+
let mut longest_match = 0;
156117
unsafe {
157118
for dir in dirs.iter() {
158-
match dir.name {
159-
None => {
160-
if longest_match == -1 {
161-
longest_match = 0;
162-
new_lvl = dir.level;
163-
}
164-
}
165-
Some(ref dir_name) => {
166-
let name = from_c_str((*entry).name);
167-
let len = dir_name.len() as int;
168-
if name.starts_with(*dir_name) &&
169-
len >= longest_match {
170-
longest_match = len;
171-
new_lvl = dir.level;
172-
}
173-
}
174-
};
119+
let name = from_c_str((*entry).name);
120+
if name.starts_with(dir.name) && dir.name.len() > longest_match {
121+
longest_match = dir.name.len();
122+
new_lvl = dir.level;
123+
}
175124
}
176125
*(*entry).log_level = new_lvl;
177126
}
178-
if longest_match >= 0 { return 1; } else { return 0; }
127+
if longest_match > 0 { return 1; } else { return 0; }
179128
}
180129

181130
#[fixed_stack_segment] #[inline(never)]
@@ -289,66 +238,45 @@ extern {
289238
// Tests for parse_logging_spec()
290239
#[test]
291240
fn parse_logging_spec_valid() {
292-
let dirs = parse_logging_spec(~"crate1::mod1=1,crate1::mod2,crate2=4");
241+
let dirs: ~[LogDirective] = parse_logging_spec(~"crate1::mod1=1,crate1::mod2,crate2=4");
293242
assert_eq!(dirs.len(), 3);
294-
assert!(dirs[0].name == Some(~"crate1::mod1"));
243+
assert!(dirs[0].name == ~"crate1::mod1");
295244
assert_eq!(dirs[0].level, 1);
296245
297-
assert!(dirs[1].name == Some(~"crate1::mod2"));
246+
assert!(dirs[1].name == ~"crate1::mod2");
298247
assert_eq!(dirs[1].level, MAX_LOG_LEVEL);
299248
300-
assert!(dirs[2].name == Some(~"crate2"));
249+
assert!(dirs[2].name == ~"crate2");
301250
assert_eq!(dirs[2].level, 4);
302251
}
303252
304253
#[test]
305254
fn parse_logging_spec_invalid_crate() {
306255
// test parse_logging_spec with multiple = in specification
307-
let dirs = parse_logging_spec(~"crate1::mod1=1=2,crate2=4");
256+
let dirs: ~[LogDirective] = parse_logging_spec(~"crate1::mod1=1=2,crate2=4");
308257
assert_eq!(dirs.len(), 1);
309-
assert!(dirs[0].name == Some(~"crate2"));
258+
assert!(dirs[0].name == ~"crate2");
310259
assert_eq!(dirs[0].level, 4);
311260
}
312261
313262
#[test]
314263
fn parse_logging_spec_invalid_log_level() {
315264
// test parse_logging_spec with 'noNumber' as log level
316-
let dirs = parse_logging_spec(~"crate1::mod1=noNumber,crate2=4");
265+
let dirs: ~[LogDirective] = parse_logging_spec(~"crate1::mod1=noNumber,crate2=4");
317266
assert_eq!(dirs.len(), 1);
318-
assert!(dirs[0].name == Some(~"crate2"));
267+
assert!(dirs[0].name == ~"crate2");
319268
assert_eq!(dirs[0].level, 4);
320269
}
321270
322-
#[test]
323-
fn parse_logging_spec_string_log_level() {
324-
// test parse_logging_spec with 'warn' as log level
325-
let dirs = parse_logging_spec(~"crate1::mod1=wrong,crate2=warn");
326-
assert_eq!(dirs.len(), 1);
327-
assert!(dirs[0].name == Some(~"crate2"));
328-
assert_eq!(dirs[0].level, 2);
329-
}
330-
331-
#[test]
332-
fn parse_logging_spec_global() {
333-
// test parse_logging_spec with no crate
334-
let dirs = parse_logging_spec(~"warn,crate2=4");
335-
assert_eq!(dirs.len(), 2);
336-
assert!(dirs[0].name == None);
337-
assert_eq!(dirs[0].level, 2);
338-
assert!(dirs[1].name == Some(~"crate2"));
339-
assert_eq!(dirs[1].level, 4);
340-
}
341-
342271
// Tests for update_entry
343272
#[test]
344273
fn update_entry_match_full_path() {
345274
use c_str::ToCStr;
346-
let dirs = ~[LogDirective {name: Some(~"crate1::mod1"), level: 2 },
347-
LogDirective {name: Some(~"crate2"), level: 3}];
348-
let level = &mut 0;
275+
let dirs = ~[LogDirective {name: ~"crate1::mod1", level: 2 },
276+
LogDirective {name: ~"crate2", level: 3}];
349277
unsafe {
350278
do "crate1::mod1".to_c_str().with_ref |ptr| {
351-
let entry= &ModEntry {name: ptr, log_level: level};
279+
let entry= &ModEntry {name: ptr, log_level: &mut 0};
352280
let m = update_entry(dirs, transmute(entry));
353281
assert!(*entry.log_level == 2);
354282
assert!(m == 1);
@@ -359,12 +287,11 @@ fn update_entry_match_full_path() {
359287
#[test]
360288
fn update_entry_no_match() {
361289
use c_str::ToCStr;
362-
let dirs = ~[LogDirective {name: Some(~"crate1::mod1"), level: 2 },
363-
LogDirective {name: Some(~"crate2"), level: 3}];
364-
let level = &mut 0;
290+
let dirs = ~[LogDirective {name: ~"crate1::mod1", level: 2 },
291+
LogDirective {name: ~"crate2", level: 3}];
365292
unsafe {
366293
do "crate3::mod1".to_c_str().with_ref |ptr| {
367-
let entry= &ModEntry {name: ptr, log_level: level};
294+
let entry= &ModEntry {name: ptr, log_level: &mut 0};
368295
let m = update_entry(dirs, transmute(entry));
369296
assert!(*entry.log_level == DEFAULT_LOG_LEVEL);
370297
assert!(m == 0);
@@ -375,12 +302,11 @@ fn update_entry_no_match() {
375302
#[test]
376303
fn update_entry_match_beginning() {
377304
use c_str::ToCStr;
378-
let dirs = ~[LogDirective {name: Some(~"crate1::mod1"), level: 2 },
379-
LogDirective {name: Some(~"crate2"), level: 3}];
380-
let level = &mut 0;
305+
let dirs = ~[LogDirective {name: ~"crate1::mod1", level: 2 },
306+
LogDirective {name: ~"crate2", level: 3}];
381307
unsafe {
382308
do "crate2::mod1".to_c_str().with_ref |ptr| {
383-
let entry= &ModEntry {name: ptr, log_level: level};
309+
let entry= &ModEntry {name: ptr, log_level: &mut 0};
384310
let m = update_entry(dirs, transmute(entry));
385311
assert!(*entry.log_level == 3);
386312
assert!(m == 1);
@@ -391,39 +317,14 @@ fn update_entry_match_beginning() {
391317
#[test]
392318
fn update_entry_match_beginning_longest_match() {
393319
use c_str::ToCStr;
394-
let dirs = ~[LogDirective {name: Some(~"crate1::mod1"), level: 2 },
395-
LogDirective {name: Some(~"crate2"), level: 3},
396-
LogDirective {name: Some(~"crate2::mod"), level: 4}];
397-
let level = &mut 0;
320+
let dirs = ~[LogDirective {name: ~"crate1::mod1", level: 2 },
321+
LogDirective {name: ~"crate2", level: 3}, LogDirective {name: ~"crate2::mod", level: 4}];
398322
unsafe {
399323
do "crate2::mod1".to_c_str().with_ref |ptr| {
400-
let entry = &ModEntry {name: ptr, log_level: level};
324+
let entry = &ModEntry {name: ptr, log_level: &mut 0};
401325
let m = update_entry(dirs, transmute(entry));
402326
assert!(*entry.log_level == 4);
403327
assert!(m == 1);
404328
}
405329
}
406330
}
407-
408-
#[test]
409-
fn update_entry_match_default() {
410-
use c_str::ToCStr;
411-
let dirs = ~[LogDirective {name: Some(~"crate1::mod1"), level: 2 },
412-
LogDirective {name: None, level: 3}
413-
];
414-
let level = &mut 0;
415-
unsafe {
416-
do "crate1::mod1".to_c_str().with_ref |ptr| {
417-
let entry= &ModEntry {name: ptr, log_level: level};
418-
let m = update_entry(dirs, transmute(entry));
419-
assert!(*entry.log_level == 2);
420-
assert!(m == 1);
421-
}
422-
do "crate2::mod2".to_c_str().with_ref |ptr| {
423-
let entry= &ModEntry {name: ptr, log_level: level};
424-
let m = update_entry(dirs, transmute(entry));
425-
assert!(*entry.log_level == 3);
426-
assert!(m == 1);
427-
}
428-
}
429-
}

branches/try2/src/libstd/unstable/raw.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub trait Repr<T> {
4949
/// struct representation. This can be used to read/write different values
5050
/// for the struct. This is a safe method because by default it does not
5151
/// give write-access to the struct returned.
52-
#[inline]
5352
fn repr(&self) -> T { unsafe { cast::transmute_copy(self) } }
5453
}
5554

0 commit comments

Comments
 (0)