diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2024-12-13 12:19:46 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2024-12-14 20:31:07 +0000 |
| commit | 8a4e5d7444c4d43097c2ca0d1b8e64be9dbeddfa (patch) | |
| tree | f9ca6a3756cf0bb0e520702d99f2064231e95223 /src/librustdoc/html/render | |
| parent | 3a64bef2ba54542d3440634602e088c2597d9ed2 (diff) | |
| download | rust-8a4e5d7444c4d43097c2ca0d1b8e64be9dbeddfa.tar.gz rust-8a4e5d7444c4d43097c2ca0d1b8e64be9dbeddfa.zip | |
Add some convenience helper methods on `hir::Safety`
Diffstat (limited to 'src/librustdoc/html/render')
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 4c8d704e65b..ced9ff2d685 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -469,7 +469,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl let unsafety_flag = match myitem.kind { clean::FunctionItem(_) | clean::ForeignFunctionItem(..) - if myitem.fn_header(tcx).unwrap().safety == hir::Safety::Unsafe => + if myitem.fn_header(tcx).unwrap().safety.is_unsafe() => { "<sup title=\"unsafe function\">⚠</sup>" } @@ -1926,9 +1926,7 @@ fn item_static( buffer, "{vis}{safe}static {mutability}{name}: {typ}", vis = visibility_print_with_space(it, cx), - safe = safety - .map(|safe| if safe == hir::Safety::Unsafe { "unsafe " } else { "" }) - .unwrap_or(""), + safe = safety.map(|safe| safe.prefix_str()).unwrap_or(""), mutability = s.mutability.print_with_space(), name = it.name.unwrap(), typ = s.type_.print(cx) |
