Skip to content

Commit

Permalink
rustdoc: mark unsafe fns with icons
Browse files Browse the repository at this point in the history
  • Loading branch information
liigo committed Oct 25, 2016
1 parent a628680 commit 9cbe79d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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))?;
}
Expand Down

0 comments on commit 9cbe79d

Please sign in to comment.