Skip to content

Commit e7dd036

Browse files
committed
---
yaml --- r: 152219 b: refs/heads/try2 c: 63e9b8f h: refs/heads/master i: 152217: 0016ad8 152215: 3b9eb76 v: v3
1 parent 65a0538 commit e7dd036

File tree

24 files changed

+108
-16
lines changed

24 files changed

+108
-16
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: 20fb7c62d433addf853b8ab824462fca536aba07
8+
refs/heads/try2: 63e9b8f105ba0fe18e99cb280a23db82380960f4
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/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;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
fn f(_: extern "Rust" fn()) {}
12+
extern fn bar() {}
13+
14+
fn main() { f(bar) }
15+
//~^ ERROR: expected `fn()` but found `extern "C" fn()`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
extern "Rust" fn main() {}
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+
}

0 commit comments

Comments
 (0)