From 9cbe79df27f13ed9e6d0eaa4d39ad49d9df4f283 Mon Sep 17 00:00:00 2001 From: Liigo Zhuang Date: Mon, 24 Oct 2016 09:09:44 +0800 Subject: [PATCH] rustdoc: mark unsafe fns with icons --- html/render.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/html/render.rs b/html/render.rs index 77a5ff3..97193f3 100644 --- a/html/render.rs +++ b/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 = ""; + } + } + let doc_value = myitem.doc_value().unwrap_or(""); write!(w, " {name} + title='{title}'>{name}{unsafety_flag} {stab_docs} {docs} @@ -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))?; }