Auto merge of #58927 - GuillaumeGomez:default-keyword, r=QuietMisdreavus
Add default keyword handling in rustdoc Fixes #58898. r? @QuietMisdreavus
This commit is contained in:
commit
48e354d224
4 changed files with 51 additions and 7 deletions
|
|
@ -45,6 +45,7 @@ pub struct GenericBounds<'a>(pub &'a [clean::GenericBound]);
|
|||
/// Wrapper struct for emitting a comma-separated list of items
|
||||
pub struct CommaSep<'a, T>(pub &'a [T]);
|
||||
pub struct AbiSpace(pub Abi);
|
||||
pub struct DefaultSpace(pub bool);
|
||||
|
||||
/// Wrapper struct for properly emitting a function or method declaration.
|
||||
pub struct Function<'a> {
|
||||
|
|
@ -1057,3 +1058,13 @@ impl fmt::Display for AbiSpace {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for DefaultSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.0 {
|
||||
write!(f, "default ")
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ use crate::doctree;
|
|||
use crate::fold::DocFolder;
|
||||
use crate::html::escape::Escape;
|
||||
use crate::html::format::{AsyncSpace, ConstnessSpace};
|
||||
use crate::html::format::{GenericBounds, WhereClause, href, AbiSpace};
|
||||
use crate::html::format::{GenericBounds, WhereClause, href, AbiSpace, DefaultSpace};
|
||||
use crate::html::format::{VisSpace, Function, UnsafetySpace, MutableSpace};
|
||||
use crate::html::format::fmt_impl_for_trait_page;
|
||||
use crate::html::item_type::ItemType;
|
||||
|
|
@ -3429,11 +3429,12 @@ fn render_assoc_item(w: &mut fmt::Formatter<'_>,
|
|||
}
|
||||
};
|
||||
let mut header_len = format!(
|
||||
"{}{}{}{}{:#}fn {}{:#}",
|
||||
"{}{}{}{}{}{:#}fn {}{:#}",
|
||||
VisSpace(&meth.visibility),
|
||||
ConstnessSpace(header.constness),
|
||||
UnsafetySpace(header.unsafety),
|
||||
AsyncSpace(header.asyncness),
|
||||
DefaultSpace(meth.is_default()),
|
||||
AbiSpace(header.abi),
|
||||
name,
|
||||
*g
|
||||
|
|
@ -3445,12 +3446,13 @@ fn render_assoc_item(w: &mut fmt::Formatter<'_>,
|
|||
(0, true)
|
||||
};
|
||||
render_attributes(w, meth)?;
|
||||
write!(w, "{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
|
||||
write!(w, "{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
|
||||
{generics}{decl}{where_clause}",
|
||||
VisSpace(&meth.visibility),
|
||||
ConstnessSpace(header.constness),
|
||||
UnsafetySpace(header.unsafety),
|
||||
AsyncSpace(header.asyncness),
|
||||
DefaultSpace(meth.is_default()),
|
||||
AbiSpace(header.abi),
|
||||
href = href,
|
||||
name = name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue