Add some convenience helper methods on hir::Safety
This commit is contained in:
parent
3a64bef2ba
commit
8a4e5d7444
27 changed files with 72 additions and 68 deletions
|
|
@ -639,7 +639,7 @@ impl FromClean<clean::BareFunctionDecl> for FunctionPointer {
|
|||
let clean::BareFunctionDecl { safety, generic_params, decl, abi } = bare_decl;
|
||||
FunctionPointer {
|
||||
header: FunctionHeader {
|
||||
is_unsafe: matches!(safety, rustc_hir::Safety::Unsafe),
|
||||
is_unsafe: safety.is_unsafe(),
|
||||
is_const: false,
|
||||
is_async: false,
|
||||
abi: convert_abi(abi),
|
||||
|
|
@ -669,7 +669,7 @@ impl FromClean<clean::Trait> for Trait {
|
|||
fn from_clean(trait_: clean::Trait, renderer: &JsonRenderer<'_>) -> Self {
|
||||
let tcx = renderer.tcx;
|
||||
let is_auto = trait_.is_auto(tcx);
|
||||
let is_unsafe = trait_.safety(tcx) == rustc_hir::Safety::Unsafe;
|
||||
let is_unsafe = trait_.safety(tcx).is_unsafe();
|
||||
let is_dyn_compatible = trait_.is_dyn_compatible(tcx);
|
||||
let clean::Trait { items, generics, bounds, .. } = trait_;
|
||||
Trait {
|
||||
|
|
@ -711,7 +711,7 @@ impl FromClean<clean::Impl> for Impl {
|
|||
ty::ImplPolarity::Negative => true,
|
||||
};
|
||||
Impl {
|
||||
is_unsafe: safety == rustc_hir::Safety::Unsafe,
|
||||
is_unsafe: safety.is_unsafe(),
|
||||
generics: generics.into_json(renderer),
|
||||
provided_trait_methods: provided_trait_methods
|
||||
.into_iter()
|
||||
|
|
@ -840,7 +840,7 @@ fn convert_static(
|
|||
Static {
|
||||
type_: (*stat.type_).into_json(renderer),
|
||||
is_mutable: stat.mutability == ast::Mutability::Mut,
|
||||
is_unsafe: safety == rustc_hir::Safety::Unsafe,
|
||||
is_unsafe: safety.is_unsafe(),
|
||||
expr: stat
|
||||
.expr
|
||||
.map(|e| rendered_const(tcx, tcx.hir().body(e), tcx.hir().body_owner_def_id(e)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue