Skip to content

Commit 93f9a13

Browse files
committed
---
yaml --- r: 207875 b: refs/heads/snap-stage3 c: 5c710b5 h: refs/heads/master i: 207873: 285b444 207871: db5c917 v: v3
1 parent d38c32d commit 93f9a13

File tree

4 files changed

+70
-8
lines changed

4 files changed

+70
-8
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: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: a5762625a168f195afbc5b74d674a93f8c692a8e
4+
refs/heads/snap-stage3: 5c710b593b429d39ea01375172a9ce968f43ab26
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/librustdoc/html/render.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,9 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
17871787
let types = t.items.iter().filter(|m| {
17881788
match m.inner { clean::AssociatedTypeItem(..) => true, _ => false }
17891789
}).collect::<Vec<_>>();
1790+
let consts = t.items.iter().filter(|m| {
1791+
match m.inner { clean::AssociatedConstItem(..) => true, _ => false }
1792+
}).collect::<Vec<_>>();
17901793
let required = t.items.iter().filter(|m| {
17911794
match m.inner { clean::TyMethodItem(_) => true, _ => false }
17921795
}).collect::<Vec<_>>();
@@ -1803,7 +1806,15 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
18031806
try!(render_assoc_item(w, t, AssocItemLink::Anchor));
18041807
try!(write!(w, ";\n"));
18051808
}
1806-
if !types.is_empty() && !required.is_empty() {
1809+
if !types.is_empty() && !consts.is_empty() {
1810+
try!(w.write_str("\n"));
1811+
}
1812+
for t in &consts {
1813+
try!(write!(w, " "));
1814+
try!(render_assoc_item(w, t, AssocItemLink::Anchor));
1815+
try!(write!(w, ";\n"));
1816+
}
1817+
if !consts.is_empty() && !required.is_empty() {
18071818
try!(w.write_str("\n"));
18081819
}
18091820
for m in &required {
@@ -1905,11 +1916,11 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
19051916
}
19061917

19071918
fn assoc_const(w: &mut fmt::Formatter, it: &clean::Item,
1908-
ty: &clean::Type, default: &Option<String>)
1919+
ty: &clean::Type, default: Option<&String>)
19091920
-> fmt::Result {
19101921
try!(write!(w, "const {}", it.name.as_ref().unwrap()));
19111922
try!(write!(w, ": {}", ty));
1912-
if let Some(ref default) = *default {
1923+
if let Some(default) = default {
19131924
try!(write!(w, " = {}", default));
19141925
}
19151926
Ok(())
@@ -1971,7 +1982,7 @@ fn render_assoc_item(w: &mut fmt::Formatter, meth: &clean::Item,
19711982
link)
19721983
}
19731984
clean::AssociatedConstItem(ref ty, ref default) => {
1974-
assoc_const(w, meth, ty, default)
1985+
assoc_const(w, meth, ty, default.as_ref())
19751986
}
19761987
clean::AssociatedTypeItem(ref bounds, ref default) => {
19771988
assoc_type(w, meth, bounds, default)
@@ -2335,9 +2346,15 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
23352346
clean::AssociatedConstItem(ref ty, ref default) => {
23362347
let name = item.name.as_ref().unwrap();
23372348
try!(write!(w, "<h4 id='assoc_const.{}' class='{}'><code>",
2338-
*name,
2339-
shortty(item)));
2340-
try!(assoc_const(w, item, ty, default));
2349+
*name, shortty(item)));
2350+
try!(assoc_const(w, item, ty, default.as_ref()));
2351+
try!(write!(w, "</code></h4>\n"));
2352+
}
2353+
clean::ConstantItem(ref c) => {
2354+
let name = item.name.as_ref().unwrap();
2355+
try!(write!(w, "<h4 id='assoc_const.{}' class='{}'><code>",
2356+
*name, shortty(item)));
2357+
try!(assoc_const(w, item, &c.type_, Some(&c.expr)));
23412358
try!(write!(w, "</code></h4>\n"));
23422359
}
23432360
clean::AssociatedTypeItem(ref bounds, ref default) => {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
static foo: Fn() -> u32 = || -> u32 {
13+
//~^ ERROR: mismatched types:
14+
//~| expected `core::ops::Fn() -> u32`,
15+
//~| found closure
16+
//~| (expected trait core::ops::Fn,
17+
//~| found closure)
18+
0
19+
};
20+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(associated_consts)]
12+
13+
pub trait Foo {
14+
// @has assoc_consts/trait.Foo.html '//*[@class="rust trait"]' \
15+
// 'const FOO: usize;'
16+
const FOO: usize;
17+
}
18+
19+
pub struct Bar;
20+
21+
impl Bar {
22+
// @has assoc_consts/struct.Bar.html '//*[@id="assoc_const.BAR"]' \
23+
// 'const BAR: usize = 3'
24+
pub const BAR: usize = 3;
25+
}

0 commit comments

Comments
 (0)