Skip to content

Commit 274cca6

Browse files
committed
---
yaml --- r: 81919 b: refs/heads/master c: 6a277dc h: refs/heads/master i: 81917: 7e76e5e 81915: 1b53e24 81911: d9e73dd 81903: d1a2dd3 81887: 58d2b2e 81855: a5a02cb 81791: 32df69f 81663: 59ac411 81407: 67f0ced 80895: 383da1e 79871: 1eafa6b 77823: 4cf0634 73727: d50f3f3 65535: 51466fe v: v3
1 parent dd69412 commit 274cca6

File tree

11 files changed

+188
-207
lines changed

11 files changed

+188
-207
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 47f2e80b65bf814953c0ceda3b48e46802883f4b
2+
refs/heads/master: 6a277dc4ba7f29e5a429e763f6faba3041b90c94
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/src/librustdoc/clean.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ pub enum ItemEnum {
149149
MethodItem(Method),
150150
StructFieldItem(StructField),
151151
VariantItem(Variant),
152+
ForeignFunctionItem(Function),
153+
ForeignStaticItem(Static),
152154
}
153155

154156
#[deriving(Clone, Encodable, Decodable)]
@@ -172,6 +174,7 @@ impl Clean<Item> for doctree::Module {
172174
inner: ModuleItem(Module {
173175
items: std::vec::concat(&[self.structs.clean(),
174176
self.enums.clean(), self.fns.clean(),
177+
std::vec::concat(self.foreigns.clean()),
175178
self.mods.clean(), self.typedefs.clean(),
176179
self.statics.clean(), self.traits.clean(),
177180
self.impls.clean(), self.view_items.clean()])
@@ -968,6 +971,41 @@ impl Clean<ViewListIdent> for ast::path_list_ident {
968971
}
969972
}
970973

974+
impl Clean<~[Item]> for ast::foreign_mod {
975+
fn clean(&self) -> ~[Item] {
976+
self.items.clean()
977+
}
978+
}
979+
980+
impl Clean<Item> for ast::foreign_item {
981+
fn clean(&self) -> Item {
982+
let inner = match self.node {
983+
ast::foreign_item_fn(ref decl, ref generics) => {
984+
ForeignFunctionItem(Function {
985+
decl: decl.clean(),
986+
generics: generics.clean(),
987+
purity: ast::extern_fn,
988+
})
989+
}
990+
ast::foreign_item_static(ref ty, mutbl) => {
991+
ForeignStaticItem(Static {
992+
type_: ty.clean(),
993+
mutability: if mutbl {Mutable} else {Immutable},
994+
expr: ~"",
995+
})
996+
}
997+
};
998+
Item {
999+
name: Some(self.ident.clean()),
1000+
attrs: self.attrs.clean(),
1001+
source: self.span.clean(),
1002+
id: self.id,
1003+
visibility: self.vis.clean(),
1004+
inner: inner,
1005+
}
1006+
}
1007+
}
1008+
9711009
// Utilities
9721010

9731011
trait ToSource {

trunk/src/librustdoc/doctree.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub struct Module {
3030
traits: ~[Trait],
3131
vis: ast::visibility,
3232
impls: ~[Impl],
33+
foreigns: ~[ast::foreign_mod],
3334
view_items: ~[ast::view_item],
3435
}
3536

@@ -50,6 +51,7 @@ impl Module {
5051
traits : ~[],
5152
impls : ~[],
5253
view_items : ~[],
54+
foreigns : ~[],
5355
}
5456
}
5557
}

trunk/src/librustdoc/html/render.rs

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,14 @@ impl Context {
521521
}
522522
}
523523
}
524+
clean::StructItem(s) => {
525+
let mut it = s.fields.move_iter();
526+
do self.recurse(name) |this| {
527+
for item in it {
528+
f(this, item);
529+
}
530+
}
531+
}
524532
_ => {}
525533
}
526534
}
@@ -532,19 +540,21 @@ impl Context {
532540

533541
fn shortty(item: &clean::Item) -> &'static str {
534542
match item.inner {
535-
clean::ModuleItem(*) => "mod",
536-
clean::StructItem(*) => "struct",
537-
clean::EnumItem(*) => "enum",
538-
clean::FunctionItem(*) => "fn",
539-
clean::TypedefItem(*) => "typedef",
540-
clean::StaticItem(*) => "static",
541-
clean::TraitItem(*) => "trait",
542-
clean::ImplItem(*) => "impl",
543-
clean::ViewItemItem(*) => "viewitem",
544-
clean::TyMethodItem(*) => "tymethod",
545-
clean::MethodItem(*) => "method",
546-
clean::StructFieldItem(*) => "structfield",
547-
clean::VariantItem(*) => "variant",
543+
clean::ModuleItem(*) => "mod",
544+
clean::StructItem(*) => "struct",
545+
clean::EnumItem(*) => "enum",
546+
clean::FunctionItem(*) => "fn",
547+
clean::TypedefItem(*) => "typedef",
548+
clean::StaticItem(*) => "static",
549+
clean::TraitItem(*) => "trait",
550+
clean::ImplItem(*) => "impl",
551+
clean::ViewItemItem(*) => "viewitem",
552+
clean::TyMethodItem(*) => "tymethod",
553+
clean::MethodItem(*) => "method",
554+
clean::StructFieldItem(*) => "structfield",
555+
clean::VariantItem(*) => "variant",
556+
clean::ForeignFunctionItem(*) => "ffi",
557+
clean::ForeignStaticItem(*) => "ffs",
548558
}
549559
}
550560

