Skip to content

Commit f7b1ce8

Browse files
committed
Fix parse tests and librustdoc issues with associated consts.
1 parent 8a74a49 commit f7b1ce8

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt,
105105
record_extern_fqn(cx, did, clean::TypeStatic);
106106
clean::StaticItem(build_static(cx, tcx, did, mtbl))
107107
}
108-
def::DefConst(did) | def::AssociatedConst(did, _) => {
108+
def::DefConst(did) | def::DefAssociatedConst(did, _) => {
109109
record_extern_fqn(cx, did, clean::TypeConst);
110110
clean::ConstantItem(build_const(cx, tcx, did))
111111
}

src/librustdoc/html/render.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ fn assoc_const(w: &mut fmt::Formatter, it: &clean::Item,
18821882
-> fmt::Result {
18831883
try!(write!(w, "const {}", it.name.as_ref().unwrap()));
18841884
try!(write!(w, ": {}", ty));
1885-
if let Some(ref default) = default {
1885+
if let Some(ref default) = *default {
18861886
try!(write!(w, " = {}", default));
18871887
}
18881888
Ok(())
@@ -2234,13 +2234,13 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl) -> fmt::Result {
22342234
try!(write!(w, "type {} = {}", name, tydef.type_));
22352235
try!(write!(w, "</code></h4>\n"));
22362236
}
2237-
clean::AssociatedConstItem(_, _) => {
2237+
clean::AssociatedConstItem(ref ty, ref default) => {
22382238
let name = item.name.as_ref().unwrap();
22392239
try!(write!(w, "<h4 id='assoc_const.{}' class='{}'>{}<code>",
22402240
*name,
22412241
shortty(item),
22422242
ConciseStability(&item.stability)));
2243-
try!(assoc_const(w, item, cstparam));
2243+
try!(assoc_const(w, item, ty, default));
22442244
try!(write!(w, "</code></h4>\n"));
22452245
}
22462246
clean::AssociatedTypeItem(ref bounds, ref default) => {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
trait Foo {
12+
pub const Foo: u32;
13+
//~^ ERROR expected one of `const`, `extern`, `fn`, `type`, or `unsafe`, found `pub`
14+
}
15+
16+
fn main() {}

src/test/parse-fail/trait-pub-assoc-ty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
// except according to those terms.
1010

1111
trait Foo {
12-
pub type Foo; //~ ERROR expected one of `extern`, `fn`, `type`, or `unsafe`, found `pub`
12+
pub type Foo;
13+
//~^ ERROR expected one of `const`, `extern`, `fn`, `type`, or `unsafe`, found `pub`
1314
}
1415

1516
fn main() {}

src/test/parse-fail/trait-pub-method.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
// except according to those terms.
1010

1111
trait Foo {
12-
pub fn foo(); //~ ERROR expected one of `extern`, `fn`, `type`, or `unsafe`, found `pub`
12+
pub fn foo();
13+
//~^ ERROR expected one of `const`, `extern`, `fn`, `type`, or `unsafe`, found `pub`
1314
}
1415

1516
fn main() {}

0 commit comments

Comments
 (0)