Skip to content

Commit f657a30

Browse files
committed
Rollup merge of rust-lang#33600 - ollie27:rustdoc_impl_params, r=alexcrichton
rustdoc: Fix missing type parameters on impls They were broken by rust-lang#32558. Fixes: rust-lang#33592
2 parents d1ab5d2 + 538de73 commit f657a30

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

src/librustdoc/clean/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -1534,13 +1534,6 @@ impl Type {
15341534
}
15351535
}
15361536

1537-
pub fn trait_name(&self) -> Option<String> {
1538-
match *self {
1539-
ResolvedPath { ref path, .. } => Some(path.last_name()),
1540-
_ => None,
1541-
}
1542-
}
1543-
15441537
pub fn is_generic(&self) -> bool {
15451538
match *self {
15461539
ResolvedPath { is_generic, .. } => is_generic,

src/librustdoc/html/format.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,13 @@ fn fmt_impl(i: &clean::Impl, f: &mut fmt::Formatter, link_trait: bool) -> fmt::R
587587
if link_trait {
588588
write!(f, "{}", *ty)?;
589589
} else {
590-
write!(f, "{}", ty.trait_name().unwrap())?;
590+
match *ty {
591+
clean::ResolvedPath{ typarams: None, ref path, is_generic: false, .. } => {
592+
let last = path.segments.last().unwrap();
593+
write!(f, "{}{}", last.name, last.params)?;
594+
}
595+
_ => unreachable!(),
596+
}
591597
}
592598
write!(f, " for ")?;
593599
}

src/test/rustdoc/issue-33592.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2016 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+
#![crate_name = "foo"]
12+
13+
pub trait Foo<T> {}
14+
15+
pub struct Bar;
16+
17+
pub struct Baz;
18+
19+
// @has foo/trait.Foo.html '//code' 'impl Foo<i32> for Bar'
20+
impl Foo<i32> for Bar {}
21+
22+
// @has foo/trait.Foo.html '//code' 'impl<T> Foo<T> for Baz'
23+
impl<T> Foo<T> for Baz {}

0 commit comments

Comments
 (0)