@@ -584,12 +594,15 @@ impl<'self> fmt::Default for Item<'self> {
584594
match it.item.inner {
585595
clean::ModuleItem(ref m) => item_module(fmt.buf, it.cx,
586596
it.item, m.items),
587-
clean::FunctionItem(ref f) => item_function(fmt.buf, it.item, f),
597+
clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) =>
598+
item_function(fmt.buf, it.item, f),
588599
clean::TraitItem(ref t) => item_trait(fmt.buf, it.item, t),
589600
clean::StructItem(ref s) => item_struct(fmt.buf, it.item, s),
590601
clean::EnumItem(ref e) => item_enum(fmt.buf, it.item, e),
591602
clean::TypedefItem(ref t) => item_typedef(fmt.buf, it.item, t),
592603
clean::VariantItem(*) => item_variant(fmt.buf, it.cx, it.item),
604+
clean::StructFieldItem(*) => item_struct_field(fmt.buf, it.cx,
605+
it.item),
593606
_ => {}
594607
}
595608
}
@@ -663,6 +676,10 @@ fn item_module(w: &mut io::Writer, cx: &Context,
663676
(_, &clean::EnumItem(*)) => false,
664677
(&clean::StaticItem(*), _) => true,
665678
(_, &clean::StaticItem(*)) => false,
679+
(&clean::ForeignFunctionItem(*), _) => true,
680+
(_, &clean::ForeignFunctionItem(*)) => false,
681+
(&clean::ForeignStaticItem(*), _) => true,
682+
(_, &clean::ForeignStaticItem(*)) => false,
666683
(&clean::TraitItem(*), _) => true,
667684
(_, &clean::TraitItem(*)) => false,
668685
(&clean::FunctionItem(*), _) => true,
@@ -690,27 +707,31 @@ fn item_module(w: &mut io::Writer, cx: &Context,
690707
}
691708
curty = myty;
692709
write!(w, "<h2>{}</h2>\n<table>", match myitem.inner {
693-
clean::ModuleItem(*) => "Modules",
694-
clean::StructItem(*) => "Structs",
695-
clean::EnumItem(*) => "Enums",
696-
clean::FunctionItem(*) => "Functions",
697-
clean::TypedefItem(*) => "Type Definitions",
698-
clean::StaticItem(*) => "Statics",
699-
clean::TraitItem(*) => "Traits",
700-
clean::ImplItem(*) => "Implementations",
701-
clean::ViewItemItem(*) => "Reexports",
702-
clean::TyMethodItem(*) => "Type Methods",
703-
clean::MethodItem(*) => "Methods",
704-
clean::StructFieldItem(*) => "Struct Fields",
705-
clean::VariantItem(*) => "Variants",
710+
clean::ModuleItem(*) => "Modules",
711+
clean::StructItem(*) => "Structs",
712+
clean::EnumItem(*) => "Enums",
713+
clean::FunctionItem(*) => "Functions",
714+
clean::TypedefItem(*) => "Type Definitions",
715+
clean::StaticItem(*) => "Statics",
716+
clean::TraitItem(*) => "Traits",
717+
clean::ImplItem(*) => "Implementations",
718+
clean::ViewItemItem(*) => "Reexports",
719+
clean::TyMethodItem(*) => "Type Methods",
720+
clean::MethodItem(*) => "Methods",
721+
clean::StructFieldItem(*) => "Struct Fields",
722+
clean::VariantItem(*) => "Variants",
723+
clean::ForeignFunctionItem(*) => "Foreign Functions",
724+
clean::ForeignStaticItem(*) => "Foreign Statics",
706725
});
707726
}
708727

