Rename Unsafe to Safety

This commit is contained in:
Santiago Pastorino 2024-05-17 14:17:48 -03:00
parent 2d89cee625
commit 6b46a919e1
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
115 changed files with 460 additions and 494 deletions

View file

@ -1053,8 +1053,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
// ^^^^^^
values.0.push(sig1.unsafety.prefix_str(), sig1.unsafety != sig2.unsafety);
values.1.push(sig2.unsafety.prefix_str(), sig1.unsafety != sig2.unsafety);
values.0.push(sig1.safety.prefix_str(), sig1.safety != sig2.safety);
values.1.push(sig2.safety.prefix_str(), sig1.safety != sig2.safety);
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
// ^^^^^^^^^^
@ -1928,7 +1928,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
self.tcx
.signature_unclosure(
args.as_closure().sig(),
rustc_hir::Unsafety::Normal,
rustc_hir::Safety::Safe,
)
.to_string(),
),

View file

@ -168,7 +168,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'tcx> {
let closure_sig = args.as_closure().sig();
Ty::new_fn_ptr(
self.tcx,
self.tcx.signature_unclosure(closure_sig, hir::Unsafety::Normal),
self.tcx.signature_unclosure(closure_sig, hir::Safety::Safe),
)
}
_ => ty.super_fold_with(self),

View file

@ -409,10 +409,8 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
{
let closure_sig = self_ty.map(|closure| {
if let ty::Closure(_, args) = closure.kind() {
self.tcx().signature_unclosure(
args.as_closure().sig(),
rustc_hir::Unsafety::Normal,
)
self.tcx()
.signature_unclosure(args.as_closure().sig(), rustc_hir::Safety::Safe)
} else {
bug!("type is not longer closure");
}

View file

@ -452,7 +452,7 @@ impl<T> Trait<T> for X {
}
(ty::FnPtr(sig), ty::FnDef(def_id, _))
| (ty::FnDef(def_id, _), ty::FnPtr(sig)) => {
if tcx.fn_sig(def_id).skip_binder().unsafety() < sig.unsafety() {
if tcx.fn_sig(def_id).skip_binder().safety() < sig.safety() {
diag.note(
"unsafe functions cannot be coerced into safe function pointers",
);