Skip to content

Commit

Permalink
Fix invalid debug display for associated consts
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Mar 16, 2017
1 parent 0aeb9c1 commit 5364acb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2242,11 +2242,11 @@ pub enum PathParameters {
AngleBracketed {
lifetimes: Vec<Lifetime>,
types: Vec<Type>,
bindings: Vec<TypeBinding>
bindings: Vec<TypeBinding>,
},
Parenthesized {
inputs: Vec<Type>,
output: Option<Type>
output: Option<Type>,
}
}

Expand All @@ -2261,14 +2261,14 @@ impl Clean<PathParameters> for hir::PathParameters {
data.lifetimes.clean(cx)
},
types: data.types.clean(cx),
bindings: data.bindings.clean(cx)
bindings: data.bindings.clean(cx),
}
}

hir::ParenthesizedParameters(ref data) => {
PathParameters::Parenthesized {
inputs: data.inputs.clean(cx),
output: data.output.clean(cx)
output: data.output.clean(cx),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
if is_not_debug {
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
} else {
write!(w, "{:?}{:?}", HRef::new(did, &last.name), last.params)?;
write!(w, "{:?}{}", HRef::new(did, &last.name), last.params)?;
}
} else {
if is_not_debug {
Expand All @@ -507,7 +507,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
} else {
format!("{:?}", HRef::new(did, &last.name))
};
write!(w, "{}{:?}", path, last.params)?;
write!(w, "{}{}", path, last.params)?;
}
}
Ok(())
Expand Down
31 changes: 31 additions & 0 deletions src/test/rustdoc/const-doc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(associated_consts)]

use std::marker::PhantomData;

pub struct Foo<'a> {
f: PhantomData<&'a u32>,
}

pub struct ContentType {
pub ttype: Foo<'static>,
pub subtype: Foo<'static>,
pub params: Option<Foo<'static>>,
}

impl ContentType {
// @has const_doc/struct.ContentType.html
// @has - '//*[@class="docblock"]' 'Any: ContentType = ContentType{ttype: Foo{f: '
pub const Any: ContentType = ContentType { ttype: Foo { f: PhantomData, },
subtype: Foo { f: PhantomData, },
params: None, };
}

0 comments on commit 5364acb

Please sign in to comment.