Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a12788a
make is_power_of_two a const function
tspiteri Aug 22, 2019
0a08841
Remove uses of `allow(unions_with_drop_fields)` in the standard library
SimonSapin Jul 3, 2019
84ca0a1
Remove most uses of `allow(unions_with_drop_fields)` in tests
SimonSapin Jul 3, 2019
2f0c821
Change untagged_unions to not allow union fields with drop
bluss Dec 19, 2018
fe13bbd
Remove unions_with_drop_fields lint
SimonSapin Jul 3, 2019
e247a40
Fixes #41073, it is no longer an ICE
SimonSapin Jul 3, 2019
05a644e
Update src/librustc_typeck/check/mod.rs
SimonSapin Jul 4, 2019
8c5ae86
Update src/librustc_typeck/check/mod.rs
SimonSapin Jul 4, 2019
0301eaf
Update src/librustc_typeck/error_codes.rs
SimonSapin Jul 4, 2019
bf25a9c
Update src/test/run-pass/union/union-nodrop.rs
SimonSapin Jul 4, 2019
fc512d2
More descriptive variable name
SimonSapin Jul 4, 2019
616cf52
Extend union-nodrop.rs test
SimonSapin Jul 4, 2019
50ec10e
rpass tests are now part of `ui` tests
oli-obk Sep 20, 2019
9c1ad0f
Preserve originally intended test semantics
oli-obk Sep 20, 2019
2fc257c
Prefer `ManuallyDrop::{take,new}` over `ptr::{read,write}`
oli-obk Sep 20, 2019
fb23a5c
Clarify a vague comment
oli-obk Sep 20, 2019
7e1a65d
Ensure we do not treat all unions as not having any drop glue.
oli-obk Sep 20, 2019
f5669eb
Update ui stderr
oli-obk Sep 20, 2019
bb5a652
Rebase fallout
oli-obk Oct 17, 2019
5719f57
miri add write_bytes method to Memory doing bounds-checks and support…
RalfJung Oct 20, 2019
50ddcbb
also check the iterator is not too long
RalfJung Oct 20, 2019
77c50dc
Remove unnecessary trait bounds from `keys::Keys`.
nnethercote Oct 19, 2019
c3b3a86
Remove unnecessary `Hash` bounds from various types.
nnethercote Oct 19, 2019
0653694
Don't silently do nothing on mis_use of `check_union_fields`
oli-obk Oct 21, 2019
875bdd5
Report even duplilcate errors in case the feature gat is not active
oli-obk Oct 21, 2019
55b787e
keep the root dir clean from debugging
RalfJung Oct 21, 2019
d4b3654
points the user away from the Allocation type and towards the Memory …
RalfJung Oct 20, 2019
f6d70b4
remove write_repeat; it is subsumed by the new write_bytes
RalfJung Oct 21, 2019
ac6daed
Remove many unnecessary trait derivations.
nnethercote Oct 20, 2019
3de7698
Fix typo from #65214
Amanieu Oct 21, 2019
d689c70
improve readability of is_power_of_two
tspiteri Oct 21, 2019
c3e909f
Remove `src/llvm-emscripten` submodule
alexcrichton Oct 17, 2019
ebc9a1a
expand comment
RalfJung Oct 21, 2019
b1feb95
Rollup merge of #62330 - SimonSapin:no-drop-in-union-fields, r=RalfJung
Centril Oct 21, 2019
ece5e58
Rollup merge of #65092 - tspiteri:const-is-pow2, r=oli-obk
Centril Oct 21, 2019
1f28401
Rollup merge of #65501 - alexcrichton:remove-emscripten-backend, r=Ma…
Centril Oct 21, 2019
57205dd
Rollup merge of #65621 - RalfJung:write_bytes, r=oli-obk
Centril Oct 21, 2019
2cf747f
Rollup merge of #65647 - nnethercote:rm-unnecessary-traits, r=Centril
Centril Oct 21, 2019
811a573
Rollup merge of #65653 - RalfJung:gitignore, r=Mark-Simulacrum,Centril
Centril Oct 21, 2019
644228d
Rollup merge of #65663 - Amanieu:typo, r=varkor
Centril Oct 21, 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
miri add write_bytes method to Memory doing bounds-checks and support…
…ing iterators
  • Loading branch information
RalfJung committed Oct 20, 2019
commit 5719f57fb1628e33765393d886f1638bfa0da059
9 changes: 7 additions & 2 deletions src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,16 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
src: &[u8],
src: impl IntoIterator<Item=u8, IntoIter: iter::ExactSizeIterator>,
) -> InterpResult<'tcx>
{
let mut src = src.into_iter();
let bytes = self.get_bytes_mut(cx, ptr, Size::from_bytes(src.len() as u64))?;
bytes.clone_from_slice(src);
// `zip` would stop when the first iterator ends; we want to definitely
// cover all of `bytes`.
for dest in bytes {
*dest = src.next().expect("iterator was shorter than it said it would be");
}
Ok(())
}

Expand Down
21 changes: 20 additions & 1 deletion src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! short-circuiting the empty case!

use std::collections::VecDeque;
use std::ptr;
use std::{ptr, iter};
use std::borrow::Cow;

use rustc::ty::{self, Instance, ParamEnv, query::TyCtxtAt};
Expand Down Expand Up @@ -785,6 +785,25 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
self.get(ptr.alloc_id)?.read_c_str(self, ptr)
}

/// Writes the given stream of bytes into memory.
///
/// Performs appropriate bounds checks.
pub fn write_bytes(
&mut self,
ptr: Scalar<M::PointerTag>,
src: impl IntoIterator<Item=u8, IntoIter: iter::ExactSizeIterator>,
) -> InterpResult<'tcx>
{
let src = src.into_iter();
let size = Size::from_bytes(src.len() as u64);
let ptr = match self.check_ptr_access(ptr, size, Align::from_bytes(1).unwrap())? {
Some(ptr) => ptr,
None => return Ok(()), // zero-sized access
};
let tcx = self.tcx.tcx;
self.get_mut(ptr.alloc_id)?.write_bytes(&tcx, ptr, src)
}

/// Expects the caller to have checked bounds and alignment.
pub fn copy(
&mut self,
Expand Down