Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
81cd1e6
Deprecate the unstable Vec::resize_default
scottmcm Jan 16, 2019
6bfb280
deprecate before_exec in favor of unsafe pre_exec
RalfJung Feb 1, 2019
d48433d
also replace before_exec by pre_exec on redox
RalfJung Feb 1, 2019
b1709d2
update test
RalfJung Feb 1, 2019
cbbf8a7
deprecate things a bit slower
RalfJung Feb 2, 2019
6c67a76
pre_exec: expand docs
RalfJung Feb 2, 2019
59da97d
rustfmt the test
RalfJung Feb 2, 2019
33ee99b
more formatting
RalfJung Feb 3, 2019
e023403
POSIX requires async signal safety for fork in signal handlers, not i…
RalfJung Feb 3, 2019
f753d30
Suggest removing parentheses surrounding lifetimes
igorsdv Feb 5, 2019
d87df69
fix overlapping mutable and shared references in BTreeMap's into_slic…
RalfJung Feb 13, 2019
f0bef49
fix invalidating references in BTree iterators
RalfJung Feb 13, 2019
9312ca1
Add a note about 2018e if someone uses `try {` in 2015e
scottmcm Feb 18, 2019
64c915e
override `VecDeque::try_rfold`, also update iterator
llogiq Feb 2, 2019
abb07c4
remove a bit of dead code
matklad Feb 20, 2019
65622e3
cleanup macro after 2018 transition
matklad Feb 20, 2019
ad096d1
Dedup a rustdoc diagnostic construction
dwijnand Feb 20, 2019
8cf3605
fix typo
llogiq Feb 20, 2019
103ed0c
Search for target_triple.json only if builtin target not found
gnzlbg Feb 20, 2019
b2a02c8
Fixes #58586: Make E0505 explain example fail for 2018 edition
gurgalex Feb 20, 2019
102436d
Put Future trait into spotlight
Feb 20, 2019
6a5abea
Remove braces from most E0505 examples
gurgalex Feb 20, 2019
0f6d363
explain why we use static alignment in ref-to-place conversion
RalfJung Feb 21, 2019
b01f81b
remark about the one place where place computation calls size_and_ali…
RalfJung Feb 21, 2019
09a2454
introduce benchmarks of BTreeSet.intersection
ssomers Feb 21, 2019
4867a8c
Update miri links
phansch Feb 21, 2019
36f6652
Fix more nursery links in CONTRIBUTING.md
phansch Feb 21, 2019
88d55f5
Make std feature list sorted
matklad Feb 22, 2019
0bcb664
Rollup merge of #57656 - scottmcm:deprecate-resize_default, r=SimonSapin
Centril Feb 22, 2019
ec8ef18
Rollup merge of #58059 - RalfJung:before_exec, r=alexcrichton
Centril Feb 22, 2019
70cc6c9
Rollup merge of #58064 - llogiq:vec-deque-try-rfold, r=scottmcm
Centril Feb 22, 2019
894141b
Rollup merge of #58198 - igorsdv:suggest-removing-parentheses-surroun…
Centril Feb 22, 2019
42b9a04
Rollup merge of #58431 - RalfJung:btree, r=Mark-Simulacrum
Centril Feb 22, 2019
bcb7dce
Rollup merge of #58555 - scottmcm:try-2015, r=Centril
Centril Feb 22, 2019
94817aa
Rollup merge of #58588 - matklad:dead-code, r=petrochenkov
Centril Feb 22, 2019
aa3779b
Rollup merge of #58589 - matklad:remove-hack, r=petrochenkov
Centril Feb 22, 2019
1d0d94a
Rollup merge of #58591 - dwijnand:dedup-a-rustdoc-diag-construction, …
Centril Feb 22, 2019
575a209
Rollup merge of #58600 - llogiq:documentation-tests-typo, r=frewsxcv
Centril Feb 22, 2019
555df2b
Rollup merge of #58601 - gnzlbg:json_error, r=oli-obk
Centril Feb 22, 2019
b28a32f
Rollup merge of #58606 - stjepang:put-future-into-spotlight, r=alexcr…
Centril Feb 22, 2019
59f1a56
Rollup merge of #58607 - gurgalex:fail_E0505_for_2018_edition, r=matt…
Centril Feb 22, 2019
9695b80
Rollup merge of #58615 - RalfJung:ref-to-place-alignment, r=oli-obk
Centril Feb 22, 2019
a2a2b7b
Rollup merge of #58620 - ssomers:btreeset_intersection_benchmarks, r=…
Centril Feb 22, 2019
40d40a3
Rollup merge of #58621 - phansch:update_miri_links, r=oli-obk
Centril Feb 22, 2019
a8a343a
Rollup merge of #58632 - matklad:reduce-contention, r=Centril
Centril Feb 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix overlapping mutable and shared references in BTreeMap's into_slic…
…es_mut
  • Loading branch information
RalfJung committed Feb 13, 2019
commit d87df696b1811dc6da6a0be1d90b4398a67eb87e
25 changes: 22 additions & 3 deletions src/liballoc/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
}

fn into_key_slice_mut(mut self) -> &'a mut [K] {
// Same as for `into_key_slice` above, we try to avoid a run-time check
// (the alignment comparison will usually be performed at compile-time).
if mem::align_of::<K>() > mem::align_of::<LeafNode<(), ()>>() && self.is_shared_root() {
&mut []
} else {
Expand All @@ -667,9 +669,26 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
}
}

fn into_slices_mut(self) -> (&'a mut [K], &'a mut [V]) {
let k = unsafe { ptr::read(&self) };
(k.into_key_slice_mut(), self.into_val_slice_mut())
fn into_slices_mut(mut self) -> (&'a mut [K], &'a mut [V]) {
debug_assert!(!self.is_shared_root());
// We cannot use the getters here, because calling the second one
// invalidates the reference returned by the first.
// More precisely, it is the call to `len` that is the culprit,
// because that creates a shared reference to the header, which *can*
// overlap with the keys.
unsafe {
let len = self.len();
let leaf = self.as_leaf_mut();
let keys = slice::from_raw_parts_mut(
MaybeUninit::first_ptr_mut(&mut (*leaf).keys),
len
);
let vals = slice::from_raw_parts_mut(
MaybeUninit::first_ptr_mut(&mut (*leaf).vals),
len
);
(keys, vals)
}
}
}

Expand Down