Skip to content

Commit f1b0747

Browse files
committed
---
yaml --- r: 151518 b: refs/heads/try2 c: 11571cd h: refs/heads/master v: v3
1 parent 815e957 commit f1b0747

File tree

30 files changed

+224
-221
lines changed

30 files changed

+224
-221
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: 4cbd7754ea7277aa3e4ae20492e2bfca81e4cd11
8+
refs/heads/try2: 11571cd9c1cde63c3b46ca65e608b84647785ac8
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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ 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] or [extra]
21-
libraries included in the language distribution. Those libraries are
20+
This document also does not serve as a reference to the [standard]
21+
library 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
2827

2928
## Disclaimer
3029

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

Lines changed: 16 additions & 11 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=do,for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
16+
setlocal cinwords=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,11 +115,16 @@ function GetRustIndent(lnum)
115115
" };
116116

117117
" Search backwards for the previous non-empty line.
118-
let prevline = s:get_line_trimmed(prevnonblank(a:lnum - 1))
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
119124
if prevline[len(prevline) - 1] == ","
120-
\ && s:get_line_trimmed(a:lnum) !~ "^\\s*[\\[\\]{}]"
121-
\ && prevline !~ "^\\s*fn\\s"
122-
\ && prevline !~ "([^()]\\+,$"
125+
\ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]'
126+
\ && prevline !~ '^\s*fn\s'
127+
\ && prevline !~ '([^()]\+,$'
123128
" Oh ho! The previous line ended in a comma! I bet cindent will try to
124129
" take this too far... For now, let's normally use the previous line's
125130
" indent.
@@ -166,7 +171,7 @@ function GetRustIndent(lnum)
166171
" column zero)
167172

168173
call cursor(a:lnum, 1)
169-
if searchpair('{\|(', '', '}\|)', 'nbW'
174+
if searchpair('{\|(', '', '}\|)', 'nbW',
170175
\ 's:is_string_comment(line("."), col("."))') == 0
171176
if searchpair('\[', '', '\]', 'nbW',
172177
\ '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: extern unsafe fn(ptr: *Opaque) -> Disr,
140+
get_disr: unsafe extern 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: extern unsafe fn(ptr: *Opaque) -> Disr,
152+
get_disr: unsafe extern 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](../io/index.html).
27+
//! for [I/O](../../std/io/index.html).
2828
//!
2929
//! A simple function returning `Result` might be
3030
//! defined and used like so:

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: extern "system" unsafe fn(sock_t, *mut libc::sockaddr,
152+
f: unsafe extern "system" 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: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,7 @@ 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 = if abi == abi::Rust {
240-
StrBuf::new()
241-
} else {
242-
StrBuf::from_owned_str(format!("extern {} ", abi.to_str()))
243-
};
244-
239+
let mut s = StrBuf::new();
245240
match fn_style {
246241
ast::NormalFn => {}
247242
_ => {
@@ -250,6 +245,10 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
250245
}
251246
};
252247

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

255254
match ident {
@@ -584,7 +583,7 @@ impl Repr for ty::ParamBounds {
584583
ty::BoundStatic => "'static".to_owned(),
585584
ty::BoundSend => "Send".to_owned(),
586585
ty::BoundSized => "Sized".to_owned(),
587-
ty::BoundCopy => "Pod".to_owned(),
586+
ty::BoundCopy => "Copy".to_owned(),
588587
ty::BoundShare => "Share".to_owned(),
589588
});
590589
}
@@ -862,7 +861,7 @@ impl UserString for ty::BuiltinBound {
862861
ty::BoundStatic => "'static".to_owned(),
863862
ty::BoundSend => "Send".to_owned(),
864863
ty::BoundSized => "Sized".to_owned(),
865-
ty::BoundCopy => "Pod".to_owned(),
864+
ty::BoundCopy => "Copy".to_owned(),
866865
ty::BoundShare => "Share".to_owned(),
867866
}
868867
}

