Skip to content

Commit 815e957

Browse files
committed
---
yaml --- r: 151517 b: refs/heads/try2 c: 4cbd775 h: refs/heads/master i: 151515: 947d5a8 v: v3
1 parent 8badb5e commit 815e957

File tree

31 files changed

+223
-226
lines changed

31 files changed

+223
-226
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: 1001635dc1be7ee7c42800e7e2e537a811280c8a
8+
refs/heads/try2: 4cbd7754ea7277aa3e4ae20492e2bfca81e4cd11
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ This document does not serve as a tutorial introduction to the
1717
language. Background familiarity with the language is assumed. A separate
1818
[tutorial] document is available to help acquire such background familiarity.
1919

20-
This document also does not serve as a reference to the [standard]
21-
library included in the language distribution. Those libraries are
20+
This document also does not serve as a reference to the [standard] or [extra]
21+
libraries included in the language distribution. Those libraries are
2222
documented separately by extracting documentation attributes from their
2323
source code.
2424

2525
[tutorial]: tutorial.html
2626
[standard]: std/index.html
27+
[extra]: extra/index.html
2728

2829
## Disclaimer
2930

branches/try2/src/etc/vim/indent/rust.vim

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ setlocal cindent
1313
setlocal cinoptions=L0,(0,Ws,JN,j1
1414
setlocal cinkeys=0{,0},!^F,o,O,0[,0]
1515
" Don't think cinwords will actually do anything at all... never mind
16-
setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
16+
setlocal cinwords=do,for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
1717

1818
" Some preliminary settings
1919
setlocal nolisp " Make sure lisp indenting doesn't supersede us
@@ -40,12 +40,12 @@ function! s:get_line_trimmed(lnum)
4040
" If the last character in the line is a comment, do a binary search for
4141
" the start of the comment. synID() is slow, a linear search would take
4242
" too long on a long line.
43-
if synIDattr(synID(a:lnum, line_len, 1), "name") =~ 'Comment\|Todo'
43+
if synIDattr(synID(a:lnum, line_len, 1), "name") =~ "Comment\|Todo"
4444
let min = 1
4545
let max = line_len
4646
while min < max
4747
let col = (min + max) / 2
48-
if synIDattr(synID(a:lnum, col, 1), "name") =~ 'Comment\|Todo'
48+
if synIDattr(synID(a:lnum, col, 1), "name") =~ "Comment\|Todo"
4949
let max = col
5050
else
5151
let min = col + 1
@@ -87,10 +87,10 @@ function GetRustIndent(lnum)
8787
if synname == "rustString"
8888
" If the start of the line is in a string, don't change the indent
8989
return -1
90-
elseif synname =~ '\(Comment\|Todo\)'
91-
\ && line !~ '^\s*/\*' " not /* opening line
90+
elseif synname =~ "\\(Comment\\|Todo\\)"
91+
\ && line !~ "^\\s*/\\*" " not /* opening line
9292
if synname =~ "CommentML" " multi-line
93-
if line !~ '^\s*\*' && getline(a:lnum - 1) =~ '^\s*/\*'
93+
if line !~ "^\\s*\\*" && getline(a:lnum - 1) =~ "^\\s*/\\*"
9494
" This is (hopefully) the line after a /*, and it has no
9595
" leader, so the correct indentation is that of the
9696
" previous line.
@@ -115,16 +115,11 @@ function GetRustIndent(lnum)
115115
" };
116116

117117
" Search backwards for the previous non-empty line.
118-
let prevlinenum = prevnonblank(a:lnum - 1)
119-
let prevline = s:get_line_trimmed(prevlinenum)
120-
while prevlinenum > 1 && prevline !~ '[^[:blank:]]'
121-
let prevlinenum = prevnonblank(prevlinenum - 1)
122-
let prevline = s:get_line_trimmed(prevlinenum)
123-
endwhile
118+
let prevline = s:get_line_trimmed(prevnonblank(a:lnum - 1))
124119
if prevline[len(prevline) - 1] == ","
125-
\ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]'
126-
\ && prevline !~ '^\s*fn\s'
127-
\ && prevline !~ '([^()]\+,$'
120+
\ && s:get_line_trimmed(a:lnum) !~ "^\\s*[\\[\\]{}]"
121+
\ && prevline !~ "^\\s*fn\\s"
122+
\ && prevline !~ "([^()]\\+,$"
128123
" Oh ho! The previous line ended in a comma! I bet cindent will try to
129124
" take this too far... For now, let's normally use the previous line's
130125
" indent.
@@ -171,7 +166,7 @@ function GetRustIndent(lnum)
171166
" column zero)
172167

173168
call cursor(a:lnum, 1)
174-
if searchpair('{\|(', '', '}\|)', 'nbW',
169+
if searchpair('{\|(', '', '}\|)', 'nbW'
175170
\ 's:is_string_comment(line("."), col("."))') == 0
176171
if searchpair('\[', '', '\]', 'nbW',
177172
\ 's:is_string_comment(line("."), col("."))') == 0

branches/try2/src/libcore/intrinsics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub trait TyVisitor {
137137
sz: uint, align: uint) -> bool;
138138

139139
fn visit_enter_enum(&mut self, n_variants: uint,
140-
get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
140+
get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
141141
sz: uint, align: uint) -> bool;
142142
fn visit_enter_enum_variant(&mut self, variant: uint,
143143
disr_val: Disr,
@@ -149,7 +149,7 @@ pub trait TyVisitor {
149149
n_fields: uint,
150150
name: &str) -> bool;
151151
fn visit_leave_enum(&mut self, n_variants: uint,
152-
get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
152+
get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
153153
sz: uint, align: uint) -> bool;
154154

155155
fn visit_enter_fn(&mut self, purity: uint, proto: uint,

branches/try2/src/libcore/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//!
2525
//! Functions return `Result` whenever errors are expected and
2626
//! recoverable. In the `std` crate `Result` is most prominently used
27-
//! for [I/O](../../std/io/index.html).
27+
//! for [I/O](../io/index.html).
2828
//!
2929
//! A simple function returning `Result` might be
3030
//! defined and used like so:

branches/try2/src/liblibc/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ pub use types::os::common::bsd44::{addrinfo, in_addr, in6_addr, sockaddr_storage
9292
pub use types::os::common::bsd44::{ip_mreq, ip6_mreq, sockaddr, sockaddr_un};
9393
pub use types::os::common::bsd44::{sa_family_t, sockaddr_in, sockaddr_in6, socklen_t};
9494
pub use types::os::arch::c95::{c_char, c_double, c_float, c_int, c_uint};
95-
pub use types::os::arch::c95::{c_long, c_short, c_uchar, c_ulong};
96-
pub use types::os::arch::c95::{c_ushort, clock_t, ptrdiff_t};
95+
pub use types::os::arch::c95::{c_long, c_short, c_uchar, c_ulong, wchar_t};
96+
pub use types::os::arch::c95::{c_ushort, clock_t, ptrdiff_t, c_schar};
9797
pub use types::os::arch::c95::{size_t, time_t, suseconds_t};
9898
pub use types::os::arch::c99::{c_longlong, c_ulonglong};
9999
pub use types::os::arch::c99::{intptr_t, uintptr_t};

branches/try2/src/libnative/io/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn last_error() -> io::IoError {
149149
#[cfg(unix)] unsafe fn close(sock: sock_t) { let _ = libc::close(sock); }
150150

151151
fn sockname(fd: sock_t,
152-
f: unsafe extern "system" fn(sock_t, *mut libc::sockaddr,
152+
f: extern "system" unsafe fn(sock_t, *mut libc::sockaddr,
153153
*mut libc::socklen_t) -> libc::c_int)
154154
-> IoResult<ip::SocketAddr>
155155
{

branches/try2/src/librustc/util/ppaux.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,12 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
236236
ident: Option<ast::Ident>,
237237
sig: &ty::FnSig)
238238
-> ~str {
239-
let mut s = StrBuf::new();
239+
let mut s = if abi == abi::Rust {
240+
StrBuf::new()
241+
} else {
242+
StrBuf::from_owned_str(format!("extern {} ", abi.to_str()))
243+
};
244+
240245
match fn_style {
241246
ast::NormalFn => {}
242247
_ => {
@@ -245,10 +250,6 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
245250
}
246251
};
247252

248-
if abi != abi::Rust {
249-
s.push_str(format!("extern {} ", abi.to_str()));
250-
};
251-
252253
s.push_str("fn");
253254

254255
match ident {
@@ -583,7 +584,7 @@ impl Repr for ty::ParamBounds {
583584
ty::BoundStatic => "'static".to_owned(),
584585
ty::BoundSend => "Send".to_owned(),
585586
ty::BoundSized => "Sized".to_owned(),
586-
ty::BoundCopy => "Copy".to_owned(),
587+
ty::BoundCopy => "Pod".to_owned(),
587588
ty::BoundShare => "Share".to_owned(),
588589
});
589590
}
@@ -861,7 +862,7 @@ impl UserString for ty::BuiltinBound {
861862
ty::BoundStatic => "'static".to_owned(),
862863
ty::BoundSend => "Send".to_owned(),
863864
ty::BoundSized => "Sized".to_owned(),
864-
ty::BoundCopy => "Copy".to_owned(),
865+
ty::BoundCopy => "Pod".to_owned(),
865866
ty::BoundShare => "Share".to_owned(),
866867
}
867868
}

branches/try2/src/librustdoc/clean.rs

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,15 @@ pub enum Type {
670670
ResolvedPath {
671671
pub path: Path,
672672
pub typarams: Option<Vec<TyParamBound>>,
673-
pub did: ast::DefId,
673+
pub id: ast::NodeId,
674+
},
675+
/// Same as above, but only external variants
676+
ExternalPath {
677+
pub path: Path,
678+
pub typarams: Option<Vec<TyParamBound>>,
679+
pub fqn: Vec<~str>,
680+
pub kind: TypeKind,
681+
pub krate: ast::CrateNum,
674682
},
675683
// I have no idea how to usefully use this.
676684
TyParamBinder(ast::NodeId),
@@ -707,18 +715,19 @@ pub enum Type {
707715

708716
#[deriving(Clone, Encodable, Decodable)]
709717
pub enum TypeKind {
710-
TypeEnum,
711-
TypeFunction,
712-
TypeModule,
713-
TypeStatic,
714718
TypeStruct,
719+
TypeEnum,
715720
TypeTrait,
716-
TypeVariant,
721+
TypeFunction,
717722
}
718723

719724
impl Clean<Type> for ast::Ty {
720725
fn clean(&self) -> Type {
721726
use syntax::ast::*;
727+
debug!("cleaning type `{:?}`", self);
728+
let ctxt = super::ctxtkey.get().unwrap();
729+
let codemap = ctxt.sess().codemap();
730+
debug!("span corresponds to `{}`", codemap.span_to_str(self.span));
722731
match self.node {
723732
TyNil => Unit,
724733
TyPtr(ref m) => RawPointer(m.mutbl.clean(), box m.ty.clean()),
@@ -1144,7 +1153,7 @@ pub enum ViewPath {
11441153
// use source::*;
11451154
GlobImport(ImportSource),
11461155
// use source::{a, b, c};
1147-
ImportList(ImportSource, Vec<ViewListIdent>),
1156+
ImportList(ImportSource, Vec<ViewListIdent> ),
11481157
}
11491158

11501159
#[deriving(Clone, Encodable, Decodable)]
@@ -1289,47 +1298,48 @@ fn resolve_type(path: Path, tpbs: Option<Vec<TyParamBound> >,
12891298
core::NotTyped(_) => return Bool
12901299
};
12911300
debug!("searching for {:?} in defmap", id);
1292-
let def = match tycx.def_map.borrow().find(&id) {
1301+
let d = match tycx.def_map.borrow().find(&id) {
12931302
Some(&k) => k,
1294-
None => fail!("unresolved id not in defmap")
1303+
None => {
1304+
debug!("could not find {:?} in defmap (`{}`)", id, tycx.map.node_to_str(id));
1305+
fail!("Unexpected failure: unresolved id not in defmap (this is a bug!)")
1306+
}
12951307
};
12961308

1297-
match def {
1309+
let (def_id, kind) = match d {
1310+
ast::DefFn(i, _) => (i, TypeFunction),
12981311
ast::DefSelfTy(i) => return Self(i),
1312+
ast::DefTy(i) => (i, TypeEnum),
1313+
ast::DefTrait(i) => {
1314+
debug!("saw DefTrait in def_to_id");
1315+
(i, TypeTrait)
1316+
},
12991317
ast::DefPrimTy(p) => match p {
13001318
ast::TyStr => return String,
13011319
ast::TyBool => return Bool,
13021320
_ => return Primitive(p)
13031321
},
13041322
ast::DefTyParam(i, _) => return Generic(i.node),
1305-
ast::DefTyParamBinder(i) => return TyParamBinder(i),
1306-
_ => {}
1307-
};
1308-
let did = register_def(&**cx, def);
1309-
ResolvedPath { path: path, typarams: tpbs, did: did }
1310-
}
1311-
1312-
fn register_def(cx: &core::DocContext, def: ast::Def) -> ast::DefId {
1313-
let (did, kind) = match def {
1314-
ast::DefFn(i, _) => (i, TypeFunction),
1315-
ast::DefTy(i) => (i, TypeEnum),
1316-
ast::DefTrait(i) => (i, TypeTrait),
13171323
ast::DefStruct(i) => (i, TypeStruct),
1318-
ast::DefMod(i) => (i, TypeModule),
1319-
ast::DefStatic(i, _) => (i, TypeStatic),
1320-
ast::DefVariant(i, _, _) => (i, TypeEnum),
1321-
_ => return ast_util::def_id_of_def(def),
1322-
};
1323-
if ast_util::is_local(did) { return did }
1324-
let tcx = match cx.maybe_typed {
1325-
core::Typed(ref t) => t,
1326-
core::NotTyped(_) => return did
1324+
ast::DefTyParamBinder(i) => {
1325+
debug!("found a typaram_binder, what is it? {}", i);
1326+
return TyParamBinder(i);
1327+
},
1328+
x => fail!("resolved type maps to a weird def {:?}", x),
13271329
};
1328-
let fqn = csearch::get_item_path(tcx, did);
1329-
let fqn = fqn.move_iter().map(|i| i.to_str()).collect();
1330-
debug!("recording {} => {}", did, fqn);
1331-
cx.external_paths.borrow_mut().get_mut_ref().insert(did, (fqn, kind));
1332-
return did;
1330+
if ast_util::is_local(def_id) {
1331+
ResolvedPath{ path: path, typarams: tpbs, id: def_id.node }
1332+
} else {
1333+
let fqn = csearch::get_item_path(tycx, def_id);
1334+
let fqn = fqn.move_iter().map(|i| i.to_str()).collect();
1335+
ExternalPath {
1336+
path: path,
1337+
typarams: tpbs,
1338+
fqn: fqn,
1339+
kind: kind,
1340+
krate: def_id.krate,
1341+
}
1342+
}
13331343
}
13341344

13351345
fn resolve_use_source(path: Path, id: ast::NodeId) -> ImportSource {
@@ -1343,7 +1353,7 @@ fn resolve_def(id: ast::NodeId) -> Option<ast::DefId> {
13431353
let cx = super::ctxtkey.get().unwrap();
13441354
match cx.maybe_typed {
13451355
core::Typed(ref tcx) => {
1346-
tcx.def_map.borrow().find(&id).map(|&def| register_def(&**cx, def))
1356+
tcx.def_map.borrow().find(&id).map(|&d| ast_util::def_id_of_def(d))
13471357
}
13481358
core::NotTyped(_) => None
13491359
}

branches/try2/src/librustdoc/core.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use syntax;
2020

2121
use std::cell::RefCell;
2222
use std::os;
23-
use collections::{HashSet, HashMap};
23+
use collections::HashSet;
2424

2525
use visit_ast::RustdocVisitor;
2626
use clean;
@@ -31,14 +31,10 @@ pub enum MaybeTyped {
3131
NotTyped(driver::session::Session)
3232
}
3333

34-
pub type ExternalPaths = RefCell<Option<HashMap<ast::DefId,
35-
(Vec<~str>, clean::TypeKind)>>>;
36-
3734
pub struct DocContext {
3835
pub krate: ast::Crate,
3936
pub maybe_typed: MaybeTyped,
4037
pub src: Path,
41-
pub external_paths: ExternalPaths,
4238
}
4339

4440
impl DocContext {
@@ -53,7 +49,6 @@ impl DocContext {
5349
pub struct CrateAnalysis {
5450
pub exported_items: privacy::ExportedItems,
5551
pub public_items: privacy::PublicItems,
56-
pub external_paths: ExternalPaths,
5752
}
5853

5954
/// Parses, resolves, and typechecks the given crate
@@ -103,11 +98,9 @@ fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<~str>)
10398
krate: krate,
10499
maybe_typed: Typed(ty_cx),
105100
src: cpath.clone(),
106-
external_paths: RefCell::new(Some(HashMap::new())),
107101
}, CrateAnalysis {
108102
exported_items: exported_items,
109103
public_items: public_items,
110-
external_paths: RefCell::new(None),
111104
})
112105
}
113106

@@ -123,7 +116,5 @@ pub fn run_core(libs: HashSet<Path>, cfgs: Vec<~str>, path: &Path)
123116
v.clean()
124117
};
125118

126-
let external_paths = ctxt.external_paths.borrow_mut().take();
127-
*analysis.external_paths.borrow_mut() = external_paths;
128119
(krate, analysis)
129120
}

0 commit comments

Comments
 (0)