Skip to content

Commit cd375f5

Browse files
committed
Auto merge of #2856 - RalfJung:rustup, r=RalfJung
Rustup
2 parents e46eb2e + 7a3ca1e commit cd375f5

File tree

8 files changed

+48
-22
lines changed

8 files changed

+48
-22
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f65615f02d22b85e9205f2716ab36182d34bab2b
1+
70540d51275086ce1a4cb12e9d96a97134df792e

src/concurrency/data_race.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use std::{
4848

4949
use rustc_ast::Mutability;
5050
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
51-
use rustc_index::vec::{Idx, IndexVec};
51+
use rustc_index::{Idx, IndexVec};
5252
use rustc_middle::mir;
5353
use rustc_span::Span;
5454
use rustc_target::abi::{Align, Size};

src/concurrency/init_once.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::VecDeque;
22
use std::num::NonZeroU32;
33

4-
use rustc_index::vec::Idx;
4+
use rustc_index::Idx;
55

66
use super::sync::EvalContextExtPriv as _;
77
use super::thread::MachineCallback;

src/concurrency/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::ops::Not;
55
use log::trace;
66

77
use rustc_data_structures::fx::FxHashMap;
8-
use rustc_index::vec::{Idx, IndexVec};
8+
use rustc_index::{Idx, IndexVec};
99

1010
use super::init_once::InitOnce;
1111
use super::vector_clock::VClock;

src/concurrency/thread.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use log::trace;
1010

1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_hir::def_id::DefId;
13-
use rustc_index::vec::{Idx, IndexVec};
13+
use rustc_index::{Idx, IndexVec};
1414
use rustc_middle::mir::Mutability;
1515
use rustc_middle::ty::layout::TyAndLayout;
1616
use rustc_span::Span;
@@ -603,10 +603,11 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
603603
// this allows us to have a deterministic scheduler.
604604
for thread in self.threads.indices() {
605605
match self.timeout_callbacks.entry(thread) {
606-
Entry::Occupied(entry) =>
606+
Entry::Occupied(entry) => {
607607
if entry.get().call_time.get_wait_time(clock) == Duration::new(0, 0) {
608608
return Some((thread, entry.remove().callback));
609-
},
609+
}
610+
}
610611
Entry::Vacant(_) => {}
611612
}
612613
}

src/concurrency/vector_clock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_index::vec::Idx;
1+
use rustc_index::Idx;
22
use rustc_span::{Span, SpanData, DUMMY_SP};
33
use smallvec::SmallVec;
44
use std::{

tests/pass/tree-borrows/read-only-from-mut.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//@compile-flags: -Zmiri-tree-borrows
2+
3+
fn main() {
4+
aliasing_read_only_mutable_refs();
5+
string_as_mut_ptr();
6+
}
7+
8+
// Tree Borrows has no issue with several mutable references existing
9+
// at the same time, as long as they are used only immutably.
10+
// I.e. multiple Reserved can coexist.
11+
pub fn aliasing_read_only_mutable_refs() {
12+
unsafe {
13+
let base = &mut 42u64;
14+
let r1 = &mut *(base as *mut u64);
15+
let r2 = &mut *(base as *mut u64);
16+
let _l = *r1;
17+
let _l = *r2;
18+
}
19+
}
20+
21+
pub fn string_as_mut_ptr() {
22+
// This errors in Stacked Borrows since as_mut_ptr restricts the provenance,
23+
// but with Tree Borrows it should work.
24+
unsafe {
25+
let mut s = String::from("hello");
26+
s.reserve(1); // make the `str` that `s` derefs to not cover the entire `s`.
27+
28+
// Prevent automatically dropping the String's data
29+
let mut s = mem::ManuallyDrop::new(s);
30+
31+
let ptr = s.as_mut_ptr();
32+
let len = s.len();
33+
let capacity = s.capacity();
34+
35+
let s = String::from_raw_parts(ptr, len, capacity);
36+
37+
assert_eq!(String::from("hello"), s);
38+
}
39+
}

0 commit comments

Comments
 (0)