Skip to content

Commit 4a3a752

Browse files
committed
---
yaml --- r: 82727 b: refs/heads/auto c: c5e03be h: refs/heads/master i: 82725: 7ef9e4e 82723: d611337 82719: 9657ce4 v: v3
1 parent 0a06480 commit 4a3a752

File tree

6 files changed

+63
-71
lines changed

6 files changed

+63
-71
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 78c3fac85292fc3083def6913cc934d9e20893c1
16+
refs/heads/auto: c5e03bec4d1e7655fc0fd13922fbebb3001f6bac
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustdoc/html/render.rs

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ impl<'self> DocFolder for Cache {
248248
match item.name {
249249
Some(ref s) => {
250250
let parent = match item.inner {
251-
clean::TyMethodItem(*) | clean::VariantItem(*) => {
251+
clean::TyMethodItem(*) |
252+
clean::StructFieldItem(*) |
253+
clean::VariantItem(*) => {
252254
Some((Some(*self.parent_stack.last()),
253255
self.stack.slice_to(self.stack.len() - 1)))
254256

@@ -299,7 +301,7 @@ impl<'self> DocFolder for Cache {
299301

300302
// Maintain the parent stack
301303
let parent_pushed = match item.inner {
302-
clean::TraitItem(*) | clean::EnumItem(*) => {
304+
clean::TraitItem(*) | clean::EnumItem(*) | clean::StructItem(*) => {
303305
self.parent_stack.push(item.id); true
304306
}
305307
clean::ImplItem(ref i) => {
@@ -510,28 +512,6 @@ impl Context {
510512
let dst = self.dst.push(item_path(&item));
511513
let writer = dst.open_writer(io::CreateOrTruncate);
512514
render(writer.unwrap(), self, &item, true);
513-
514-
// recurse if necessary
515-
let name = item.name.get_ref().clone();
516-
match item.inner {
517-
clean::EnumItem(e) => {
518-
let mut it = e.variants.move_iter();
519-
do self.recurse(name) |this| {
520-
for item in it {
521-
f(this, item);
522-
}
523-
}
524-
}
525-
clean::StructItem(s) => {
526-
let mut it = s.fields.move_iter();
527-
do self.recurse(name) |this| {
528-
for item in it {
529-
f(this, item);
530-
}
531-
}
532-
}
533-
_ => {}
534-
}
535515
}
536516

537517
_ => {}
@@ -613,9 +593,6 @@ impl<'self> fmt::Default for Item<'self> {
613593
clean::StructItem(ref s) => item_struct(fmt.buf, it.item, s),
614594
clean::EnumItem(ref e) => item_enum(fmt.buf, it.item, e),
615595
clean::TypedefItem(ref t) => item_typedef(fmt.buf, it.item, t),
616-
clean::VariantItem(*) => item_variant(fmt.buf, it.cx, it.item),
617-
clean::StructFieldItem(*) => item_struct_field(fmt.buf, it.cx,
618-
it.item),
619596
_ => {}
620597
}
621598
}
@@ -862,7 +839,8 @@ fn item_trait(w: &mut io::Writer, it: &clean::Item, t: &clean::Trait) {
862839
document(w, it);
863840

864841
fn meth(w: &mut io::Writer, m: &clean::TraitMethod) {
865-
write!(w, "<h3 id='fn.{}' class='method'><code>",
842+
write!(w, "<h3 id='{}.{}' class='method'><code>",
843+
shortty(m.item()),
866844
*m.item().name.get_ref());
867845
render_method(w, m.item(), false);
868846
write!(w, "</code></h3>");
@@ -923,13 +901,15 @@ fn render_method(w: &mut io::Writer, meth: &clean::Item, withlink: bool) {
923901
g: &clean::Generics, selfty: &clean::SelfTy, d: &clean::FnDecl,
924902
withlink: bool) {
925903
write!(w, "{}fn {withlink, select,
926-
true{<a href='\\#fn.{name}' class='fnname'>{name}</a>}
904+
true{<a href='\\#{ty}.{name}'
905+
class='fnname'>{name}</a>}
927906
other{<span class='fnname'>{name}</span>}
928907
}{generics}{decl}",
929908
match purity {
930909
ast::unsafe_fn => "unsafe ",
931910
_ => "",
932911
},
912+
ty = shortty(it),
933913
name = it.name.get_ref().as_slice(),
934914
generics = *g,
935915
decl = Method(selfty, d),
@@ -1014,7 +994,7 @@ fn render_struct(w: &mut io::Writer, it: &clean::Item,
1014994
for field in fields.iter() {
1015995
match field.inner {
1016996
clean::StructFieldItem(ref ty) => {
1017-
write!(w, " {}<a name='field.{name}'>{name}</a>: \
997+
write!(w, " {}<a name='structfield.{name}'>{name}</a>: \
1018998
{},\n{}",
1019999
VisSpace(field.visibility),
10201000
ty.type_,
@@ -1089,7 +1069,7 @@ fn render_impl(w: &mut io::Writer, i: &clean::Impl) {
10891069
write!(w, "{}</code></h3>", i.for_);
10901070
write!(w, "<div class='methods'>");
10911071
for meth in i.methods.iter() {
1092-
write!(w, "<h4 id='fn.{}' class='method'><code>",
1072+
write!(w, "<h4 id='method.{}' class='method'><code>",
10931073
*meth.name.get_ref());
10941074
render_method(w, meth, false);
10951075
write!(w, "</code></h4>\n");
@@ -1159,12 +1139,11 @@ impl<'self> fmt::Default for Sidebar<'self> {
11591139
write!(w, "<a class='{ty} {class}' href='{curty, select,
11601140
mod{../}
11611141
other{}
1162-
}{tysel, select,
1142+
}{ty, select,
11631143
mod{{name}/index.html}
11641144
other{#.{name}.html}
11651145
}'>{name}</a><br/>",
11661146
ty = short,
1167-
tysel = short,
11681147
class = class,
11691148
curty = shortty(cur),
11701149
name = item.as_slice());
@@ -1197,21 +1176,3 @@ fn build_sidebar(m: &clean::Module) -> HashMap<~str, ~[~str]> {
11971176
}
11981177
return map;
11991178
}
1200-
1201-
fn item_variant(w: &mut io::Writer, cx: &Context, it: &clean::Item) {
1202-
write!(w, "<DOCTYPE html><html><head>\
1203-
<meta http-equiv='refresh' content='0; \
1204-
url=../enum.{}.html\\#variant.{}'>\
1205-
</head><body></body></html>",
1206-
*cx.current.last(),
1207-
it.name.get_ref().as_slice());
1208-
}
1209-
1210-
fn item_struct_field(w: &mut io::Writer, cx: &Context, it: &clean::Item) {
1211-
write!(w, "<DOCTYPE html><html><head>\
1212-
<meta http-equiv='refresh' content='0; \
1213-
url=../struct.{}.html\\#field.{}'>\
1214-
</head><body></body></html>",
1215-
*cx.current.last(),
1216-
it.name.get_ref().as_slice());
1217-
}

branches/auto/src/librustdoc/html/static/main.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,25 +265,52 @@
265265
output += '<tr class="' + type + ' result"><td>';
266266

267267
if (type === 'mod') {
268-
output += item.path + '::<a href="' + rootPath + item.path.replace(/::/g, '/') + '/' + name + '/index.html" class="' + type + '">' + name + '</a>';
268+
output += item.path +
269+
'::<a href="' + rootPath +
270+
item.path.replace(/::/g, '/') + '/' +
271+
name + '/index.html" class="' +
272+
type + '">' + name + '</a>';
269273
} else if (type === 'static' || type === 'reexport') {
270-
output += item.path + '::<a href="' + rootPath + item.path.replace(/::/g, '/') + '/index.html" class="' + type + '">' + name + '</a>';
274+
output += item.path +
275+
'::<a href="' + rootPath +
276+
item.path.replace(/::/g, '/') +
277+
'/index.html" class="' + type +
278+
'">' + name + '</a>';
271279
} else if (item.parent !== undefined) {
280+
console.log(item);
272281
var myparent = allPaths[item.parent];
273-
output += item.path + '::' + myparent.name + '::<a href="' + rootPath + item.path.replace(/::/g, '/') + '/' + myparent.type + '.' + myparent.name + '.html" class="' + type + '">' + name + '</a>';
282+
var anchor = '#' + type + '.' + name;
283+
output += item.path + '::' + myparent.name +
284+
'::<a href="' + rootPath +
285+
item.path.replace(/::/g, '/') +
286+
'/' + myparent.type +
287+
'.' + myparent.name +
288+
'.html' + anchor +
289+
'" class="' + type +
290+
'">' + name + '</a>';
274291
} else {
275-
output += item.path + '::<a href="' + rootPath + item.path.replace(/::/g, '/') + '/' + type + '.' + name + '.html" class="' + type + '">' + name + '</a>';
292+
output += item.path +
293+
'::<a href="' + rootPath +
294+
item.path.replace(/::/g, '/') +
295+
'/' + type +
296+
'.' + name +
297+
'.html" class="' + type +
298+
'">' + name + '</a>';
276299
}
277300

278-
output += '</td><td><span class="desc">' + item.desc + '</span></td></tr>';
301+
output += '</td><td><span class="desc">' + item.desc +
302+
'</span></td></tr>';
279303
});
280304
} else {
281-
output += 'No results :( <a href="https://duckduckgo.com/?q=' + encodeURIComponent('rust ' + query.query) + '">Try on DuckDuckGo?</a>';
305+
output += 'No results :( <a href="https://duckduckgo.com/?q=' +
306+
encodeURIComponent('rust ' + query.query) +
307+
'">Try on DuckDuckGo?</a>';
282308
}
283309

284310
output += "</p>";
285311
$('.content').html(output);
286-
$('.search-results .desc').width($('.content').width() - 40 - $('.content td:first-child').first().width());
312+
$('.search-results .desc').width($('.content').width() - 40 -
313+
$('.content td:first-child').first().width());
287314
initSearchNav();
288315
}
289316

branches/auto/src/libsyntax/ext/format.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use std::vec;
2222

2323
#[deriving(Eq)]
2424
enum ArgumentType {
25+
Unknown,
2526
Known(@str),
2627
Unsigned,
2728
String,
@@ -152,13 +153,14 @@ impl Context {
152153
parse::ArgumentIs(i) => Left(i),
153154
parse::ArgumentNamed(s) => Right(s.to_managed()),
154155
};
156+
let ty = if arg.format.ty == "" {
157+
Unknown
158+
} else { Known(arg.format.ty.to_managed()) };
159+
self.verify_arg_type(pos, ty);
155160

156161
// and finally the method being applied
157162
match arg.method {
158-
None => {
159-
let ty = Known(arg.format.ty.to_managed());
160-
self.verify_arg_type(pos, ty);
161-
}
163+
None => {}
162164
Some(ref method) => { self.verify_method(pos, *method); }
163165
}
164166
}
@@ -251,7 +253,7 @@ impl Context {
251253
return;
252254
}
253255
self.verify_same(self.args[arg].span, ty, self.arg_types[arg]);
254-
if self.arg_types[arg].is_none() {
256+
if ty != Unknown || self.arg_types[arg].is_none() {
255257
self.arg_types[arg] = Some(ty);
256258
}
257259
}
@@ -267,7 +269,7 @@ impl Context {
267269
};
268270
self.verify_same(span, ty,
269271
self.name_types.find(&name).map(|&x| *x));
270-
if !self.name_types.contains_key(&name) {
272+
if ty != Unknown || !self.name_types.contains_key(&name) {
271273
self.name_types.insert(name, ty);
272274
}
273275
// Assign this named argument a slot in the arguments array if
@@ -290,8 +292,9 @@ impl Context {
290292
/// that: `Some(None) == Some(Some(x))`
291293
fn verify_same(&self, sp: Span, ty: ArgumentType,
292294
before: Option<ArgumentType>) {
295+
if ty == Unknown { return }
293296
let cur = match before {
294-
None => return,
297+
Some(Unknown) | None => return,
295298
Some(t) => t,
296299
};
297300
if ty == cur { return }
@@ -646,9 +649,9 @@ impl Context {
646649
};
647650

648651
let fmt_trait = match ty {
652+
Unknown => "Default",
649653
Known(tyname) => {
650654
match tyname.as_slice() {
651-
"" => "Default",
652655
"?" => "Poly",
653656
"b" => "Bool",
654657
"c" => "Char",

branches/auto/src/test/compile-fail/ifmt-bad-arg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ fn main() {
6565
// format strings because otherwise the "internal pointer of which argument
6666
// is next" would be invalidated if different cases had different numbers of
6767
// arguments.
68-
format!("{1, select, other{{}}}", 1, "a"); //~ ERROR: cannot use implicit
69-
format!("{1, plural, other{{}}}", 1, 1); //~ ERROR: cannot use implicit
68+
format!("{0, select, other{{}}}", "a"); //~ ERROR: cannot use implicit
69+
format!("{0, plural, other{{}}}", 1); //~ ERROR: cannot use implicit
7070
format!("{0, plural, other{{1:.*d}}}", 1, 2); //~ ERROR: cannot use implicit
7171

7272
format!("foo } bar"); //~ ERROR: unmatched `}` found

branches/auto/src/test/run-pass/ifmt.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub fn main() {
8585
t!(format!("{1} {0}", 0, 1), "1 0");
8686
t!(format!("{foo} {bar}", foo=0, bar=1), "0 1");
8787
t!(format!("{foo} {1} {bar} {0}", 0, 1, foo=2, bar=3), "2 1 3 0");
88+
t!(format!("{} {0:s}", "a"), "a a");
8889
t!(format!("{} {0}", "a"), "a a");
8990
t!(format!("{foo_bar}", foo_bar=1), "1");
9091

@@ -97,8 +98,8 @@ pub fn main() {
9798
t!(format!("{0, select, a{a#} b{b#} c{c#} other{d#}}", "b"), "bb");
9899
t!(format!("{0, select, a{a#} b{b#} c{c#} other{d#}}", "c"), "cc");
99100
t!(format!("{0, select, a{a#} b{b#} c{c#} other{d#}}", "d"), "dd");
100-
t!(format!("{1, select, a{#{0:s}} other{#}}", "b", "a"), "ab");
101-
t!(format!("{1, select, a{#{0}} other{#}}", "c", "b"), "b");
101+
t!(format!("{1, select, a{#{0:s}} other{#{1}}}", "b", "a"), "ab");
102+
t!(format!("{1, select, a{#{0}} other{#{1}}}", "c", "b"), "bb");
102103

103104
// Formatting strings and their arguments
104105
t!(format!("{:s}", "a"), "a");

0 commit comments

Comments
 (0)