Skip to content

Commit 0016ad8

Browse files
committed
---
yaml --- r: 152217 b: refs/heads/try2 c: 455f574 h: refs/heads/master i: 152215: 3b9eb76 v: v3
1 parent ab5f37a commit 0016ad8

File tree

26 files changed

+131
-26
lines changed

26 files changed

+131
-26
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: 60e0f6fbb06d8a1c848cd8793edafa42ba4e1940
8+
refs/heads/try2: 455f574470a3a3f755522bc0fb6594ec10eeda40
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/rust.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ An example of re-exporting:
904904
~~~~
905905
# fn main() { }
906906
mod quux {
907-
pub use quux::foo::*;
907+
pub use quux::foo::{bar, baz};
908908
909909
pub mod foo {
910910
pub fn bar() { }
@@ -913,10 +913,10 @@ mod quux {
913913
}
914914
~~~~
915915

916-
In this example, the module `quux` re-exports all of the public names defined in `foo`.
916+
In this example, the module `quux` re-exports two public names defined in `foo`.
917917

918918
Also note that the paths contained in `use` items are relative to the crate root.
919-
So, in the previous example, the `use` refers to `quux::foo::*`, and not simply to `foo::*`.
919+
So, in the previous example, the `use` refers to `quux::foo::{bar, baz}`, and not simply to `foo::{bar, baz}`.
920920
This also means that top-level module declarations should be at the crate root if direct usage
921921
of the declared modules within `use` items is desired. It is also possible to use `self` and `super`
922922
at the beginning of a `use` item to refer to the current and direct parent modules respectively.

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/librustdoc/html/markdown.rs

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
287287
slice::raw::buf_as_slice((*lang).data,
288288
(*lang).size as uint, |lang| {
289289
let s = str::from_utf8(lang).unwrap();
290-
(s.contains("should_fail"),
291-
s.contains("no_run"),
292-
s.contains("ignore"),
293-
s.contains("notrust"))
290+
parse_lang_string(s)
294291
})
295292
};
296293
if notrust { return }
@@ -340,6 +337,35 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
340337
}
341338
}
342339

