Skip to content

Commit ec14e80

Browse files
committed
(c2rust-analyze) Move and fully implement the post-typeck const ref permission check.
1 parent fec08df commit ec14e80

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

c2rust-analyze/src/dataflow/type_check.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,5 @@ pub fn visit<'tcx>(
489489
);
490490
}
491491

492-
for (&constant, const_lty) in &acx.const_ref_tys {
493-
let _ptr_id = const_lty.label;
494-
let _expected_perms = PermissionSet::for_const(constant);
495-
// TODO: check that perms match the expected ones
496-
}
497-
498492
(tc.constraints, tc.equiv_constraints)
499493
}

c2rust-analyze/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,13 @@ fn run(tcx: TyCtxt) {
625625
let mut asn = gasn.and(&mut info.lasn);
626626
info.dataflow.propagate_cell(&mut asn);
627627

628+
for (&constant, const_lty) in &acx.const_ref_tys {
629+
let ptr_id = const_lty.label;
630+
let expected_perms = PermissionSet::for_const(constant);
631+
let actual_perms = asn.perms()[ptr_id];
632+
assert_eq!(expected_perms, actual_perms);
633+
}
634+
628635
// Print labeling and rewrites for the current function.
629636

630637
eprintln!("\nfinal labeling for {:?}:", name);

0 commit comments

Comments
 (0)