-
Notifications
You must be signed in to change notification settings - Fork 13.4k
rustdoc: Return String from doc_value, not Option #92079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -525,10 +525,11 @@ fn document_short( | |||||
if !show_def_docs { | ||||||
return; | ||||||
} | ||||||
if let Some(s) = item.doc_value() { | ||||||
let mut summary_html = MarkdownSummaryLine(&s, &item.links(cx)).into_string(); | ||||||
let dox = &item.doc_value(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this even compile currently? Doesn't it borrow a temporary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your suggestion requires borrowing at all the use sites, which makes it more noisy IMO. The reference here behaves the same as
I don't know exactly the rule for it, just that it works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I only see one use site that would need a borrow? |
||||||
if !dox.is_empty() { | ||||||
let mut summary_html = MarkdownSummaryLine(dox, &item.links(cx)).into_string(); | ||||||
|
||||||
if s.contains('\n') { | ||||||
if dox.contains('\n') { | ||||||
let link = format!(r#" <a href="{}">Read more</a>"#, naive_assoc_href(item, link, cx)); | ||||||
|
||||||
if let Some(idx) = summary_html.rfind("</p>") { | ||||||
|
@@ -567,7 +568,7 @@ fn document_full_inner( | |||||
is_collapsible: bool, | ||||||
heading_offset: HeadingOffset, | ||||||
) { | ||||||
if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) { | ||||||
if let Some(s) = item.collapsed_doc_value() { | ||||||
debug!("Doc block: =====\n{}\n=====", s); | ||||||
if is_collapsible { | ||||||
w.write_str( | ||||||
|
@@ -1363,7 +1364,7 @@ fn render_impl( | |||||
if let Some(it) = t.items.iter().find(|i| i.name == item.name) { | ||||||
// We need the stability of the item from the trait | ||||||
// because impls can't have a stability. | ||||||
if item.doc_value().is_some() { | ||||||
if !item.doc_value().is_empty() { | ||||||
document_item_info(&mut info_buffer, cx, it, Some(parent)); | ||||||
document_full(&mut doc_buffer, item, cx, HeadingOffset::H5); | ||||||
short_documented = false; | ||||||
|
@@ -1612,7 +1613,7 @@ fn render_impl( | |||||
write!(w, "</summary>") | ||||||
} | ||||||
|
||||||
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) { | ||||||
if let Some(ref dox) = i.impl_item.collapsed_doc_value() { | ||||||
let mut ids = cx.id_map.borrow_mut(); | ||||||
write!( | ||||||
w, | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.