340+
fn parse_lang_string(string: &str) -> (bool,bool,bool,bool) {
341+
let mut seen_rust_tags = false;
342+
let mut seen_other_tags = false;
343+
let mut should_fail = false;
344+
let mut no_run = false;
345+
let mut ignore = false;
346+
let mut notrust = false;
347+
348+
let mut tokens = string.as_slice().split(|c: char|
349+
!(c == '_' || c == '-' || c.is_alphanumeric())
350+
);
351+
352+
for token in tokens {
353+
match token {
354+
"" => {},
355+
"should_fail" => { should_fail = true; seen_rust_tags = true; },
356+
"no_run" => { no_run = true; seen_rust_tags = true; },
357+
"ignore" => { ignore = true; seen_rust_tags = true; },
358+
"notrust" => { notrust = true; seen_rust_tags = true; },
359+
"rust" => { notrust = false; seen_rust_tags = true; },
360+
_ => { seen_other_tags = true }
361+
}
362+
}
363+
364+
let notrust = notrust || (seen_other_tags && !seen_rust_tags);
365+
366+
(should_fail, no_run, ignore, notrust)
367+
}
368+
343369
/// By default this markdown renderer generates anchors for each header in the
344370
/// rendered document. The anchor name is the contents of the header spearated
345371
/// by hyphens, and a task-local map is used to disambiguate among duplicate
@@ -367,3 +393,22 @@ impl<'a> fmt::Show for MarkdownWithToc<'a> {
367393
render(fmt, md.as_slice(), true)
368394
}
369395
}
396+
397+
#[cfg(test)]
398+
mod tests {
399+
use super::parse_lang_string;
400+
401+
#[test]
402+
fn test_parse_lang_string() {
403+
assert_eq!(parse_lang_string(""), (false,false,false,false))
404+
assert_eq!(parse_lang_string("rust"), (false,false,false,false))
405+
assert_eq!(parse_lang_string("sh"), (false,false,false,true))
406+
assert_eq!(parse_lang_string("notrust"), (false,false,false,true))
407+
assert_eq!(parse_lang_string("ignore"), (false,false,true,false))
408+
assert_eq!(parse_lang_string("should_fail"), (true,false,false,false))
409+
assert_eq!(parse_lang_string("no_run"), (false,true,false,false))
410+
assert_eq!(parse_lang_string("{.no_run .example}"), (false,true,false,false))
411+
assert_eq!(parse_lang_string("{.sh .should_fail}"), (true,false,false,false))
412+
assert_eq!(parse_lang_string("{.example .rust}"), (false,false,false,false))
413+
}
414+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
// except according to those terms.
1010

1111
use abi;
12-
use ast::{P, Ident};
12+
use ast::{P, Ident, Generics, NodeId, Expr};
1313
use ast;
1414
use ast_util;
1515
use attr;
1616
use codemap::{Span, respan, Spanned, DUMMY_SP};
1717
use ext::base::ExtCtxt;
18-
use ext::quote::rt::*;
1918
use fold::Folder;
2019
use owned_slice::OwnedSlice;
2120
use parse::token::special_idents;
21+
use parse::token::InternedString;
2222
use parse::token;
2323

2424
pub struct Field {

branches/try2/src/libsyntax/ext/deriving/bounds.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use ast::{MetaItem, MetaWord, Item};
1212
use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::deriving::generic::*;
15+
use ext::deriving::generic::ty::*;
1516

1617
pub fn expand_deriving_bound(cx: &mut ExtCtxt,
1718
span: Span,

branches/try2/src/libsyntax/ext/deriving/clone.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_clone(cx: &mut ExtCtxt,

branches/try2/src/libsyntax/ext/deriving/cmp/eq.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_eq(cx: &mut ExtCtxt,

branches/try2/src/libsyntax/ext/deriving/cmp/ord.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718
use parse::token::InternedString;
1819

1920
pub fn expand_deriving_ord(cx: &mut ExtCtxt,

branches/try2/src/libsyntax/ext/deriving/cmp/totaleq.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,

branches/try2/src/libsyntax/ext/deriving/cmp/totalord.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718
use parse::token::InternedString;
1819

1920
use std::cmp::{Ordering, Equal, Less, Greater};

branches/try2/src/libsyntax/ext/deriving/decodable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use codemap::Span;
1919
use ext::base::ExtCtxt;
2020
use ext::build::AstBuilder;
2121
use ext::deriving::generic::*;
22+
use ext::deriving::generic::ty::*;
2223
use parse::token::InternedString;
2324
use parse::token;
2425

branches/try2/src/libsyntax/ext/deriving/default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_default(cx: &mut ExtCtxt,

branches/try2/src/libsyntax/ext/deriving/encodable.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ use codemap::Span;
8888
use ext::base::ExtCtxt;
8989
use ext::build::AstBuilder;
9090
use ext::deriving::generic::*;
91+
use ext::deriving::generic::ty::*;
9192
use parse::token;
9293

9394
pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
@@ -175,6 +176,14 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
175176
stmts.push(cx.stmt_expr(call));
176177
}
177178

179+
// unit structs have no fields and need to return Ok()
180+
if stmts.is_empty() {
181+
let ret_ok = cx.expr(trait_span,
182+
ExprRet(Some(cx.expr_ok(trait_span,
183+
cx.expr_lit(trait_span, LitNil)))));
184+
stmts.push(cx.stmt_expr(ret_ok));
185+
}
186+
178187
let blk = cx.lambda_stmts_1(trait_span, stmts, blkarg);
179188
cx.expr_method_call(trait_span,
180189
encoder,

branches/try2/src/libsyntax/ext/deriving/generic/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ use codemap::Span;
191191
use owned_slice::OwnedSlice;
192192
use parse::token::InternedString;
193193

194-
pub use self::ty::*;
195-
mod ty;
194+
use self::ty::*;
195+
196+
pub mod ty;
196197

197198
pub struct TraitDef<'a> {
198199
/// The span for the current #[deriving(Foo)] header.

branches/try2/src/libsyntax/ext/deriving/hash.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718
use parse::token::InternedString;
1819

1920
pub fn expand_deriving_hash(cx: &mut ExtCtxt,

branches/try2/src/libsyntax/ext/deriving/primitive.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718
use parse::token::InternedString;
1819

1920
pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,

branches/try2/src/libsyntax/ext/deriving/rand.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::{AstBuilder};
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718

1819
pub fn expand_deriving_rand(cx: &mut ExtCtxt,
1920
span: Span,

branches/try2/src/libsyntax/ext/deriving/show.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use ext::format;
1515
use ext::base::ExtCtxt;
1616
use ext::build::AstBuilder;
1717
use ext::deriving::generic::*;
18+
use ext::deriving::generic::ty::*;
1819
use parse::token;
1920

2021
use collections::HashMap;

branches/try2/src/libsyntax/ext/deriving/zero.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_zero(cx: &mut ExtCtxt,

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ pub mod rt {
3636
use parse;
3737
use print::pprust;
3838

39-
pub use ast::*;
40-
pub use parse::token::*;
39+
#[cfg(not(stage0))]
40+
use ast::{TokenTree, Generics, Expr};
41+
42+
// NOTE remove this after snapshot
43+
// (stage0 quasiquoter needs this)
44+
#[cfg(stage0)]
45+
pub use ast::{Generics, TokenTree, TTTok};
46+
#[cfg(stage0)]
47+
pub use parse::token::{IDENT, SEMI, LBRACE, RBRACE, LIFETIME, COLON, AND, BINOP, EQ,
48+
LBRACKET, RBRACKET, LPAREN, RPAREN, POUND, NOT, MOD_SEP, DOT, COMMA};
49+
4150
pub use parse::new_parser_from_tts;
4251
pub use codemap::{BytePos, Span, dummy_spanned};
4352

@@ -72,7 +81,7 @@ pub mod rt {
7281

7382
impl ToSource for ast::Ident {
7483
fn to_source(&self) -> String {
75-
get_ident(*self).get().to_string()
84+
token::get_ident(*self).get().to_string()
7685
}
7786
}
7887

@@ -685,11 +694,14 @@ fn expand_wrapper(cx: &ExtCtxt,
685694
sp: Span,
686695
cx_expr: @ast::Expr,
687696
expr: @ast::Expr) -> @ast::Expr {
688-
let uses = vec![ cx.view_use_glob(sp, ast::Inherited,
689-
ids_ext(vec!["syntax".to_string(),
690-
"ext".to_string(),
691-
"quote".to_string(),
692-
"rt".to_string()])) ];
697+
let uses = [
698+
&["syntax", "ast"],
699+
&["syntax", "parse", "token"],
700+
&["syntax", "ext", "quote", "rt"],
701+
].iter().map(|path| {
702+
let path = path.iter().map(|s| s.to_string()).collect();
703+
cx.view_use_glob(sp, ast::Inherited, ids_ext(path))
704+
}).collect();
693705

694706
let stmt_let_ext_cx = cx.stmt_let(sp, false, id_ext("ext_cx"), cx_expr);
695707

branches/try2/src/libsyntax/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub mod util {
4848
pub mod syntax {
4949
pub use ext;
5050
pub use parse;
51+
pub use ast;
5152
}
5253

5354
pub mod owned_slice;

branches/try2/src/test/run-pass/extern-pass-TwoU64s.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// Test a foreign function that accepts and returns a struct
1212
// by value.
1313

14-
// ignore-win32 #9205
15-
1614
#[deriving(PartialEq, Show)]
1715
struct TwoU64s {
1816
one: u64, two: u64

branches/try2/src/test/run-pass/extern-return-TwoU64s.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-win32 #9205
12-
1311
struct TwoU64s {
1412
one: u64, two: u64
1513
}
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+
12+
extern crate serialize;
13+
14+
use serialize::{Encodable, Decodable};
15+
use serialize::json;
16+
17+
#[deriving(Encodable, Decodable, PartialEq, Show)]
18+
struct UnitLikeStruct;
19+
20+
pub fn main() {
21+
let obj = UnitLikeStruct;
22+
let json_str: String = json::Encoder::str_encode(&obj);
23+
24+
let json_object = json::from_str(json_str.as_slice());
25+
let mut decoder = json::Decoder::new(json_object.unwrap());
26+
let mut decoded_obj: UnitLikeStruct = Decodable::decode(&mut decoder).unwrap();
27+
28+
assert_eq!(obj, decoded_obj);
29+
}

branches/try2/src/test/run-pass/struct-return.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-win32 #9205
12-
1311
pub struct Quad { a: u64, b: u64, c: u64, d: u64 }
1412
pub struct Floats { a: f64, b: u8, c: f64 }
1513

0 commit comments

Comments
 (0)