Rollup merge of #37250 - liigo:rustdoc-unsafe-fns, r=steveklabnik
rustdoc: mark unsafe fns in module page with superscript icons Note: I'v changed the mark style. Now use superscript ⚠(U+26A0) (the old one is '[Unsafe]' literal). Basically per https://botbot.me/mozilla/rust-docs/2016-10-19/?msg=75112017&page=1  
This commit is contained in:
commit
6c7b43375a
1 changed files with 10 additions and 1 deletions
|
@ -1828,11 +1828,19 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut unsafety_flag = "";
|
||||||
|
if let clean::FunctionItem(ref func) = myitem.inner {
|
||||||
|
if func.unsafety == hir::Unsafety::Unsafe {
|
||||||
|
unsafety_flag = "<a title='unsafe function' href='#'><sup>⚠</sup></a>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let doc_value = myitem.doc_value().unwrap_or("");
|
let doc_value = myitem.doc_value().unwrap_or("");
|
||||||
write!(w, "
|
write!(w, "
|
||||||
<tr class='{stab} module-item'>
|
<tr class='{stab} module-item'>
|
||||||
<td><a class='{class}' href='{href}'
|
<td><a class='{class}' href='{href}'
|
||||||
title='{title}'>{name}</a></td>
|
title='{title}'>{name}</a>{unsafety_flag}</td>
|
||||||
<td class='docblock-short'>
|
<td class='docblock-short'>
|
||||||
{stab_docs} {docs}
|
{stab_docs} {docs}
|
||||||
</td>
|
</td>
|
||||||
|
@ -1842,6 +1850,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||||
docs = shorter(Some(&Markdown(doc_value).to_string())),
|
docs = shorter(Some(&Markdown(doc_value).to_string())),
|
||||||
class = myitem.type_(),
|
class = myitem.type_(),
|
||||||
stab = myitem.stability_class(),
|
stab = myitem.stability_class(),
|
||||||
|
unsafety_flag = unsafety_flag,
|
||||||
href = item_path(myitem.type_(), myitem.name.as_ref().unwrap()),
|
href = item_path(myitem.type_(), myitem.name.as_ref().unwrap()),
|
||||||
title = full_path(cx, myitem))?;
|
title = full_path(cx, myitem))?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue