Skip to content

Commit 0025b02

Browse files
committed
(c2rust-analyze) Refactor out PermissionSet::for_const_ref_ty from PermissionSet::for_const_ref (to be used directly later).
1 parent 3574ba4 commit 0025b02

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

c2rust-analyze/src/context.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ bitflags! {
5353
}
5454

5555
impl PermissionSet {
56-
pub fn for_const_ref(constant: ConstantKind) -> Self {
57-
let ref_ty = constant.ty();
58-
let ty = match ref_ty.kind() {
56+
pub fn for_const_ref_ty(ty: Ty) -> Self {
57+
let ty = match ty.kind() {
5958
ty::Ref(_, ty, _) => ty,
60-
_ => panic!("expected only `Ref`s for constants: {ref_ty:?}"),
59+
_ => panic!("expected only `Ref`s for constants: {ty:?}"),
6160
};
6261
if ty.is_array() || ty.is_str() {
6362
Self::READ | Self::OFFSET_ADD
@@ -67,6 +66,10 @@ impl PermissionSet {
6766
panic!("expected an array, str, or primitive type: {ty:?}");
6867
}
6968
}
69+
70+
pub fn for_const_ref(constant: ConstantKind) -> Self {
71+
Self::for_const_ref_ty(constant.ty())
72+
}
7073
}
7174

7275
bitflags! {

0 commit comments

Comments
 (0)