branches/try2/src/librustdoc/clean.rs

Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -670,15 +670,7 @@ pub enum Type {
670670
ResolvedPath {
671671
pub path: Path,
672672
pub typarams: Option<Vec<TyParamBound>>,
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,
673+
pub did: ast::DefId,
682674
},
683675
// I have no idea how to usefully use this.
684676
TyParamBinder(ast::NodeId),
@@ -715,19 +707,18 @@ pub enum Type {
715707

716708
#[deriving(Clone, Encodable, Decodable)]
717709
pub enum TypeKind {
718-
TypeStruct,
719710
TypeEnum,
720-
TypeTrait,
721711
TypeFunction,
712+
TypeModule,
713+
TypeStatic,
714+
TypeStruct,
715+
TypeTrait,
716+
TypeVariant,
722717
}
723718

724719
impl Clean<Type> for ast::Ty {
725720
fn clean(&self) -> Type {
726721
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));
731722
match self.node {
732723
TyNil => Unit,
733724
TyPtr(ref m) => RawPointer(m.mutbl.clean(), box m.ty.clean()),
@@ -1153,7 +1144,7 @@ pub enum ViewPath {
11531144
// use source::*;
11541145
GlobImport(ImportSource),
11551146
// use source::{a, b, c};
1156-
ImportList(ImportSource, Vec<ViewListIdent> ),
1147+
ImportList(ImportSource, Vec<ViewListIdent>),
11571148
}
11581149

11591150
#[deriving(Clone, Encodable, Decodable)]
@@ -1298,48 +1289,47 @@ fn resolve_type(path: Path, tpbs: Option<Vec<TyParamBound> >,
12981289
core::NotTyped(_) => return Bool
12991290
};
13001291
debug!("searching for {:?} in defmap", id);
1301-
let d = match tycx.def_map.borrow().find(&id) {
1292+
let def = match tycx.def_map.borrow().find(&id) {
13021293
Some(&k) => k,
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-
}
1294+
None => fail!("unresolved id not in defmap")
13071295
};
13081296

1309-
let (def_id, kind) = match d {
1310-
ast::DefFn(i, _) => (i, TypeFunction),
1297+
match def {
13111298
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-
},
13171299
ast::DefPrimTy(p) => match p {
13181300
ast::TyStr => return String,
13191301
ast::TyBool => return Bool,
13201302
_ => return Primitive(p)
13211303
},
13221304
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),
13231317
ast::DefStruct(i) => (i, TypeStruct),
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),
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),
13291322
};
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-
}
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
1327+
};
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;
13431333
}
13441334

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

branches/try2/src/librustdoc/core.rs

Lines changed: 10 additions & 1 deletion
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;
23+
use collections::{HashSet, HashMap};
2424

2525
use visit_ast::RustdocVisitor;
2626
use clean;
@@ -31,10 +31,14 @@ 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+
3437
pub struct DocContext {
3538
pub krate: ast::Crate,
3639
pub maybe_typed: MaybeTyped,
3740
pub src: Path,
41+
pub external_paths: ExternalPaths,
3842
}
3943

4044
impl DocContext {
@@ -49,6 +53,7 @@ impl DocContext {
4953
pub struct CrateAnalysis {
5054
pub exported_items: privacy::ExportedItems,
5155
pub public_items: privacy::PublicItems,
56+
pub external_paths: ExternalPaths,
5257
}
5358

5459
/// Parses, resolves, and typechecks the given crate
@@ -98,9 +103,11 @@ fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<~str>)
98103
krate: krate,
99104
maybe_typed: Typed(ty_cx),
100105
src: cpath.clone(),
106+
external_paths: RefCell::new(Some(HashMap::new())),
101107
}, CrateAnalysis {
102108
exported_items: exported_items,
103109
public_items: public_items,
110+
external_paths: RefCell::new(None),
104111
})
105112
}
106113

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

126+
let external_paths = ctxt.external_paths.borrow_mut().take();
127+
*analysis.external_paths.borrow_mut() = external_paths;
119128
(krate, analysis)
120129
}

0 commit comments

Comments
 (0)