Skip to content

Commit 048566e

Browse files
committed
---
yaml --- r: 112621 b: refs/heads/snap-stage3 c: 23262a8 h: refs/heads/master i: 112619: e40ed55 v: v3
1 parent bc2f5a6 commit 048566e

File tree

37 files changed

+437
-43
lines changed

37 files changed

+437
-43
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 30e373390f1a2f74e78bf9ca9c8ca68451f3511a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 6c41253a473728451283e20bef3498fdfe797243
4+
refs/heads/snap-stage3: 23262a83909392f88fdc8031ebd754f8d9b94525
55
refs/heads/try: fa3000fae833e0869b11da51cabb2a2598ba86d1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/doc/tutorial.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,11 +1793,6 @@ spawn(proc() {
17931793
});
17941794
~~~~
17951795
1796-
> *Note:* If you want to see the output of `debug!` statements, you will need to turn on
1797-
> `debug!` logging. To enable `debug!` logging, set the RUST_LOG environment
1798-
> variable to the name of your crate, which, for a file named `foo.rs`, will be
1799-
> `foo` (e.g., with bash, `export RUST_LOG=foo`).
1800-
18011796
## Closure compatibility
18021797
18031798
Rust closures have a convenient subtyping property: you can pass any kind of

branches/snap-stage3/src/etc/maketest.py

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,53 @@
1212
import os
1313
import sys
1414

15-
# FIXME #12303 these tests are broken on windows
16-
if os.name == 'nt':
17-
print 'ignoring make tests on windows'
18-
sys.exit(0)
15+
# msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
16+
# `c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks
17+
# the value is list of paths.
18+
# this causes great confusion and error: shell and Makefile doesn't like
19+
# windows paths so it is really error-prone. revert it for peace.
20+
def normalize_path(v):
21+
# c:\path -> /c/path
22+
if ':\\' in v:
23+
v = '/' + v.replace(':\\', '/')
24+
v = v.replace('\\', '/')
25+
return v
26+
27+
28+
def putenv(name, value):
29+
if os.name == 'nt':
30+
value = normalize_path(value)
31+
os.putenv(name, value)
32+
1933

2034
make = sys.argv[2]
21-
os.putenv('RUSTC', os.path.abspath(sys.argv[3]))
22-
os.putenv('TMPDIR', os.path.abspath(sys.argv[4]))
23-
os.putenv('CC', sys.argv[5])
24-
os.putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
35+
putenv('RUSTC', os.path.abspath(sys.argv[3]))
36+
putenv('TMPDIR', os.path.abspath(sys.argv[4]))
37+
putenv('CC', sys.argv[5])
38+
putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
2539
filt = sys.argv[7]
2640
ldpath = sys.argv[8]
2741
if ldpath != '':
28-
os.putenv(ldpath.split('=')[0], ldpath.split('=')[1])
42+
name = ldpath.split('=')[0]
43+
value = ldpath.split('=')[1]
44+
if os.name == 'nt' and name != 'PATH':
45+
value = ":".join(normalize_path(v) for v in value.split(";"))
46+
os.putenv(name, value)
2947

3048
if not filt in sys.argv[1]:
3149
sys.exit(0)
3250
print('maketest: ' + os.path.basename(os.path.dirname(sys.argv[1])))
3351

34-
proc = subprocess.Popen([make, '-C', sys.argv[1]],
52+
path = sys.argv[1]
53+
if path[-1] == '/':
54+
# msys1 has a bug that `make` fails to include `../tools.mk` (parent dir)
55+
# if `-C path` option is given and `path` is absolute directory with
56+
# trailing slash (`c:/path/to/test/`).
57+
# the easist workaround is to remove the slash (`c:/path/to/test`).
58+
# msys2 seems to fix this problem.
59+
path = path[:-1]
60+
61+
proc = subprocess.Popen([make, '-C', path],
3562
stdout = subprocess.PIPE,
3663
stderr = subprocess.PIPE)
3764
out, err = proc.communicate()

branches/snap-stage3/src/librustc/front/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ fn fold_mod(cx: &mut Context, m: &ast::Mod) -> ast::Mod {
7070
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
7171
}).collect();
7272
ast::Mod {
73+
inner: m.inner,
7374
view_items: filtered_view_items,
7475
items: flattened_items
7576
}

