Skip to content

Commit 47515ad

Browse files
committed
rustdoc: mark unsafe fns with icons
1 parent 7a20864 commit 47515ad

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/librustdoc/html/render.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1828,11 +1828,19 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
18281828
} else {
18291829
String::new()
18301830
};
1831+
1832+
let mut unsafety_flag = "";
1833+
if let clean::FunctionItem(ref func) = myitem.inner {
1834+
if func.unsafety == hir::Unsafety::Unsafe {
1835+
unsafety_flag = "<a title='unsafe function' href='#'><sup>⚠</sup></a>";
1836+
}
1837+
}
1838+
18311839
let doc_value = myitem.doc_value().unwrap_or("");
18321840
write!(w, "
18331841
<tr class='{stab} module-item'>
18341842
<td><a class='{class}' href='{href}'
1835-
title='{title}'>{name}</a></td>
1843+
title='{title}'>{name}</a>{unsafety_flag}</td>
18361844
<td class='docblock-short'>
18371845
{stab_docs} {docs}
18381846
</td>
@@ -1842,6 +1850,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
18421850
docs = shorter(Some(&Markdown(doc_value).to_string())),
18431851
class = myitem.type_(),
18441852
stab = myitem.stability_class(),
1853+
unsafety_flag = unsafety_flag,
18451854
href = item_path(myitem.type_(), myitem.name.as_ref().unwrap()),
18461855
title = full_path(cx, myitem))?;
18471856
}

0 commit comments

Comments
 (0)