Skip to content

Commit 4c922ee

Browse files
committed
---
yaml --- r: 112623 b: refs/heads/snap-stage3 c: a3b28cb h: refs/heads/master i: 112621: 048566e 112619: e40ed55 112615: 1a48c04 112607: b04b8a0 v: v3
1 parent bb77726 commit 4c922ee

File tree

22 files changed

+122
-41
lines changed

22 files changed

+122
-41
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: c0ff3caae1c0fb7817e09749c5f1ddae3b301ee2
4+
refs/heads/snap-stage3: a3b28cb1f87a649e4bfe4a4b85fe591f9cb6c92f
55
refs/heads/try: fa3000fae833e0869b11da51cabb2a2598ba86d1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

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/librustuv/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ mod homing;
8888
mod queue;
8989
mod rc;
9090

91-
/// The implementation of `rtio` for libuv
9291
pub mod uvio;
93-
94-
/// C bindings to libuv
9592
pub mod uvll;
9693

9794
pub mod file;

branches/snap-stage3/src/librustuv/uvio.rs

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

11+
//! The implementation of `rtio` for libuv
12+
1113
use std::c_str::CString;
1214
use std::cast;
1315
use std::io::IoError;

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/rt/backtrace.rs

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

11+
//! Simple backtrace functionality (to print on failure)
12+
1113
#![allow(non_camel_case_types)]
1214

1315
use char::Char;

branches/snap-stage3/src/libstd/rt/global_heap.rs

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

11+
12+
//! The global (exchange) heap.
13+
1114
use libc::{c_void, size_t, free, malloc, realloc};
1215
use ptr::{RawPtr, mut_null};
1316
use intrinsics::abort;

branches/snap-stage3/src/libstd/rt/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,44 +85,44 @@ pub mod shouldnt_be_public {
8585
// Internal macros used by the runtime.
8686
mod macros;
8787

88-
/// The global (exchange) heap.
88+
// The global (exchange) heap.
8989
pub mod global_heap;
9090

91-
/// Implementations of language-critical runtime features like @.
91+
// Implementations of language-critical runtime features like @.
9292
pub mod task;
9393

94-
/// The EventLoop and internal synchronous I/O interface.
94+
// The EventLoop and internal synchronous I/O interface.
9595
pub mod rtio;
9696

97-
/// The Local trait for types that are accessible via thread-local
98-
/// or task-local storage.
97+
// The Local trait for types that are accessible via thread-local
98+
// or task-local storage.
9999
pub mod local;
100100

101-
/// Bindings to system threading libraries.
101+
// Bindings to system threading libraries.
102102
pub mod thread;
103103

104-
/// The runtime configuration, read from environment variables.
104+
// The runtime configuration, read from environment variables.
105105
pub mod env;
106106

107-
/// The local, managed heap
107+
// The local, managed heap
108108
pub mod local_heap;
109109

110-
/// The runtime needs to be able to put a pointer into thread-local storage.
110+
// The runtime needs to be able to put a pointer into thread-local storage.
111111
mod local_ptr;
112112

113-
/// Bindings to pthread/windows thread-local storage.
113+
// Bindings to pthread/windows thread-local storage.
114114
mod thread_local_storage;
115115

116-
/// Stack unwinding
116+
// Stack unwinding
117117
pub mod unwind;
118118

119-
/// The interface to libunwind that rust is using.
119+
// The interface to libunwind that rust is using.
120120
mod libunwind;
121121

122-
/// Simple backtrace functionality (to print on failure)
122+
// Simple backtrace functionality (to print on failure)
123123
pub mod backtrace;
124124

125-
/// Just stuff
125+
// Just stuff
126126
mod util;
127127

128128
// Global command line argument storage

branches/snap-stage3/src/libstd/rt/rtio.rs

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

11+
//! The EventLoop and internal synchronous I/O interface.
12+
1113
use c_str::CString;
1214
use cast;
1315
use comm::{Sender, Receiver};

branches/snap-stage3/src/libstd/rt/unwind.rs

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

11+
//! Stack unwinding
12+
1113
// Implementation of Rust stack unwinding
1214
//
1315
// For background on exception handling and stack unwinding please see

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/classify.rs

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

11-
/*
12-
Predicates on exprs and stmts that the pretty-printer and parser use
13-
*/
11+
//! Routines the parser uses to classify AST nodes
12+
13+
// Predicates on exprs and stmts that the pretty-printer and parser use
1414

1515
use ast;
1616

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

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

11+
//! Common routines shared by parser mods
12+
1113
use parse::token;
1214

1315
// SeqSep : a sequence separator (token)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@ pub mod token;
2828
pub mod comments;
2929
pub mod attr;
3030

31-
/// Common routines shared by parser mods
3231
pub mod common;
33-
34-
/// Routines the parser uses to classify AST nodes
3532
pub mod classify;
36-
37-
/// Reporting obsolete syntax
3833
pub mod obsolete;
3934

4035
// info about a parsing session.

0 commit comments

Comments
 (0)