709728
match myitem.inner {
710-
clean::StaticItem(ref s) => {
729+
clean::StaticItem(ref s) | clean::ForeignStaticItem(ref s) => {
711730
struct Initializer<'self>(&'self str);
712731
impl<'self> fmt::Default for Initializer<'self> {
713732
fn fmt(s: &Initializer<'self>, f: &mut fmt::Formatter) {
733+
if s.len() == 0 { return; }
734+
write!(f.buf, "<code> = </code>");
714735
let tag = if s.contains("\n") { "pre" } else { "code" };
715736
write!(f.buf, "<{tag}>{}</{tag}>",
716737
s.as_slice(), tag=tag);
@@ -719,7 +740,7 @@ fn item_module(w: &mut io::Writer, cx: &Context,
719740

720741
write!(w, "
721742
<tr>
722-
<td><code>{}static {}: {} = </code>{}</td>
743+
<td><code>{}static {}: {}</code>{}</td>
723744
<td class='docblock'>{}&nbsp;</td>
724745
</tr>
725746
",
@@ -980,11 +1001,12 @@ fn render_struct(w: &mut io::Writer, it: &clean::Item,
9801001
for field in fields.iter() {
9811002
match field.inner {
9821003
clean::StructFieldItem(ref ty) => {
983-
write!(w, " {}{}: {},\n{}",
1004+
write!(w, " {}<a name='field.{name}'>{name}</a>: \
1005+
{},\n{}",
9841006
VisSpace(field.visibility),
985-
field.name.get_ref().as_slice(),
9861007
ty.type_,
987-
tab);
1008+
tab,
1009+
name = field.name.get_ref().as_slice());
9881010
}
9891011
_ => unreachable!()
9901012
}
@@ -1170,3 +1192,12 @@ fn item_variant(w: &mut io::Writer, cx: &Context, it: &clean::Item) {
11701192
*cx.current.last(),
11711193
it.name.get_ref().as_slice());
11721194
}
1195+
1196+
fn item_struct_field(w: &mut io::Writer, cx: &Context, it: &clean::Item) {
1197+
write!(w, "<DOCTYPE html><html><head>\
1198+
<meta http-equiv='refresh' content='0; \
1199+
url=../struct.{}.html\\#field.{}'>\
1200+
</head><body></body></html>",
1201+
*cx.current.last(),
1202+
it.name.get_ref().as_slice());
1203+
}

trunk/src/librustdoc/passes.rs

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use std::num;
1212
use std::uint;
13+
use std::hashmap::HashSet;
1314

1415
use syntax::ast;
1516

@@ -50,16 +51,18 @@ pub fn strip_hidden(crate: clean::Crate) -> plugins::PluginResult {
5051

5152
/// Strip private items from the point of view of a crate or externally from a
5253
/// crate, specified by the `xcrate` flag.
53-
pub fn strip_private(crate: clean::Crate) -> plugins::PluginResult {
54-
struct Stripper;
55-
impl fold::DocFolder for Stripper {
54+
pub fn strip_private(mut crate: clean::Crate) -> plugins::PluginResult {
55+
// This stripper collects all *retained* nodes.
56+
struct Stripper<'self>(&'self mut HashSet<ast::NodeId>);
57+
impl<'self> fold::DocFolder for Stripper<'self> {
5658
fn fold_item(&mut self, i: Item) -> Option<Item> {
5759
match i.inner {
5860
// These items can all get re-exported
5961
clean::TypedefItem(*) | clean::StaticItem(*) |
6062
clean::StructItem(*) | clean::EnumItem(*) |
6163
clean::TraitItem(*) | clean::FunctionItem(*) |
62-
clean::ViewItemItem(*) | clean::MethodItem(*) => {
64+
clean::ViewItemItem(*) | clean::MethodItem(*) |
65+
clean::ForeignFunctionItem(*) | clean::ForeignStaticItem(*) => {
6366
// XXX: re-exported items should get surfaced in the docs as
6467
// well (using the output of resolve analysis)
6568
if i.visibility != Some(ast::public) {
@@ -97,6 +100,7 @@ pub fn strip_private(crate: clean::Crate) -> plugins::PluginResult {
97100
};
98101

99102
let i = if fastreturn {
103+
self.insert(i.id);
100104
return Some(i);
101105
} else {
102106
self.fold_item_recur(i)
@@ -108,15 +112,50 @@ pub fn strip_private(crate: clean::Crate) -> plugins::PluginResult {
108112
// emptied modules/impls have no need to exist
109113
clean::ModuleItem(ref m) if m.items.len() == 0 => None,
110114
clean::ImplItem(ref i) if i.methods.len() == 0 => None,
111-
_ => Some(i),
115+
_ => {
116+
self.insert(i.id);
117+
Some(i)
118+
}
112119
}
113120
}
114121
None => None,
115122
}
116123
}
117124
}
118-
let mut stripper = Stripper;
119-
let crate = stripper.fold_crate(crate);
125+
126+
// This stripper discards all private impls of traits
127+
struct ImplStripper<'self>(&'self HashSet<ast::NodeId>);
128+
impl<'self> fold::DocFolder for ImplStripper<'self> {
129+
fn fold_item(&mut self, i: Item) -> Option<Item> {
130+
match i.inner {
131+
clean::ImplItem(ref imp) => {
132+
match imp.trait_ {
133+
Some(clean::ResolvedPath{ id, _ }) => {
134+
if !self.contains(&id) {
135+
return None;
136+
}
137+
}
138+
Some(*) | None => {}
139+
}
140+
}
141+
_ => {}
142+
}
143+
self.fold_item_recur(i)
144+
}
145+
}
146+
147+
let mut retained = HashSet::new();
148+
// First, strip all private items
149+
{
150+
let mut stripper = Stripper(&mut retained);
151+
crate = stripper.fold_crate(crate);
152+
}
153+
154+
// Next, strip all private implementations of traits
155+
{
156+
let mut stripper = ImplStripper(&retained);
157+
crate = stripper.fold_crate(crate);
158+
}
120159
(crate, None)
121160
}
122161

trunk/src/librustdoc/visit_ast.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ impl RustdocVisitor {
174174
};
175175
om.impls.push(i);
176176
},
177+
ast::item_foreign_mod(ref fm) => {
178+
om.foreigns.push(fm.clone());
179+
}
177180
_ => (),
178181
}
179182
}

trunk/src/libstd/rt/comm.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,6 @@ impl<T> ChanOne<T> {
118118
rtassert!(!rt::in_sched_context());
119119
}
120120

121-
// In order to prevent starvation of other tasks in situations
122-
// where a task sends repeatedly without ever receiving, we
123-
// occassionally yield instead of doing a send immediately.
124-
// Only doing this if we're doing a rescheduling send,
125-
// otherwise the caller is expecting not to context switch.
126-
if do_resched {
127-
// XXX: This TLS hit should be combined with other uses of the scheduler below
128-
let sched: ~Scheduler = Local::take();
129-
sched.maybe_yield();
130-
}
131-
132121
let mut this = self;
133122
let mut recvr_active = true;
134123
let packet = this.packet();

0 commit comments

Comments
 (0)