Skip to content

Commit 2a8677d

Browse files
committed
---
yaml --- r: 50473 b: refs/heads/auto c: d79b224 h: refs/heads/master i: 50471: 3b35d1c v: v3
1 parent e77b03b commit 2a8677d

File tree

8 files changed

+57
-124
lines changed

8 files changed

+57
-124
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 6153aae809387bf5d8e99eda9d2a3c86e80d1b2d
17+
refs/heads/auto: d79b22474cf9b02d0d3a0a78f8c6ef279770c36b
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167

branches/auto/doc/rust.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,6 +3251,28 @@ of runtime logging modules follows.
32513251
* `::rt::backtrace` Log a backtrace on task failure
32523252
* `::rt::callback` Unused
32533253

3254+
#### Logging Expressions
3255+
3256+
Rust provides several macros to log information. Here's a simple Rust program
3257+
that demonstrates all four of them:
3258+
3259+
```rust
3260+
fn main() {
3261+
error!("This is an error log")
3262+
warn!("This is a warn log")
3263+
info!("this is an info log")
3264+
debug!("This is a dubug log")
3265+
}
3266+
```
3267+
3268+
These four log levels correspond to levels 1-4, as controlled by `RUST_LOG`:
3269+
3270+
```bash
3271+
$ RUST_LOG=rust=3 ./rust
3272+
rust: ~"\"This is na error log\""
3273+
rust: ~"\"This is a warn log\""
3274+
rust: ~"\"this is an info log\""
3275+
```
32543276

32553277
# Appendix: Rationales and design tradeoffs
32563278

