Skip to content

Commit d49f869

Browse files
authored
Rollup merge of rust-lang#40587 - GuillaumeGomez:rustdoc-const-display, r=frewsxcv
Fix invalid debug display for associated consts Fixes rust-lang#40568. r? @rust-lang/docs cc @SergioBenitez
2 parents de724ba + 5364acb commit d49f869

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

src/librustdoc/clean/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2241,11 +2241,11 @@ pub enum PathParameters {
22412241
AngleBracketed {
22422242
lifetimes: Vec<Lifetime>,
22432243
types: Vec<Type>,
2244-
bindings: Vec<TypeBinding>
2244+
bindings: Vec<TypeBinding>,
22452245
},
22462246
Parenthesized {
22472247
inputs: Vec<Type>,
2248-
output: Option<Type>
2248+
output: Option<Type>,
22492249
}
22502250
}
22512251

@@ -2260,14 +2260,14 @@ impl Clean<PathParameters> for hir::PathParameters {
22602260
data.lifetimes.clean(cx)
22612261
},
22622262
types: data.types.clean(cx),
2263-
bindings: data.bindings.clean(cx)
2263+
bindings: data.bindings.clean(cx),
22642264
}
22652265
}
22662266

22672267
hir::ParenthesizedParameters(ref data) => {
22682268
PathParameters::Parenthesized {
22692269
inputs: data.inputs.clean(cx),
2270-
output: data.output.clean(cx)
2270+
output: data.output.clean(cx),
22712271
}
22722272
}
22732273
}

src/librustdoc/html/format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
481481
if is_not_debug {
482482
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
483483
} else {
484-
write!(w, "{:?}{:?}", HRef::new(did, &last.name), last.params)?;
484+
write!(w, "{:?}{}", HRef::new(did, &last.name), last.params)?;
485485
}
486486
} else {
487487
if is_not_debug {
@@ -507,7 +507,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
507507
} else {
508508
format!("{:?}", HRef::new(did, &last.name))
509509
};
510-
write!(w, "{}{:?}", path, last.params)?;
510+
write!(w, "{}{}", path, last.params)?;
511511
}
512512
}
513513
Ok(())

src/test/rustdoc/const-doc.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2017 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+
use std::marker::PhantomData;
14+
15+
pub struct Foo<'a> {
16+
f: PhantomData<&'a u32>,
17+
}
18+
19+
pub struct ContentType {
20+
pub ttype: Foo<'static>,
21+
pub subtype: Foo<'static>,
22+
pub params: Option<Foo<'static>>,
23+
}
24+
25+
impl ContentType {
26+
// @has const_doc/struct.ContentType.html
27+
// @has - '//*[@class="docblock"]' 'Any: ContentType = ContentType{ttype: Foo{f: '
28+
pub const Any: ContentType = ContentType { ttype: Foo { f: PhantomData, },
29+
subtype: Foo { f: PhantomData, },
30+
params: None, };
31+
}

0 commit comments

Comments
 (0)