Treat safe target_feature functions as unsafe by default
This commit is contained in:
parent
a907c56a77
commit
56178ddc90
20 changed files with 159 additions and 56 deletions
|
@ -1120,6 +1120,10 @@ pub(crate) fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
|
|||
let hir_id = tcx.local_def_id_to_hir_id(def);
|
||||
let safety_context = tcx.hir().fn_sig_by_hir_id(hir_id).map_or(SafetyContext::Safe, |fn_sig| {
|
||||
match fn_sig.header.safety {
|
||||
// We typeck the body as safe, but otherwise treat it as unsafe everywhere else.
|
||||
// Call sites to other SafeTargetFeatures functions are checked explicitly and don't need
|
||||
// to care about safety of the body.
|
||||
hir::HeaderSafety::SafeTargetFeatures => SafetyContext::Safe,
|
||||
hir::HeaderSafety::Normal(safety) => match safety {
|
||||
hir::Safety::Unsafe => SafetyContext::UnsafeFn,
|
||||
hir::Safety::Safe => SafetyContext::Safe,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue