Don't mark "safe" intrinsics as unsafe

This commit is contained in:
Guillaume Gomez 2021-06-15 14:52:16 +02:00
parent 6936ca8c99
commit 91f491ecf2

View File

@ -26,6 +26,8 @@
use rustc_span::hygiene::{AstPass, MacroKind}; use rustc_span::hygiene::{AstPass, MacroKind};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{self, ExpnKind}; use rustc_span::{self, ExpnKind};
use rustc_target::spec::abi::Abi;
use rustc_typeck::check::intrinsic::intrinsic_operation_unsafety;
use rustc_typeck::hir_ty_to_ty; use rustc_typeck::hir_ty_to_ty;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
@ -2132,7 +2134,11 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Item {
decl, decl,
generics, generics,
header: hir::FnHeader { header: hir::FnHeader {
unsafety: hir::Unsafety::Unsafe, unsafety: if abi == Abi::RustIntrinsic {
intrinsic_operation_unsafety(item.ident.name)
} else {
hir::Unsafety::Unsafe
},
abi, abi,
constness: hir::Constness::NotConst, constness: hir::Constness::NotConst,
asyncness: hir::IsAsync::NotAsync, asyncness: hir::IsAsync::NotAsync,