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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
ac67729
Remove stdlib stuff from the Reference
steveklabnik Mar 11, 2015
528a5e2
Add examples for std::ascii
steveklabnik Mar 24, 2015
c3f4fba
syntax: add {trait_item,impl_item,where_clause}_to_string
erickt Mar 14, 2015
4ec07ed
syntax: Allow where strings to be parsed independent from generics
erickt Mar 14, 2015
a17f556
syntax: Allow quotes to insert path
erickt Mar 14, 2015
4c2ddb3
std: Reexport std::rt::unwind::try in std::thread
alexcrichton Mar 23, 2015
3577555
Implement AsRef and AsMut for fixed-sized arrays
gkoz Mar 24, 2015
053d58e
Update pointers.md
wettowelreactor Mar 25, 2015
54f16b8
rustc: Remove support for int/uint
alexcrichton Mar 24, 2015
71386e5
Alphabetize
tamird Mar 25, 2015
d9d2236
Add iOS triple mapping so tests can run
tamird Mar 25, 2015
3902190
Switch drop-flag to `u8` to allow special tags to instrument state.
pnkfelix Feb 10, 2015
7c671e5
Regression tests for issues uncovered only post the run-pass and comp…
pnkfelix Mar 11, 2015
5bc35b1
filling-drop: switch `DTOR_NEEDED` and `DTOR_DONE` to non-trivial val…
pnkfelix Mar 17, 2015
5733726
A better `core::mem::dropped` implementation suggested by huonw on th…
pnkfelix Mar 23, 2015
601eca3
Added instability markers to `POST_DROP_*` consts, and related opt-in's.
pnkfelix Mar 25, 2015
4053b00
Use `-Z force-dropflag-checks=on/off` for emitting sanity-check.
pnkfelix Mar 25, 2015
aab4bef
Add tests exercising the dropflag checking functionality.
pnkfelix Mar 25, 2015
c5b8763
Deprecate as_mut_slice methods
erickt Mar 26, 2015
c153fc1
New section of the book: nightly rust
steveklabnik Mar 25, 2015
36ef29a
Register new snapshots
alexcrichton Mar 25, 2015
77de3ee
syntax: Remove parsing of old slice syntax
alexcrichton Mar 26, 2015
e2cc8b1
add feature flags required post rebase.
pnkfelix Mar 26, 2015
53a183f
Auto merge of #23359 - erickt:quote, r=pnkfelix
bors Mar 26, 2015
7d3bf47
Adding more information about the behavior of Arc/Rc
Adenilson Mar 26, 2015
43bfaa4
Mass rename uint/int to usize/isize
alexcrichton Mar 26, 2015
dac552f
doc: change 0u32..10 to 0..10
oneeman Mar 26, 2015
3e100ff
book: make it one sentence
tshepang Mar 26, 2015
9754b06
rustc: Remove support for old_impl_check
alexcrichton Mar 26, 2015
1c43e53
impl `FromStr` for `IpAddr`
murarth Mar 26, 2015
3752958
syntax: Remove support for #[should_fail]
alexcrichton Mar 26, 2015
e7525cf
Revise use of conversion traits
aturon Mar 26, 2015
5123bf4
Update docs to fix various 404s
gmjosack Mar 26, 2015
9c9bb9c
Implement `Reflect` trait with a variant on the standard OIBIT
nikomatsakis Mar 24, 2015
c59fe8b
Drive-by fix for incorrect variance rule that I noticed.
nikomatsakis Mar 25, 2015
703308d
Refactor how binders are handled in trait selection
nikomatsakis Mar 26, 2015
710af04
Refactor object-safety test to use def-ids only
nikomatsakis Mar 26, 2015
671d896
rustc: Remove old #[phase] and #[plugin]
alexcrichton Mar 26, 2015
cbef22e
Update rust-installer. Fixes --help and interop with NixOS
brson Mar 26, 2015
4357621
book: there is no guessing game anymore, so remove references to it
tshepang Mar 26, 2015
4f419d9
rustc: Remove support for `-l foo:static`
alexcrichton Mar 26, 2015
ce668a8
book: fix typo
tshepang Mar 26, 2015
e71221f
std: Stabilize BufRead::split
alexcrichton Mar 26, 2015
b68ca84
workaround pretty-print bugs to placate `make check-pretty`.
pnkfelix Mar 27, 2015
c0dd239
Add `std::net::lookup_addr` for reverse DNS lookup
murarth Mar 16, 2015
c9f600b
Stabilize some stragglers in `std::option`
aturon Mar 27, 2015
dd8cf92
Fix doc tests.
nikomatsakis Mar 27, 2015
1c35953
entry API v3: replace Entry::get with Entry::default and Entry::defau…
Gankra Mar 1, 2015
93cdf1f
update everything to use Entry defaults
Gankra Mar 1, 2015
a67faf1
Change the trivial cast lints to allow by default
nrc Mar 27, 2015
975ebc1
num: Derive Debug for Wrapping
ruuda Mar 27, 2015
1b98f6d
default => or_insert per RFC
Gankra Mar 20, 2015
242ed0b
Auto merge of #22930 - Gankro:entry_3, r=aturon
bors Mar 27, 2015
afaa3b6
Prevent ICEs when parsing invalid escapes, closes #23620
fhahn Mar 26, 2015
fa38403
alloc: Don't run some Arc doc tests
alexcrichton Mar 27, 2015
0e5052c
rollup merge of #23419: murarth/lookup-addr
alexcrichton Mar 27, 2015
e42521a
rollup merge of #23535: pnkfelix/fsk-filling-drop
alexcrichton Mar 27, 2015
b79fbe0
rollup merge of #23625: fhahn/issue-23620-ice-unicode-bytestring
alexcrichton Mar 27, 2015
6968ccf
rollup merge of #23651: alexcrichton/unwind-try
alexcrichton Mar 27, 2015
431296f
rollup merge of #23676: gkoz/array_as_ref
alexcrichton Mar 27, 2015
adbb516
rollup merge of #23690: wettowelreactor/patch-1
alexcrichton Mar 27, 2015
e6166b7
rollup merge of #23712: nikomatsakis/reflect-trait
alexcrichton Mar 27, 2015
8eb918e
rollup merge of #23719: steveklabnik/unstable_book
alexcrichton Mar 27, 2015
4bd1552
rollup merge of #23721: erickt/deprecate
alexcrichton Mar 27, 2015
39fecde
rollup merge of #23725: tamird/test-with-ios
alexcrichton Mar 27, 2015
31fbfc3
rollup merge of #23736: gmjosack/master
alexcrichton Mar 27, 2015
d2fac62
rollup merge of #23740: alexcrichton/remove-deprecated-slicing-syntax
alexcrichton Mar 27, 2015
df49ea6
rollup merge of #23743: Adenilson/addInfoArcClone01
alexcrichton Mar 27, 2015
5f9fd2e
rollup merge of #23745: oneeman/trpl-looping
alexcrichton Mar 27, 2015
5d8a529
rollup merge of #23747: tshepang/misleading-info
alexcrichton Mar 27, 2015
88c3a0f
rollup merge of #23750: murarth/ipaddr-fromstr
alexcrichton Mar 27, 2015
55c398d
rollup merge of #23752: alexcrichton/remove-should-fail
alexcrichton Mar 27, 2015
7d79a4f
rollup merge of #23753: aturon/revise-convert
alexcrichton Mar 27, 2015
6251999
rollup merge of #23761: alexcrichton/remove-phase
alexcrichton Mar 27, 2015
19ed61e
rollup merge of #23764: tshepang/no-guessing-anymore
alexcrichton Mar 27, 2015
fbbf02d
rollup merge of #23765: alexcrichton/remove-colon-syntax
alexcrichton Mar 27, 2015
7393693
rollup merge of #23767: tshepang/typo
alexcrichton Mar 27, 2015
a491d21
rollup merge of #23769: alexcrichton/stabilize-split
alexcrichton Mar 27, 2015
45f1324
rollup merge of #23771: aturon/stab-straggle-1
alexcrichton Mar 27, 2015
aff160b
rollup merge of #23775: alexcrichton/fix-flaky-test
alexcrichton Mar 27, 2015
dc6bb5e
rollup merge of #23776: nrc/allow_trivial_cast
alexcrichton Mar 27, 2015
169231d
rollup merge of #23780: ruud-v-a/wrapping
alexcrichton Mar 27, 2015
956c2eb
rollup merge of #23738: alexcrichton/snapshots
alexcrichton Mar 27, 2015
28a6b16
rollup merge of #23741: alexcrichton/remove-int-uint
alexcrichton Mar 27, 2015
e361b25
rollup merge of #23749: alexcrichton/remove-old-impl-check
alexcrichton Mar 27, 2015
b24a3b8
rustc: Remove support for hyphens in crate names
alexcrichton Mar 27, 2015
13e4270
Unquote all crate names without underscores
richo Mar 27, 2015
8bc3838
Merge 'richo/unquote-crates' into less-quotes
alexcrichton Mar 27, 2015
6acf385
Updated std::dynamic_lib to use std::path.
aatxe Mar 23, 2015
70042cf
When testing whether a default method predicates are satisfiable,
nikomatsakis Mar 18, 2015
0156011
Test fixes and rebase conflicts, round 1
alexcrichton Mar 27, 2015
e77db16
Fix fallout of removing quotes in crate names
alexcrichton Mar 27, 2015
63bbdc1
Fix wording for Option<T>.unwrap. Fixes #23713
jviereck Mar 27, 2015
1a6188a
Update return value docs in atomics docs
steveklabnik Mar 27, 2015
3f1d57f
rollup merge of #23285: steveklabnik/gh11794
alexcrichton Mar 27, 2015
ac24a51
rollup merge of #23486: nikomatsakis/issue-23485
alexcrichton Mar 27, 2015
df50510
rollup merge of #23665: steveklabnik/doc_std_ascii
alexcrichton Mar 27, 2015
8ec3695
rollup merge of #23791: jviereck/fix-23713
alexcrichton Mar 27, 2015
828c369
rollup merge of #23197: aatxe/master
alexcrichton Mar 27, 2015
1c78478
rollup merge of #23793: steveklabnik/gh21668
alexcrichton Mar 27, 2015
d65fee2
Test fixes and rebase conflicts, round 2
alexcrichton Mar 27, 2015
990202c
rollup merge of #23794: brson/slicegate
alexcrichton Mar 27, 2015
7e3fd14
Test fixes and rebase conflicts, round 3
alexcrichton Mar 27, 2015
1c0e1a8
rollup merge of #23763: brson/installer
alexcrichton Mar 27, 2015
d3a4f36
rollup merge of #23786: alexcrichton/less-quotes
alexcrichton Mar 27, 2015
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
5 changes: 3 additions & 2 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ impl<T> Drop for Arc<T> {
// more than once (but it is guaranteed to be zeroed after the first if
// it's run more than once)
let ptr = *self._ptr;
if ptr.is_null() { return }
// if ptr.is_null() { return }
if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return }

// Because `fetch_sub` is already atomic, we do not need to synchronize
// with other threads unless we are going to delete the object. This
Expand Down Expand Up @@ -485,7 +486,7 @@ impl<T> Drop for Weak<T> {
let ptr = *self._ptr;

// see comments above for why this check is here
if ptr.is_null() { return }
if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return }

// If we find out that we were the last weak pointer, then its time to
// deallocate the data entirely. See the discussion in Arc::drop() about
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#![feature(box_syntax)]
#![feature(optin_builtin_traits)]
#![feature(unboxed_closures)]
#![feature(unsafe_no_drop_flag)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(core)]
#![feature(unique)]
#![cfg_attr(test, feature(test, alloc, rustc_private))]
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ use core::default::Default;
use core::fmt;
use core::hash::{Hasher, Hash};
use core::marker;
use core::mem::{min_align_of, size_of, forget};
use core::mem::{self, min_align_of, size_of, forget};
use core::nonzero::NonZero;
use core::ops::{Deref, Drop};
use core::option::Option;
Expand Down Expand Up @@ -407,7 +407,7 @@ impl<T> Drop for Rc<T> {
fn drop(&mut self) {
unsafe {
let ptr = *self._ptr;
if !ptr.is_null() {
if !ptr.is_null() && ptr as usize != mem::POST_DROP_USIZE {
self.dec_strong();
if self.strong() == 0 {
ptr::read(&**self); // destroy the contained object
Expand Down Expand Up @@ -718,7 +718,7 @@ impl<T> Drop for Weak<T> {
fn drop(&mut self) {
unsafe {
let ptr = *self._ptr;
if !ptr.is_null() {
if !ptr.is_null() && ptr as usize != mem::POST_DROP_USIZE {
self.dec_weak();
// the weak count starts at 1, and will only go to zero if all
// the strong pointers have disappeared.
Expand Down
6 changes: 4 additions & 2 deletions src/libcollections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ impl<T> Drop for RawItems<T> {
#[unsafe_destructor]
impl<K, V> Drop for Node<K, V> {
fn drop(&mut self) {
if self.keys.is_null() {
if self.keys.is_null() ||
(unsafe { self.keys.get() as *const K as usize == mem::POST_DROP_USIZE })
{
// Since we have #[unsafe_no_drop_flag], we have to watch
// out for a null value being stored in self.keys. (Using
// out for the sentinel value being stored in self.keys. (Using
// null is technically a violation of the `Unique`
// requirements, though.)
return;
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#![feature(unicode)]
#![feature(unsafe_destructor)]
#![feature(unique)]
#![feature(unsafe_no_drop_flag)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(step_by)]
#![feature(str_char)]
#![feature(convert)]
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ impl<T> Drop for Vec<T> {
fn drop(&mut self) {
// This is (and should always remain) a no-op if the fields are
// zeroed (when moving out, because of #[unsafe_no_drop_flag]).
if self.cap != 0 {
if self.cap != 0 && self.cap != mem::POST_DROP_USIZE {
unsafe {
for x in &*self {
ptr::read(x);
Expand Down Expand Up @@ -1977,7 +1977,7 @@ impl<'a, T> ExactSizeIterator for Drain<'a, T> {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Drop for Drain<'a, T> {
fn drop(&mut self) {
// self.ptr == self.end == null if drop has already been called,
// self.ptr == self.end == mem::POST_DROP_USIZE if drop has already been called,
// so we can use #[unsafe_no_drop_flag].

// destroy the remaining elements
Expand Down
24 changes: 23 additions & 1 deletion src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,35 @@ extern "rust-intrinsic" {
/// crate it is invoked in.
pub fn type_id<T: ?Sized + 'static>() -> u64;

/// Create a value initialized to so that its drop flag,
/// if any, says that it has been dropped.
///
/// `init_dropped` is unsafe because it returns a datum with all
/// of its bytes set to the drop flag, which generally does not
/// correspond to a valid value.
///
/// This intrinsic is likely to be deprecated in the future when
/// Rust moves to non-zeroing dynamic drop (and thus removes the
/// embedded drop flags that are being established by this
/// intrinsic).
#[cfg(not(stage0))]
pub fn init_dropped<T>() -> T;

/// Create a value initialized to zero.
///
/// `init` is unsafe because it returns a zeroed-out datum,
/// which is unsafe unless T is Copy.
/// which is unsafe unless T is `Copy`. Also, even if T is
/// `Copy`, an all-zero value may not correspond to any legitimate
/// state for the type in question.
pub fn init<T>() -> T;

/// Create an uninitialized value.
///
/// `uninit` is unsafe because there is no guarantee of what its
/// contents are. In particular its drop-flag may be set to any
/// state, which means it may claim either dropped or
/// undropped. In the general case one must use `ptr::write` to
/// initialize memory previous set to the result of `uninit`.
pub fn uninit<T>() -> T;

/// Move a value out of scope without running drop glue.
Expand Down
69 changes: 69 additions & 0 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,32 @@ pub unsafe fn zeroed<T>() -> T {
intrinsics::init()
}

/// Create a value initialized to an unspecified series of bytes.
///
/// The byte sequence usually indicates that the value at the memory
/// in question has been dropped. Thus, *if* T carries a drop flag,
/// any associated destructor will not be run when the value falls out
/// of scope.
///
/// Some code at one time used the `zeroed` function above to
/// accomplish this goal.
///
/// This function is expected to be deprecated with the transition
/// to non-zeroing drop.
#[inline]
#[unstable(feature = "filling_drop")]
pub unsafe fn dropped<T>() -> T {
#[cfg(stage0)]
#[inline(always)]
unsafe fn dropped_impl<T>() -> T { zeroed() }

#[cfg(not(stage0))]
#[inline(always)]
unsafe fn dropped_impl<T>() -> T { intrinsics::init_dropped() }

dropped_impl()
}

/// Create an uninitialized value.
///
/// Care must be taken when using this function, if the type `T` has a destructor and the value
Expand Down Expand Up @@ -291,6 +317,49 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
#[stable(feature = "rust1", since = "1.0.0")]
pub fn drop<T>(_x: T) { }

macro_rules! repeat_u8_as_u32 {
($name:expr) => { (($name as u32) << 24 |
($name as u32) << 16 |
($name as u32) << 8 |
($name as u32)) }
}
macro_rules! repeat_u8_as_u64 {
($name:expr) => { ((repeat_u8_as_u32!($name) as u64) << 32 |
(repeat_u8_as_u32!($name) as u64)) }
}

// NOTE: Keep synchronized with values used in librustc_trans::trans::adt.
//
// In particular, the POST_DROP_U8 marker must never equal the
// DTOR_NEEDED_U8 marker.
//
// For a while pnkfelix was using 0xc1 here.
// But having the sign bit set is a pain, so 0x1d is probably better.
//
// And of course, 0x00 brings back the old world of zero'ing on drop.
#[cfg(not(stage0))] #[unstable(feature = "filling_drop")]
pub const POST_DROP_U8: u8 = 0x1d;
#[cfg(not(stage0))] #[unstable(feature = "filling_drop")]
pub const POST_DROP_U32: u32 = repeat_u8_as_u32!(POST_DROP_U8);
#[cfg(not(stage0))] #[unstable(feature = "filling_drop")]
pub const POST_DROP_U64: u64 = repeat_u8_as_u64!(POST_DROP_U8);

#[cfg(target_pointer_width = "32")]
#[cfg(not(stage0))] #[unstable(feature = "filling_drop")]
pub const POST_DROP_USIZE: usize = POST_DROP_U32 as usize;
#[cfg(target_pointer_width = "64")]
#[cfg(not(stage0))] #[unstable(feature = "filling_drop")]
pub const POST_DROP_USIZE: usize = POST_DROP_U64 as usize;

#[cfg(stage0)] #[unstable(feature = "filling_drop")]
pub const POST_DROP_U8: u8 = 0;
#[cfg(stage0)] #[unstable(feature = "filling_drop")]
pub const POST_DROP_U32: u32 = 0;
#[cfg(stage0)] #[unstable(feature = "filling_drop")]
pub const POST_DROP_U64: u64 = 0;
#[cfg(stage0)] #[unstable(feature = "filling_drop")]
pub const POST_DROP_USIZE: usize = 0;

/// Interprets `src` as `&U`, and then reads `src` without moving the contained value.
///
/// This function will unsafely assume the pointer `src` is valid for `sizeof(U)` bytes by
Expand Down
15 changes: 15 additions & 0 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,21 @@ pub unsafe fn read_and_zero<T>(dest: *mut T) -> T {
tmp
}

/// Variant of read_and_zero that writes the specific drop-flag byte
/// (which may be more appropriate than zero).
#[inline(always)]
#[unstable(feature = "core",
reason = "may play a larger role in std::ptr future extensions")]
pub unsafe fn read_and_drop<T>(dest: *mut T) -> T {
// Copy the data out from `dest`:
let tmp = read(&*dest);

// Now mark `dest` as dropped:
write_bytes(dest, mem::POST_DROP_U8, 1);

tmp
}

/// Overwrites a memory location with the given value without reading or
/// dropping the old value.
///
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"Print the size of enums and their variants"),
force_overflow_checks: Option<bool> = (None, parse_opt_bool,
"Force overflow checks on or off"),
force_dropflag_checks: Option<bool> = (None, parse_opt_bool,
"Force drop flag checks on or off"),
}

pub fn default_lib_output() -> CrateType {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let scope = cleanup::var_scope(tcx, p_id);
bcx = mk_binding_alloca(
bcx, p_id, &path1.node, scope, (),
|(), bcx, llval, ty| { zero_mem(bcx, llval, ty); bcx });
|(), bcx, llval, ty| { drop_done_fill_mem(bcx, llval, ty); bcx });
});
bcx
}
Expand Down
Loading