diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-11-09 20:51:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-09 20:51:15 +0200 |
| commit | 6c7b43375ad70b9b134973b461854bbe60313ffc (patch) | |
| tree | eabc7866fa55d8cd8625920a358d9c5ef3a8552f | |
| parent | dc8ac2679aa1c52d5860a2e6514cf7ed89b7d445 (diff) | |
| parent | 47515ad5bdd8503a518db6a2c1fa9a8abeb1d67d (diff) | |
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  
| -rw-r--r-- | src/librustdoc/html/render.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index aeb952fbaad..2db771d7711 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1828,11 +1828,19 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, } else { 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(""); write!(w, " <tr class='{stab} module-item'> <td><a class='{class}' href='{href}' - title='{title}'>{name}</a></td> + title='{title}'>{name}</a>{unsafety_flag}</td> <td class='docblock-short'> {stab_docs} {docs} </td> @@ -1842,6 +1850,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, docs = shorter(Some(&Markdown(doc_value).to_string())), class = myitem.type_(), stab = myitem.stability_class(), + unsafety_flag = unsafety_flag, href = item_path(myitem.type_(), myitem.name.as_ref().unwrap()), title = full_path(cx, myitem))?; } |
