Skip to content

Commit 17bbcd5

Browse files
committed
---
yaml --- r: 152233 b: refs/heads/try2 c: 296102e h: refs/heads/master i: 152231: 99a7ecf v: v3
1 parent ca8ca0c commit 17bbcd5

File tree

6 files changed

+74
-112
lines changed

6 files changed

+74
-112
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: 2ec3eeaba85b95e52c30988e54aee957f1812faa
8+
refs/heads/try2: 296102ec869834a7faed34106ad2cf24dd83766a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and its implications on a task that programmers usually find very difficult: con
1818

1919
Ownership is central to Rust,
2020
and is the feature from which many of Rust's powerful capabilities are derived.
21-
"Ownership" refers to which parts of your code are allowed to read,
21+
"Ownership" refers to which parts of your code are allowed read,
2222
write, and ultimately release, memory.
2323
Let's start by looking at some C++ code:
2424

branches/try2/src/libregex_macros/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
html_root_url = "http://doc.rust-lang.org/")]
2121

2222
#![feature(macro_registrar, managed_boxes, quote)]
23+
#![allow(unused_imports)] // `quote_expr!` adds some `use` globs which may be unused
2324

2425
extern crate regex;
2526
extern crate syntax;

branches/try2/src/libserialize/json.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,10 +2227,6 @@ impl<A:ToJson,B:ToJson,C:ToJson> ToJson for (A, B, C) {
22272227
}
22282228
}
22292229

2230-
impl<'a, A:ToJson> ToJson for &'a [A] {
2231-
fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
2232-
}
2233-
22342230
impl<A:ToJson> ToJson for ~[A] {
22352231
fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }
22362232
}
@@ -3338,56 +3334,6 @@ mod tests {
33383334
assert!(stack.get(1) == Key("foo"));
33393335
}
33403336

3341-
#[test]
3342-
fn test_to_json() {
3343-
use collections::{HashMap,TreeMap};
3344-
use super::ToJson;
3345-
3346-
let list2 = List(vec!(Number(1.0_f64), Number(2.0_f64)));
3347-
let list3 = List(vec!(Number(1.0f64), Number(2.0f64), Number(3.0f64)));
3348-
let object = {
3349-
let mut tree_map = TreeMap::new();
3350-
tree_map.insert("a".to_string(), Number(1.0_f64));
3351-
tree_map.insert("b".to_string(), Number(2.0_f64));
3352-
Object(box tree_map)
3353-
};
3354-
3355-
assert_eq!(list2.to_json(), list2);
3356-
assert_eq!(object.to_json(), object);
3357-
assert_eq!(3_i.to_json(), Number(3.0_f64));
3358-
assert_eq!(4_i8.to_json(), Number(4.0_f64));
3359-
assert_eq!(5_i16.to_json(), Number(5.0_f64));
3360-
assert_eq!(6_i32.to_json(), Number(6.0_f64));
3361-
assert_eq!(7_i64.to_json(), Number(7.0_f64));
3362-
assert_eq!(8_u.to_json(), Number(8.0_f64));
3363-
assert_eq!(9_u8.to_json(), Number(9.0_f64));
3364-
assert_eq!(10_u16.to_json(), Number(10.0_f64));
3365-
assert_eq!(11_u32.to_json(), Number(11.0_f64));
3366-
assert_eq!(12_u64.to_json(), Number(12.0_f64));
3367-
assert_eq!(13.0_f32.to_json(), Number(13.0_f64));
3368-
assert_eq!(14.0_f64.to_json(), Number(14.0_f64));
3369-
assert_eq!(().to_json(), Null);
3370-
assert_eq!(true.to_json(), Boolean(true));
3371-
assert_eq!(false.to_json(), Boolean(false));
3372-
assert_eq!("abc".to_string().to_json(), String("abc".to_string()));
3373-
assert_eq!((1, 2).to_json(), list2);
3374-
assert_eq!((1, 2, 3).to_json(), list3);
3375-
assert_eq!([1, 2].to_json(), list2);
3376-
assert_eq!((&[1, 2, 3]).to_json(), list3);
3377-
assert_eq!((~[1, 2]).to_json(), list2);
3378-
assert_eq!(vec!(1, 2, 3).to_json(), list3);
3379-
let mut tree_map = TreeMap::new();
3380-
tree_map.insert("a".to_string(), 1);
3381-
tree_map.insert("b".to_string(), 2);
3382-
assert_eq!(tree_map.to_json(), object);
3383-
let mut hash_map = HashMap::new();
3384-
hash_map.insert("a".to_string(), 1);
3385-
hash_map.insert("b".to_string(), 2);
3386-
assert_eq!(hash_map.to_json(), object);
3387-
assert_eq!(Some(15).to_json(), Number(15 as f64));
3388-
assert_eq!(None::<int>.to_json(), Null);
3389-
}
3390-
33913337
#[bench]
33923338
fn bench_streaming_small(b: &mut Bencher) {
33933339
b.iter( || {

branches/try2/src/libsyntax/crateid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,7 +13,7 @@ use std::fmt;
1313
/// CrateIds identify crates and include the crate name and optionally a path
1414
/// and version. In the full form, they look like relative URLs. Example:
1515
/// `github.com/mozilla/rust#std:1.0` would be a package ID with a path of
16-
/// `gitub.com/mozilla/rust` and a crate name of `std` with a version of
16+
/// `github.com/mozilla/rust` and a crate name of `std` with a version of
1717
/// `1.0`. If no crate name is given after the hash, the name is inferred to
1818
/// be the last component of the path. If no version is given, it is inferred
1919
/// to be `0.0`.

branches/try2/src/libsyntax/ext/quote.rs

Lines changed: 69 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,6 @@ fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr {
401401
vec!(e_str))
402402
}
403403

404-
fn mk_ast_path(cx: &ExtCtxt, sp: Span, name: &str) -> @ast::Expr {
405-
let idents = vec!(id_ext("syntax"), id_ext("ast"), id_ext(name));
406-
cx.expr_path(cx.path_global(sp, idents))
407-
}
408-
409-
fn mk_token_path(cx: &ExtCtxt, sp: Span, name: &str) -> @ast::Expr {
410-
let idents = vec!(id_ext("syntax"), id_ext("parse"), id_ext("token"), id_ext(name));
411-
cx.expr_path(cx.path_global(sp, idents))
412-
}
413-
414404
fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOp) -> @ast::Expr {
415405
let name = match bop {
416406
PLUS => "PLUS",
@@ -424,96 +414,116 @@ fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOp) -> @ast::Expr {
424414
SHL => "SHL",
425415
SHR => "SHR"
426416
};
427-
mk_token_path(cx, sp, name)
417+
cx.expr_ident(sp, id_ext(name))
428418
}
429419

430420
fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
431421

432422
match *tok {
433423
BINOP(binop) => {
434-
return cx.expr_call(sp, mk_token_path(cx, sp, "BINOP"), vec!(mk_binop(cx, sp, binop)));
424+
return cx.expr_call_ident(sp,
425+
id_ext("BINOP"),
426+
vec!(mk_binop(cx, sp, binop)));
435427
}
436428
BINOPEQ(binop) => {
437-
return cx.expr_call(sp, mk_token_path(cx, sp, "BINOPEQ"),
438-
vec!(mk_binop(cx, sp, binop)));
429+
return cx.expr_call_ident(sp,
430+
id_ext("BINOPEQ"),
431+
vec!(mk_binop(cx, sp, binop)));
439432
}
440433

441434
LIT_CHAR(i) => {
442435
let e_char = cx.expr_lit(sp, ast::LitChar(i));
443436

444-
return cx.expr_call(sp, mk_token_path(cx, sp, "LIT_CHAR"), vec!(e_char));
437+
return cx.expr_call_ident(sp, id_ext("LIT_CHAR"), vec!(e_char));
445438
}
446439

447440
LIT_INT(i, ity) => {
448441
let s_ity = match ity {
449-
ast::TyI => "TyI",
450-
ast::TyI8 => "TyI8",
451-
ast::TyI16 => "TyI16",
452-
ast::TyI32 => "TyI32",
453-
ast::TyI64 => "TyI64"
442+
ast::TyI => "TyI".to_string(),
443+
ast::TyI8 => "TyI8".to_string(),
444+
ast::TyI16 => "TyI16".to_string(),
445+
ast::TyI32 => "TyI32".to_string(),
446+
ast::TyI64 => "TyI64".to_string()
454447
};
455-
let e_ity = mk_ast_path(cx, sp, s_ity);
448+
let e_ity = cx.expr_ident(sp, id_ext(s_ity.as_slice()));
449+
456450
let e_i64 = cx.expr_lit(sp, ast::LitInt(i, ast::TyI64));
457-
return cx.expr_call(sp, mk_token_path(cx, sp, "LIT_INT"), vec!(e_i64, e_ity));
451+
452+
return cx.expr_call_ident(sp,
453+
id_ext("LIT_INT"),
454+
vec!(e_i64, e_ity));
458455
}
459456

460457
LIT_UINT(u, uty) => {
461458
let s_uty = match uty {
462-
ast::TyU => "TyU",
463-
ast::TyU8 => "TyU8",
464-
ast::TyU16 => "TyU16",
465-
ast::TyU32 => "TyU32",
466-
ast::TyU64 => "TyU64"
459+
ast::TyU => "TyU".to_string(),
460+
ast::TyU8 => "TyU8".to_string(),
461+
ast::TyU16 => "TyU16".to_string(),
462+
ast::TyU32 => "TyU32".to_string(),
463+
ast::TyU64 => "TyU64".to_string()
467464
};
468-
let e_uty = mk_ast_path(cx, sp, s_uty);
465+
let e_uty = cx.expr_ident(sp, id_ext(s_uty.as_slice()));
466+
469467
let e_u64 = cx.expr_lit(sp, ast::LitUint(u, ast::TyU64));
470-
return cx.expr_call(sp, mk_token_path(cx, sp, "LIT_UINT"), vec!(e_u64, e_uty));
468+
469+
return cx.expr_call_ident(sp,
470+
id_ext("LIT_UINT"),
471+
vec!(e_u64, e_uty));
471472
}
472473

473474
LIT_INT_UNSUFFIXED(i) => {
474475
let e_i64 = cx.expr_lit(sp, ast::LitInt(i, ast::TyI64));
475-
return cx.expr_call(sp, mk_token_path(cx, sp, "LIT_INT_UNSUFFIXED"), vec!(e_i64));
476+
477+
return cx.expr_call_ident(sp,
478+
id_ext("LIT_INT_UNSUFFIXED"),
479+
vec!(e_i64));
476480
}
477481

478482
LIT_FLOAT(fident, fty) => {
479483
let s_fty = match fty {
480-
ast::TyF32 => "TyF32",
481-
ast::TyF64 => "TyF64",
482-
ast::TyF128 => "TyF128"
484+
ast::TyF32 => "TyF32".to_string(),
485+
ast::TyF64 => "TyF64".to_string(),
486+
ast::TyF128 => "TyF128".to_string()
483487
};
484-
let e_fty = mk_ast_path(cx, sp, s_fty);
488+
let e_fty = cx.expr_ident(sp, id_ext(s_fty.as_slice()));
489+
485490
let e_fident = mk_ident(cx, sp, fident);
486-
return cx.expr_call(sp, mk_token_path(cx, sp, "LIT_FLOAT"), vec!(e_fident, e_fty));
491+
492+
return cx.expr_call_ident(sp,
493+
id_ext("LIT_FLOAT"),
494+
vec!(e_fident, e_fty));
487495
}
488496

489497
LIT_STR(ident) => {
490-
return cx.expr_call(sp,
491-
mk_token_path(cx, sp, "LIT_STR"),
492-
vec!(mk_ident(cx, sp, ident)));
498+
return cx.expr_call_ident(sp,
499+
id_ext("LIT_STR"),
500+
vec!(mk_ident(cx, sp, ident)));
493501
}
494502

495503
LIT_STR_RAW(ident, n) => {
496-
return cx.expr_call(sp,
497-
mk_token_path(cx, sp, "LIT_STR_RAW"),
498-
vec!(mk_ident(cx, sp, ident), cx.expr_uint(sp, n)));
504+
return cx.expr_call_ident(sp,
505+
id_ext("LIT_STR_RAW"),
506+
vec!(mk_ident(cx, sp, ident),
507+
cx.expr_uint(sp, n)));
499508
}
500509

501510
IDENT(ident, b) => {
502-
return cx.expr_call(sp,
503-
mk_token_path(cx, sp, "IDENT"),
504-
vec!(mk_ident(cx, sp, ident), cx.expr_bool(sp, b)));
511+
return cx.expr_call_ident(sp,
512+
id_ext("IDENT"),
513+
vec!(mk_ident(cx, sp, ident),
514+
cx.expr_bool(sp, b)));
505515
}
506516

507517
LIFETIME(ident) => {
508-
return cx.expr_call(sp,
509-
mk_token_path(cx, sp, "LIFETIME"),
510-
vec!(mk_ident(cx, sp, ident)));
518+
return cx.expr_call_ident(sp,
519+
id_ext("LIFETIME"),
520+
vec!(mk_ident(cx, sp, ident)));
511521
}
512522

513523
DOC_COMMENT(ident) => {
514-
return cx.expr_call(sp,
515-
mk_token_path(cx, sp, "DOC_COMMENT"),
516-
vec!(mk_ident(cx, sp, ident)));
524+
return cx.expr_call_ident(sp,
525+
id_ext("DOC_COMMENT"),
526+
vec!(mk_ident(cx, sp, ident)));
517527
}
518528

519529
INTERPOLATED(_) => fail!("quote! with interpolated token"),
@@ -555,16 +565,19 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr {
555565
EOF => "EOF",
556566
_ => fail!()
557567
};
558-
mk_token_path(cx, sp, name)
568+
cx.expr_ident(sp, id_ext(name))
559569
}
560570

571+
561572
fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec<@ast::Stmt> {
573+
562574
match *tt {
575+
563576
ast::TTTok(sp, ref tok) => {
564577
let e_sp = cx.expr_ident(sp, id_ext("_sp"));
565-
let e_tok = cx.expr_call(sp,
566-
mk_ast_path(cx, sp, "TTTok"),
567-
vec!(e_sp, mk_token(cx, sp, tok)));
578+
let e_tok = cx.expr_call_ident(sp,
579+
id_ext("TTTok"),
580+
vec!(e_sp, mk_token(cx, sp, tok)));
568581
let e_push =
569582
cx.expr_method_call(sp,
570583
cx.expr_ident(sp, id_ext("tt")),
@@ -682,6 +695,8 @@ fn expand_wrapper(cx: &ExtCtxt,
682695
cx_expr: @ast::Expr,
683696
expr: @ast::Expr) -> @ast::Expr {
684697
let uses = [
698+
&["syntax", "ast"],
699+
&["syntax", "parse", "token"],
685700
&["syntax", "ext", "quote", "rt"],
686701
].iter().map(|path| {
687702
let path = path.iter().map(|s| s.to_string()).collect();

0 commit comments

Comments
 (0)