Rename Unsafe to Safety
This commit is contained in:
parent
2d89cee625
commit
6b46a919e1
115 changed files with 460 additions and 494 deletions
|
@ -156,7 +156,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
[],
|
||||
expected_return_type,
|
||||
false,
|
||||
hir::Unsafety::Normal,
|
||||
hir::Safety::Safe,
|
||||
Abi::Rust,
|
||||
));
|
||||
|
||||
|
@ -252,7 +252,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
|||
[tcx.types.isize, Ty::new_imm_ptr(tcx, Ty::new_imm_ptr(tcx, tcx.types.u8))],
|
||||
tcx.types.isize,
|
||||
false,
|
||||
hir::Unsafety::Normal,
|
||||
hir::Safety::Safe,
|
||||
Abi::Rust,
|
||||
));
|
||||
|
||||
|
|
|
@ -71,13 +71,13 @@ fn equate_intrinsic_type<'tcx>(
|
|||
}
|
||||
|
||||
/// Returns the unsafety of the given intrinsic.
|
||||
pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hir::Unsafety {
|
||||
pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hir::Safety {
|
||||
let has_safe_attr = if tcx.has_attr(intrinsic_id, sym::rustc_intrinsic) {
|
||||
tcx.fn_sig(intrinsic_id).skip_binder().unsafety()
|
||||
tcx.fn_sig(intrinsic_id).skip_binder().safety()
|
||||
} else {
|
||||
match tcx.has_attr(intrinsic_id, sym::rustc_safe_intrinsic) {
|
||||
true => hir::Unsafety::Normal,
|
||||
false => hir::Unsafety::Unsafe,
|
||||
true => hir::Safety::Safe,
|
||||
false => hir::Safety::Unsafe,
|
||||
}
|
||||
};
|
||||
let is_in_list = match tcx.item_name(intrinsic_id.into()) {
|
||||
|
@ -136,8 +136,8 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
|
|||
| sym::fmul_algebraic
|
||||
| sym::fdiv_algebraic
|
||||
| sym::frem_algebraic
|
||||
| sym::const_eval_select => hir::Unsafety::Normal,
|
||||
_ => hir::Unsafety::Unsafe,
|
||||
| sym::const_eval_select => hir::Safety::Safe,
|
||||
_ => hir::Safety::Unsafe,
|
||||
};
|
||||
|
||||
if has_safe_attr != is_in_list {
|
||||
|
@ -197,7 +197,7 @@ pub fn check_intrinsic_type(
|
|||
})
|
||||
};
|
||||
|
||||
let (n_tps, n_lts, n_cts, inputs, output, unsafety) = if name_str.starts_with("atomic_") {
|
||||
let (n_tps, n_lts, n_cts, inputs, output, safety) = if name_str.starts_with("atomic_") {
|
||||
let split: Vec<&str> = name_str.split('_').collect();
|
||||
assert!(split.len() >= 2, "Atomic intrinsic in an incorrect format");
|
||||
|
||||
|
@ -219,9 +219,9 @@ pub fn check_intrinsic_type(
|
|||
return;
|
||||
}
|
||||
};
|
||||
(n_tps, 0, 0, inputs, output, hir::Unsafety::Unsafe)
|
||||
(n_tps, 0, 0, inputs, output, hir::Safety::Unsafe)
|
||||
} else {
|
||||
let unsafety = intrinsic_operation_unsafety(tcx, intrinsic_id);
|
||||
let safety = intrinsic_operation_unsafety(tcx, intrinsic_id);
|
||||
let (n_tps, n_cts, inputs, output) = match intrinsic_name {
|
||||
sym::abort => (0, 0, vec![], tcx.types.never),
|
||||
sym::unreachable => (0, 0, vec![], tcx.types.never),
|
||||
|
@ -514,14 +514,14 @@ pub fn check_intrinsic_type(
|
|||
[mut_u8],
|
||||
tcx.types.unit,
|
||||
false,
|
||||
hir::Unsafety::Normal,
|
||||
hir::Safety::Safe,
|
||||
Abi::Rust,
|
||||
));
|
||||
let catch_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig(
|
||||
[mut_u8, mut_u8],
|
||||
tcx.types.unit,
|
||||
false,
|
||||
hir::Unsafety::Normal,
|
||||
hir::Safety::Safe,
|
||||
Abi::Rust,
|
||||
));
|
||||
(
|
||||
|
@ -656,9 +656,9 @@ pub fn check_intrinsic_type(
|
|||
return;
|
||||
}
|
||||
};
|
||||
(n_tps, 0, n_cts, inputs, output, unsafety)
|
||||
(n_tps, 0, n_cts, inputs, output, safety)
|
||||
};
|
||||
let sig = tcx.mk_fn_sig(inputs, output, false, unsafety, abi);
|
||||
let sig = tcx.mk_fn_sig(inputs, output, false, safety, abi);
|
||||
let sig = ty::Binder::bind_with_vars(sig, bound_vars);
|
||||
equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, n_lts, n_cts, sig)
|
||||
}
|
||||
|
|
|
@ -456,7 +456,7 @@ fn fn_sig_suggestion<'tcx>(
|
|||
|
||||
let output = if !output.is_unit() { format!(" -> {output}") } else { String::new() };
|
||||
|
||||
let unsafety = sig.unsafety.prefix_str();
|
||||
let safety = sig.safety.prefix_str();
|
||||
let (generics, where_clauses) = bounds_from_generic_predicates(tcx, predicates);
|
||||
|
||||
// FIXME: this is not entirely correct, as the lifetimes from borrowed params will
|
||||
|
@ -464,9 +464,7 @@ fn fn_sig_suggestion<'tcx>(
|
|||
// lifetimes between the `impl` and the `trait`, but this should be good enough to
|
||||
// fill in a significant portion of the missing code, and other subsequent
|
||||
// suggestions can help the user fix the code.
|
||||
format!(
|
||||
"{unsafety}{asyncness}fn {ident}{generics}({args}){output}{where_clauses} {{ todo!() }}"
|
||||
)
|
||||
format!("{safety}{asyncness}fn {ident}{generics}({args}){output}{where_clauses} {{ todo!() }}")
|
||||
}
|
||||
|
||||
/// Return placeholder code for the given associated item.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue