File tree Expand file tree Collapse file tree 3 files changed +30
-5
lines changed Expand file tree Collapse file tree 3 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -620,6 +620,14 @@ fn main() {
620
620
"-Zmiri-unique-is-unique only has an effect when -Zmiri-tree-borrows is also used"
621
621
) ;
622
622
}
623
+ // Tree Borrows + permissive provenance does not work.
624
+ if miri_config. provenance_mode == ProvenanceMode :: Permissive
625
+ && matches ! ( miri_config. borrow_tracker, Some ( BorrowTrackerMethod :: TreeBorrows ) )
626
+ {
627
+ show_error ! (
628
+ "Tree Borrows does not support integer-to-pointer casts, and is hence not compatible with permissive provenance"
629
+ ) ;
630
+ }
623
631
624
632
debug ! ( "rustc arguments: {:?}" , rustc_args) ;
625
633
debug ! ( "crate arguments: {:?}" , miri_config. args) ;
Original file line number Diff line number Diff line change @@ -232,6 +232,10 @@ impl GlobalStateInner {
232
232
pub fn remove_unreachable_allocs ( & mut self , allocs : & LiveAllocs < ' _ , ' _ > ) {
233
233
self . root_ptr_tags . retain ( |id, _| allocs. is_live ( * id) ) ;
234
234
}
235
+
236
+ pub fn borrow_tracker_method ( & self ) -> BorrowTrackerMethod {
237
+ self . borrow_tracker_method
238
+ }
235
239
}
236
240
237
241
/// Which borrow tracking method to use
Original file line number Diff line number Diff line change @@ -647,8 +647,8 @@ impl<'tcx> MiriMachine<'tcx> {
647
647
} ;
648
648
649
649
let helps = match & e {
650
- Int2Ptr { details : true } =>
651
- vec ! [
650
+ Int2Ptr { details : true } => {
651
+ let mut v = vec ! [
652
652
(
653
653
None ,
654
654
format!(
@@ -673,13 +673,26 @@ impl<'tcx> MiriMachine<'tcx> {
673
673
"you can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics"
674
674
) ,
675
675
) ,
676
- (
676
+ ] ;
677
+ if self . borrow_tracker . as_ref ( ) . is_some_and ( |b| {
678
+ matches ! ( b. borrow( ) . borrow_tracker_method( ) , BorrowTrackerMethod :: TreeBorrows )
679
+ } ) {
680
+ v. push ( (
681
+ None ,
682
+ format ! (
683
+ "Tree Borrows does not support integer-to-pointer casts, so the program is likely to go wrong when this pointer gets used"
684
+ ) ,
685
+ ) ) ;
686
+ } else {
687
+ v. push ( (
677
688
None ,
678
689
format ! (
679
690
"alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning"
680
691
) ,
681
- ) ,
682
- ] ,
692
+ ) ) ;
693
+ }
694
+ v
695
+ }
683
696
ExternTypeReborrow => {
684
697
vec ! [
685
698
(
You can’t perform that action at this time.
0 commit comments