Skip to content

Commit 9ce018b

Browse files
committed
Update tests
1 parent 74633b0 commit 9ce018b

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

src/librustdoc/html/render.rs

+17-15
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,8 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
16601660
fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLink) -> fmt::Result {
16611661
if let Some(s) = item.doc_value() {
16621662
let markdown = if s.contains('\n') {
1663-
format!("{} [Read more]({})", &plain_summary_line(Some(s)), naive_assoc_href(item, link))
1663+
format!("{} [Read more]({})",
1664+
&plain_summary_line(Some(s)), naive_assoc_href(item, link))
16641665
} else {
16651666
format!("{}", &plain_summary_line(Some(s)))
16661667
};
@@ -2619,25 +2620,26 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
26192620
_ => panic!("can't make docs for trait item with name {:?}", item.name)
26202621
}
26212622

2622-
if !is_default_item && (!is_static || render_static) {
2623+
if !is_static || render_static {
2624+
if !is_default_item {
26232625

2624-
if item.doc_value().is_some() {
2625-
document(w, cx, item)
2626-
} else {
2627-
// In case the item isn't documented,
2628-
// provide short documentation from the trait
2629-
if let Some(t) = trait_ {
2630-
if let Some(it) = t.items.iter()
2631-
.find(|i| i.name == item.name) {
2632-
document_short(w, it, link)?;
2626+
if item.doc_value().is_some() {
2627+
document(w, cx, item)?;
2628+
} else {
2629+
// In case the item isn't documented,
2630+
// provide short documentation from the trait
2631+
if let Some(t) = trait_ {
2632+
if let Some(it) = t.items.iter()
2633+
.find(|i| i.name == item.name) {
2634+
document_short(w, it, link)?;
2635+
}
26332636
}
26342637
}
2635-
Ok(())
2638+
} else {
2639+
document_short(w, item, link)?;
26362640
}
2637-
} else {
2638-
document_short(w, item, link)?;
2639-
Ok(())
26402641
}
2642+
Ok(())
26412643
}
26422644

26432645
let traits = &cache().traits;

src/test/rustdoc/manual_impl.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,24 @@ pub trait T {
2121
fn b_method(&self) -> usize {
2222
self.a_method()
2323
}
24+
25+
/// Docs associated with the trait c_method definition.
26+
///
27+
/// There is another line
28+
fn c_method(&self) -> usize {
29+
self.a_method()
30+
}
2431
}
2532

2633
// @has manual_impl/struct.S1.html '//*[@class="trait"]' 'T'
2734
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.'
2835
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.'
2936
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
30-
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
37+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
38+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
39+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
40+
// @!has - '//*[@class="docblock"]' 'There is another line'
41+
// @has - '//*[@class="docblock"]' 'Read more'
3142
pub struct S1(usize);
3243

3344
/// Docs associated with the S1 trait implementation.
@@ -41,9 +52,11 @@ impl T for S1 {
4152
// @has manual_impl/struct.S2.html '//*[@class="trait"]' 'T'
4253
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.'
4354
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.'
44-
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait b_method implementation.'
55+
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.'
4556
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
46-
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
57+
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
58+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
59+
// @!has - '//*[@class="docblock"]' 'Read more'
4760
pub struct S2(usize);
4861

4962
/// Docs associated with the S2 trait implementation.
@@ -53,16 +66,16 @@ impl T for S2 {
5366
self.0
5467
}
5568

56-
/// Docs associated with the S2 trait b_method implementation.
57-
fn b_method(&self) -> usize {
69+
/// Docs associated with the S2 trait c_method implementation.
70+
fn c_method(&self) -> usize {
5871
5
5972
}
6073
}
6174

6275
// @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
6376
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
6477
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
65-
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
78+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
6679
pub struct S3(usize);
6780

6881
/// Docs associated with the S3 trait implementation.

0 commit comments

Comments
 (0)