branches/auto/src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub fn parse_input(sess: Session, +cfg: ast::crate_cfg, input: input)
151151
-> @ast::crate {
152152
match input {
153153
file_input(ref file) => {
154-
parse::parse_crate_from_file_using_tts(&(*file), cfg, sess.parse_sess)
154+
parse::parse_crate_from_file(&(*file), cfg, sess.parse_sess)
155155
}
156156
str_input(ref src) => {
157157
// FIXME (#2319): Don't really want to box the source string

branches/auto/src/libsyntax/ext/tt/transcribe.rs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use core::vec;
2626
`~` */
2727
///an unzipping of `token_tree`s
2828
struct TtFrame {
29-
forest: @mut ~[ast::token_tree],
29+
readme: @mut ~[ast::token_tree],
3030
idx: uint,
3131
dotdotdoted: bool,
3232
sep: Option<Token>,
@@ -37,7 +37,7 @@ pub struct TtReader {
3737
sp_diag: @span_handler,
3838
interner: @ident_interner,
3939
// the unzipped tree:
40-
stack: @mut TtFrame,
40+
cur: @mut TtFrame,
4141
/* for MBE-style macro transcription */
4242
interpolations: LinearMap<ident, @named_match>,
4343
repeat_idx: ~[uint],
@@ -58,8 +58,8 @@ pub fn new_tt_reader(sp_diag: @span_handler,
5858
let r = @mut TtReader {
5959
sp_diag: sp_diag,
6060
interner: itr,
61-
stack: @mut TtFrame {
62-
forest: @mut src,
61+
cur: @mut TtFrame {
62+
readme: @mut src,
6363
idx: 0u,
6464
dotdotdoted: false,
6565
sep: None,
@@ -81,7 +81,7 @@ pub fn new_tt_reader(sp_diag: @span_handler,
8181

8282
fn dup_tt_frame(f: @mut TtFrame) -> @mut TtFrame {
8383
@mut TtFrame {
84-
forest: @mut (copy *f.forest),
84+
readme: @mut (copy *f.readme),
8585
idx: f.idx,
8686
dotdotdoted: f.dotdotdoted,
8787
sep: copy f.sep,
@@ -96,7 +96,7 @@ pub fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader {
9696
@mut TtReader {
9797
sp_diag: r.sp_diag,
9898
interner: r.interner,
99-
stack: dup_tt_frame(r.stack),
99+
cur: dup_tt_frame(r.cur),
100100
interpolations: r.interpolations,
101101
repeat_idx: copy r.repeat_idx,
102102
repeat_len: copy r.repeat_len,
@@ -167,46 +167,45 @@ fn lockstep_iter_size(t: token_tree, r: &mut TtReader) -> lis {
167167
}
168168
}
169169

170-
// return the next token from the TtReader.
171-
// EFFECT: advances the reader's token field
170+
172171
pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
173172
let ret_val = TokenAndSpan {
174173
tok: copy r.cur_tok,
175174
sp: r.cur_span,
176175
};
177176
loop {
178177
{
179-
let stack = &mut *r.stack;
180-
let forest = &mut *stack.forest;
181-
if stack.idx < forest.len() {
178+
let cur = &mut *r.cur;
179+
let readme = &mut *cur.readme;
180+
if cur.idx < readme.len() {
182181
break;
183182
}
184183
}
185184

186185
/* done with this set; pop or repeat? */
187-
if ! r.stack.dotdotdoted
186+
if ! r.cur.dotdotdoted
188187
|| { *r.repeat_idx.last() == *r.repeat_len.last() - 1 } {
189188

190-
match r.stack.up {
189+
match r.cur.up {
191190
None => {
192191
r.cur_tok = EOF;
193192
return ret_val;
194193
}
195194
Some(tt_f) => {
196-
if r.stack.dotdotdoted {
195+
if r.cur.dotdotdoted {
197196
r.repeat_idx.pop();
198197
r.repeat_len.pop();
199198
}
200199

201-
r.stack = tt_f;
202-
r.stack.idx += 1u;
200+
r.cur = tt_f;
201+
r.cur.idx += 1u;
203202
}
204203
}
205204

206205
} else { /* repeat */
207-
r.stack.idx = 0u;
206+
r.cur.idx = 0u;
208207
r.repeat_idx[r.repeat_idx.len() - 1u] += 1u;
209-
match r.stack.sep {
208+
match r.cur.sep {
210209
Some(copy tk) => {
211210
r.cur_tok = tk; /* repeat same span, I guess */
212211
return ret_val;
@@ -217,21 +216,21 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
217216
}
218217
loop { /* because it's easiest, this handles `tt_delim` not starting
219218
with a `tt_tok`, even though it won't happen */
220-
match r.stack.forest[r.stack.idx] {
219+
match r.cur.readme[r.cur.idx] {
221220
tt_delim(copy tts) => {
222-
r.stack = @mut TtFrame {
223-
forest: @mut tts,
221+
r.cur = @mut TtFrame {
222+
readme: @mut tts,
224223
idx: 0u,
225224
dotdotdoted: false,
226225
sep: None,
227-
up: option::Some(r.stack)
226+
up: option::Some(r.cur)
228227
};
229228
// if this could be 0-length, we'd need to potentially recur here
230229
}
231230
tt_tok(sp, copy tok) => {
232231
r.cur_span = sp;
233232
r.cur_tok = tok;
234-
r.stack.idx += 1u;
233+
r.cur.idx += 1u;
235234
return ret_val;
236235
}
237236
tt_seq(sp, copy tts, copy sep, zerok) => {
@@ -257,17 +256,17 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
257256
once");
258257
}
259258

260-
r.stack.idx += 1u;
259+
r.cur.idx += 1u;
261260
return tt_next_token(r);
262261
} else {
263262
r.repeat_len.push(len);
264263
r.repeat_idx.push(0u);
265-
r.stack = @mut TtFrame {
266-
forest: @mut tts,
264+
r.cur = @mut TtFrame {
265+
readme: @mut tts,
267266
idx: 0u,
268267
dotdotdoted: true,
269268
sep: sep,
270-
up: Some(r.stack)
269+
up: Some(r.cur)
271270
};
272271
}
273272
}
@@ -281,13 +280,13 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
281280
(b) we actually can, since it's a token. */
282281
matched_nonterminal(nt_ident(sn,b)) => {
283282
r.cur_span = sp; r.cur_tok = IDENT(sn,b);
284-
r.stack.idx += 1u;
283+
r.cur.idx += 1u;
285284
return ret_val;
286285
}
287286
matched_nonterminal(ref other_whole_nt) => {
288287
r.cur_span = sp;
289288
r.cur_tok = INTERPOLATED(copy *other_whole_nt);
290-
r.stack.idx += 1u;
289+
r.cur.idx += 1u;
291290
return ret_val;
292291
}
293292
matched_seq(*) => {

branches/auto/src/libsyntax/parse/common.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ pub impl Parser {
159159
}
160160
}
161161

162-
// if the given word is not a keyword, signal an error.
163-
// if the next token is the given keyword, eat it and return
164-
// true. Otherwise, return false.
165162
fn eat_keyword(&self, word: &~str) -> bool {
166163
self.require_keyword(word);
167164
let is_kw = match *self.token {
@@ -172,9 +169,6 @@ pub impl Parser {
172169
is_kw
173170
}
174171

175-
// if the given word is not a keyword, signal an error.
176-
// if the next token is not the given word, signal an error.
177-
// otherwise, eat it.
178172
fn expect_keyword(&self, word: &~str) {
179173
self.require_keyword(word);
180174
if !self.eat_keyword(word) {
@@ -188,12 +182,10 @@ pub impl Parser {
188182
}
189183
}
190184

191-
// return true if the given string is a strict keyword
192185
fn is_strict_keyword(&self, word: &~str) -> bool {
193186
self.strict_keywords.contains(word)
194187
}
195188

196-
// signal an error if the current token is a strict keyword
197189
fn check_strict_keywords(&self) {
198190
match *self.token {
199191
token::IDENT(_, false) => {
@@ -204,19 +196,16 @@ pub impl Parser {
204196
}
205197
}
206198

207-
// signal an error if the given string is a strict keyword
208199
fn check_strict_keywords_(&self, w: &~str) {
209200
if self.is_strict_keyword(w) {
210201
self.fatal(fmt!("found `%s` in ident position", *w));
211202
}
212203
}
213204

214-
// return true if this is a reserved keyword
215205
fn is_reserved_keyword(&self, word: &~str) -> bool {
216206
self.reserved_keywords.contains(word)
217207
}
218208

219-
// signal an error if the current token is a reserved keyword
220209
fn check_reserved_keywords(&self) {
221210
match *self.token {
222211
token::IDENT(_, false) => {
@@ -227,16 +216,14 @@ pub impl Parser {
227216
}
228217
}
229218

230-
// signal an error if the given string is a reserved keyword
231219
fn check_reserved_keywords_(&self, w: &~str) {
232220
if self.is_reserved_keyword(w) {
233221
self.fatal(fmt!("`%s` is a reserved keyword", *w));
234222
}
235223
}
236224

237225
// expect and consume a GT. if a >> is seen, replace it
238-
// with a single > and continue. If a GT is not seen,
239-
// signal an error.
226+
// with a single > and continue.
240227
fn expect_gt(&self) {
241228
if *self.token == token::GT {
242229
self.bump();

branches/auto/src/libsyntax/parse/lexer.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ pub fn new_low_level_string_reader(span_diagnostic: @span_handler,
8080
last_pos: filemap.start_pos,
8181
col: CharPos(0),
8282
curr: initial_char,
83-
filemap: filemap,
84-
interner: itr,
83+
filemap: filemap, interner: itr,
8584
/* dummy values; not read */
8685
peek_tok: token::EOF,
8786
peek_span: codemap::dummy_sp()
@@ -151,7 +150,6 @@ impl reader for TtReader {
151150
}
152151

153152
// EFFECT: advance peek_tok and peek_span to refer to the next token.
154-
// EFFECT: update the interner, maybe.
155153
fn string_advance_token(r: @mut StringReader) {
156154
match (consume_whitespace_and_comments(r)) {
157155
Some(comment) => {
@@ -541,9 +539,6 @@ fn ident_continue(c: char) -> bool {
541539
|| (c > 'z' && char::is_XID_continue(c))
542540
}
543541

544-
// return the next token from the string
545-
// EFFECT: advances the input past that token
546-
// EFFECT: updates the interner
547542
fn next_token_inner(rdr: @mut StringReader) -> token::Token {
548543
let mut accum_str = ~"";
549544
let mut c = rdr.curr;

branches/auto/src/libsyntax/parse/mod.rs

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,10 @@ pub mod classify;
4545
/// Reporting obsolete syntax
4646
pub mod obsolete;
4747

48-
// info about a parsing session.
49-
// This structure and the reader both have
50-
// an interner associated with them. If they're
51-
// not the same, bad things can happen.
5248
pub struct ParseSess {
53-
cm: @codemap::CodeMap, // better be the same as the one in the reader!
49+
cm: @codemap::CodeMap,
5450
next_id: node_id,
55-
span_diagnostic: @span_handler, // better be the same as the one in the reader!
51+
span_diagnostic: @span_handler,
5652
interner: @ident_interner,
5753
}
5854

@@ -94,19 +90,6 @@ pub fn parse_crate_from_file(
9490
// why is there no p.abort_if_errors here?
9591
}
9692

97-
pub fn parse_crate_from_file_using_tts(
98-
input: &Path,
99-
cfg: ast::crate_cfg,
100-
sess: @mut ParseSess
101-
) -> @ast::crate {
102-
let p = new_parser_from_file(sess, /*bad*/ copy cfg, input);
103-
let tts = p.parse_all_token_trees();
104-
new_parser_from_tts(sess,cfg,tts).parse_crate_mod(/*bad*/ copy cfg)
105-
// why is there no p.abort_if_errors here?
106-
}
107-
108-
109-
11093
pub fn parse_crate_from_source_str(
11194
name: ~str,
11295
source: @~str,
@@ -330,46 +313,17 @@ mod test {
330313
use std;
331314
use core::io;
332315
use core::option::None;
333-
use ast;
334316

335317
#[test] fn to_json_str<E : Encodable<std::json::Encoder>>(val: @E) -> ~str {
336318
do io::with_str_writer |writer| {
337319
val.encode(~std::json::Encoder(writer));
338320
}
339321
}
340322

341-
fn string_to_crate (source_str : @~str) -> @ast::crate {
342-
parse_crate_from_source_str(
343-
~"bogofile",
344-
source_str,
345-
~[],
346-
new_parse_sess(None))
347-
}
348-
349-
fn string_to_tt_to_crate (source_str : @~str) -> @ast::crate {
350-
let tts = parse_tts_from_source_str(
351-
~"bogofile",
352-
source_str,
353-
~[],
354-
new_parse_sess(None));
355-
new_parser_from_tts(new_parse_sess(None),~[],tts)
356-
.parse_crate_mod(~[])
357-
}
358-
359-
// make sure that parsing from TTs produces the same result
360-
// as parsing from strings
361-
#[test] fn tts_produce_the_same_result () {
362-
let source_str = @~"fn foo (x : int) { x; }";
363-
assert_eq!(string_to_tt_to_crate(source_str),
364-
string_to_crate(source_str));
365-
}
366-
367-
// check the contents of the tt manually:
368323
#[test] fn alltts () {
369-
let source_str = @~"fn foo (x : int) { x; }";
370324
let tts = parse_tts_from_source_str(
371325
~"bogofile",
372-
source_str,
326+
@~"fn foo (x : int) { x; }",
373327
~[],
374328
new_parse_sess(None));
375329
assert_eq!(

0 commit comments

Comments
 (0)