branches/snap-stage3/src/librustc/front/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
143143
}
144144

145145
let mod_nomain = ast::Mod {
146+
inner: m.inner,
146147
view_items: m.view_items.clone(),
147148
items: m.items.iter().map(|i| nomain(&self.cx, *i)).collect(),
148149
};
@@ -335,6 +336,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::Item {
335336
)).unwrap();
336337

337338
let testmod = ast::Mod {
339+
inner: DUMMY_SP,
338340
view_items: view_items,
339341
items: vec!(mainfn, tests),
340342
};

branches/snap-stage3/src/librustdoc/clean.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,27 @@ impl Clean<Item> for doctree::Module {
227227
self.view_items.clean().move_iter().collect(),
228228
self.macros.clean().move_iter().collect()
229229
);
230+
231+
// determine if we should display the inner contents or
232+
// the outer `mod` item for the source code.
233+
let where = {
234+
let ctxt = local_data::get(super::ctxtkey, |x| *x.unwrap());
235+
let cm = ctxt.sess().codemap();
236+
let outer = cm.lookup_char_pos(self.where_outer.lo);
237+
let inner = cm.lookup_char_pos(self.where_inner.lo);
238+
if outer.file.start_pos == inner.file.start_pos {
239+
// mod foo { ... }
240+
self.where_outer
241+
} else {
242+
// mod foo; (and a separate FileMap for the contents)
243+
self.where_inner
244+
}
245+
};
246+
230247
Item {
231248
name: Some(name),
232249
attrs: self.attrs.clean(),
233-
source: self.where.clean(),
250+
source: where.clean(),
234251
visibility: self.vis.clean(),
235252
id: self.id,
236253
inner: ModuleItem(Module {

branches/snap-stage3/src/librustdoc/doctree.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use syntax::ast::{Ident, NodeId};
1919
pub struct Module {
2020
pub name: Option<Ident>,
2121
pub attrs: Vec<ast::Attribute>,
22-
pub where: Span,
22+
pub where_outer: Span,
23+
pub where_inner: Span,
2324
pub structs: Vec<Struct>,
2425
pub enums: Vec<Enum>,
2526
pub fns: Vec<Function>,
@@ -42,7 +43,8 @@ impl Module {
4243
name : name,
4344
id: 0,
4445
vis: ast::Inherited,
45-
where: syntax::codemap::DUMMY_SP,
46+
where_outer: syntax::codemap::DUMMY_SP,
47+
where_inner: syntax::codemap::DUMMY_SP,
4648
attrs : Vec::new(),
4749
structs : Vec::new(),
4850
enums : Vec::new(),

branches/snap-stage3/src/librustdoc/visit_ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ impl<'a> RustdocVisitor<'a> {
118118
for item in m.view_items.iter() {
119119
self.visit_view_item(item, &mut om);
120120
}
121-
om.where = span;
121+
om.where_outer = span;
122+
om.where_inner = m.inner;
122123
om.attrs = attrs;
123124
om.vis = vis;
124125
om.id = id;

branches/snap-stage3/src/libstd/mem.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,38 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
248248
/**
249249
* Replace the value at a mutable location with a new one, returning the old
250250
* value, without deinitialising or copying either one.
251+
*
252+
* This is primarily used for transferring and swapping ownership of a value
253+
* in a mutable location. For example, this function allows consumption of
254+
* one field of a struct by replacing it with another value. The normal approach
255+
* doesn't always work:
256+
*
257+
* ```rust,ignore
258+
* struct Buffer<T> { buf: Vec<T> }
259+
*
260+
* impl<T> Buffer<T> {
261+
* fn get_and_reset(&mut self) -> Vec<T> {
262+
* // error: cannot move out of dereference of `&mut`-pointer
263+
* let buf = self.buf;
264+
* self.buf = Vec::new();
265+
* buf
266+
* }
267+
* }
268+
* ```
269+
*
270+
* Note that `T` does not necessarily implement `Clone`, so it can't even
271+
* clone and reset `self.buf`. But `replace` can be used to disassociate
272+
* the original value of `self.buf` from `self`, allowing it to be returned:
273+
*
274+
* ```rust
275+
* # struct Buffer<T> { buf: Vec<T> }
276+
* impl<T> Buffer<T> {
277+
* fn get_and_reset(&mut self) -> Vec<T> {
278+
* use std::mem::replace;
279+
* replace(&mut self.buf, Vec::new())
280+
* }
281+
* }
282+
* ```
251283
*/
252284
#[inline]
253285
pub fn replace<T>(dest: &mut T, mut src: T) -> T {

branches/snap-stage3/src/libstd/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ impl<T:Eq> Vec<T> {
12881288
// +---+---+---+---+---+---+
12891289
// w
12901290
//
1291-
// Comparing self[r] against self[w-1], tis is not a duplicate, so
1291+
// Comparing self[r] against self[w-1], this is not a duplicate, so
12921292
// we swap self[r] and self[w] (no effect as r==w) and then increment both
12931293
// r and w, leaving us with:
12941294
//

branches/snap-stage3/src/libsyntax/ast.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,12 @@ pub struct Method {
921921

922922
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
923923
pub struct Mod {
924-
pub view_items: Vec<ViewItem> ,
925-
pub items: Vec<@Item> ,
924+
/// A span from the first token past `{` to the last token until `}`.
925+
/// For `mod foo;`, the inner span ranges from the first token
926+
/// to the last token in the external file.
927+
pub inner: Span,
928+
pub view_items: Vec<ViewItem>,
929+
pub items: Vec<@Item>,
926930
}
927931

928932
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
@@ -1165,7 +1169,15 @@ mod test {
11651169
fn check_asts_encodable() {
11661170
use std::io;
11671171
let e = Crate {
1168-
module: Mod {view_items: Vec::new(), items: Vec::new()},
1172+
module: Mod {
1173+
inner: Span {
1174+
lo: BytePos(11),
1175+
hi: BytePos(19),
1176+
expn_info: None,
1177+
},
1178+
view_items: Vec::new(),
1179+
items: Vec::new(),
1180+
},
11691181
attrs: Vec::new(),
11701182
config: Vec::new(),
11711183
span: Span {

branches/snap-stage3/src/libsyntax/ext/build.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub trait AstBuilder {
220220
generics: Generics) -> @ast::Item;
221221
fn item_struct(&self, span: Span, name: Ident, struct_def: ast::StructDef) -> @ast::Item;
222222

223-
fn item_mod(&self, span: Span,
223+
fn item_mod(&self, span: Span, inner_span: Span,
224224
name: Ident, attrs: Vec<ast::Attribute> ,
225225
vi: Vec<ast::ViewItem> , items: Vec<@ast::Item> ) -> @ast::Item;
226226

@@ -898,7 +898,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
898898
self.item(span, name, Vec::new(), ast::ItemStruct(@struct_def, generics))
899899
}
900900

901-
fn item_mod(&self, span: Span, name: Ident,
901+
fn item_mod(&self, span: Span, inner_span: Span, name: Ident,
902902
attrs: Vec<ast::Attribute> ,
903903
vi: Vec<ast::ViewItem> ,
904904
items: Vec<@ast::Item> ) -> @ast::Item {
@@ -907,6 +907,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
907907
name,
908908
attrs,
909909
ast::ItemMod(ast::Mod {
910+
inner: inner_span,
910911
view_items: vi,
911912
items: items,
912913
})

branches/snap-stage3/src/libsyntax/fold.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ pub fn noop_fold_type_method<T: Folder>(m: &TypeMethod, fld: &mut T) -> TypeMeth
652652

653653
pub fn noop_fold_mod<T: Folder>(m: &Mod, folder: &mut T) -> Mod {
654654
ast::Mod {
655+
inner: folder.new_span(m.inner),
655656
view_items: m.view_items
656657
.iter()
657658
.map(|x| folder.fold_view_item(x)).collect(),

branches/snap-stage3/src/libsyntax/parse/parser.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4036,7 +4036,8 @@ impl<'a> Parser<'a> {
40364036
// attributes (of length 0 or 1), parse all of the items in a module
40374037
fn parse_mod_items(&mut self,
40384038
term: token::Token,
4039-
first_item_attrs: Vec<Attribute> )
4039+
first_item_attrs: Vec<Attribute>,
4040+
inner_lo: BytePos)
40404041
-> Mod {
40414042
// parse all of the items up to closing or an attribute.
40424043
// view items are legal here.
@@ -4081,7 +4082,11 @@ impl<'a> Parser<'a> {
40814082
self.span_err(self.last_span, "expected item after attributes");
40824083
}
40834084

4084-
ast::Mod { view_items: view_items, items: items }
4085+
ast::Mod {
4086+
inner: mk_sp(inner_lo, self.span.lo),
4087+
view_items: view_items,
4088+
items: items
4089+
}
40854090
}
40864091

40874092
fn parse_item_const(&mut self) -> ItemInfo {
@@ -4107,8 +4112,9 @@ impl<'a> Parser<'a> {
41074112
} else {
41084113
self.push_mod_path(id, outer_attrs);
41094114
self.expect(&token::LBRACE);
4115+
let mod_inner_lo = self.span.lo;
41104116
let (inner, next) = self.parse_inner_attrs_and_next();
4111-
let m = self.parse_mod_items(token::RBRACE, next);
4117+
let m = self.parse_mod_items(token::RBRACE, next, mod_inner_lo);
41124118
self.expect(&token::RBRACE);
41134119
self.pop_mod_path();
41144120
(id, ItemMod(m), Some(inner))
@@ -4197,10 +4203,11 @@ impl<'a> Parser<'a> {
41974203
self.cfg.clone(),
41984204
&path,
41994205
id_sp);
4206+
let mod_inner_lo = p0.span.lo;
42004207
let (inner, next) = p0.parse_inner_attrs_and_next();
42014208
let mod_attrs = outer_attrs.append(inner.as_slice());
42024209
let first_item_outer_attrs = next;
4203-
let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
4210+
let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs, mod_inner_lo);
42044211
self.sess.included_mod_stack.borrow_mut().pop();
42054212
return (ast::ItemMod(m0), mod_attrs);
42064213
}
@@ -5061,7 +5068,7 @@ impl<'a> Parser<'a> {
50615068
let (inner, next) = self.parse_inner_attrs_and_next();
50625069
let first_item_outer_attrs = next;
50635070
// parse the items inside the crate:
5064-
let m = self.parse_mod_items(token::EOF, first_item_outer_attrs);
5071+
let m = self.parse_mod_items(token::EOF, first_item_outer_attrs, lo);
50655072

50665073
ast::Crate {
50675074
module: m,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2012-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+
trait A<'a, T> {
12+
fn f(&mut self) -> &'a mut T;
13+
fn p() -> T;
14+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
struct Test<'s> {
12+
func: ||: 's,
13+
}
14+
15+
fn main() {
16+
let test = ~Test { func: proc() {} };
17+
//~^ ERROR: expected `||` but found `proc()`
18+
}

branches/snap-stage3/src/test/run-make/c-link-to-rust-staticlib/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
-include ../tools.mk
22

3+
ifndef IS_WINDOWS
34
ifneq ($(shell uname),Darwin)
45
EXTRAFLAGS := -lm -lrt -ldl -lpthread
56
endif
7+
endif
68

7-
# FIXME
9+
# FIXME: ignore freebsd
810
ifneq ($(shell uname),FreeBSD)
911
all:
1012
$(RUSTC) foo.rs

0 commit comments

Comments
 (0)