Skip to content

Commit ee4489c

Browse files
committed
---
yaml --- r: 210425 b: refs/heads/try c: dd59b1f h: refs/heads/master i: 210423: 7d93279 v: v3
1 parent 247d6fd commit ee4489c

File tree

49 files changed

+335
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+335
-222
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: cf76e637450a861e94ef583340b8f080379a159a
5+
refs/heads/try: dd59b1fb4c66089c10b7e189975aeb171085312e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/libcollections/vec.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use core::intrinsics::assume;
6767
use core::iter::{repeat, FromIterator};
6868
use core::marker::PhantomData;
6969
use core::mem;
70-
use core::ops::{Index, IndexMut, Deref};
70+
use core::ops::{Index, IndexMut, Deref, Add};
7171
use core::ops;
7272
use core::ptr;
7373
use core::ptr::Unique;
@@ -647,7 +647,7 @@ impl<T> Vec<T> {
647647
// zero-size types consume no memory, so we can't rely on the
648648
// address space running out
649649
self.len = self.len.checked_add(1).expect("length overflow");
650-
unsafe { mem::forget(value); }
650+
mem::forget(value);
651651
return
652652
}
653653

@@ -994,7 +994,7 @@ impl<T> Vec<T> {
994994
num_u: 0,
995995
marker: PhantomData,
996996
};
997-
unsafe { mem::forget(vec); }
997+
mem::forget(vec);
998998

999999
while pv.num_t != 0 {
10001000
unsafe {
@@ -1622,6 +1622,17 @@ impl<T: Ord> Ord for Vec<T> {
16221622
}
16231623
}
16241624

1625+
#[stable(feature = "rust1", since = "1.0.0")]
1626+
impl<'a, T: Clone> Add<&'a [T]> for Vec<T> {
1627+
type Output = Vec<T>;
1628+
1629+
#[inline]
1630+
fn add(mut self, rhs: &[T]) -> Vec<T> {
1631+
self.push_all(rhs);
1632+
self
1633+
}
1634+
}
1635+
16251636
#[stable(feature = "rust1", since = "1.0.0")]
16261637
impl<T> Drop for Vec<T> {
16271638
fn drop(&mut self) {

branches/try/src/libcore/intrinsics.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ extern "rust-intrinsic" {
232232
pub fn uninit<T>() -> T;
233233

234234
/// Moves a value out of scope without running drop glue.
235-
///
236-
/// `forget` is unsafe because the caller is responsible for
237-
/// ensuring the argument is deallocated already.
238-
#[stable(feature = "rust1", since = "1.0.0")]
239235
pub fn forget<T>(_: T) -> ();
240236

241237
/// Unsafely transforms a value of one type into a value of another type.

branches/try/src/libcore/mem.rs

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,54 @@ use ptr;
2222
#[stable(feature = "rust1", since = "1.0.0")]
2323
pub use intrinsics::transmute;
2424

25-
/// Moves a thing into the void.
25+
/// Leaks a value into the void, consuming ownership and never running its
26+
/// destructor.
2627
///
27-
/// The forget function will take ownership of the provided value but neglect
28-
/// to run any required cleanup or memory management operations on it.
28+
/// This function will take ownership of its argument, but is distinct from the
29+
/// `mem::drop` function in that it **does not run the destructor**, leaking the
30+
/// value and any resources that it owns.
2931
///
30-
/// This function is the unsafe version of the `drop` function because it does
31-
/// not run any destructors.
32+
/// # Safety
33+
///
34+
/// This function is not marked as `unsafe` as Rust does not guarantee that the
35+
/// `Drop` implementation for a value will always run. Note, however, that
36+
/// leaking resources such as memory or I/O objects is likely not desired, so
37+
/// this function is only recommended for specialized use cases.
38+
///
39+
/// The safety of this function implies that when writing `unsafe` code
40+
/// yourself care must be taken when leveraging a destructor that is required to
41+
/// run to preserve memory safety. There are known situations where the
42+
/// destructor may not run (such as if ownership of the object with the
43+
/// destructor is returned) which must be taken into account.
44+
///
45+
/// # Other forms of Leakage
46+
///
47+
/// It's important to point out that this function is not the only method by
48+
/// which a value can be leaked in safe Rust code. Other known sources of
49+
/// leakage are:
50+
///
51+
/// * `Rc` and `Arc` cycles
52+
/// * `mpsc::{Sender, Receiver}` cycles (they use `Arc` internally)
53+
/// * Panicking destructors are likely to leak local resources
54+
///
55+
/// # Example
56+
///
57+
/// ```rust,no_run
58+
/// use std::mem;
59+
/// use std::fs::File;
60+
///
61+
/// // Leak some heap memory by never deallocating it
62+
/// let heap_memory = Box::new(3);
63+
/// mem::forget(heap_memory);
64+
///
65+
/// // Leak an I/O object, never closing the file
66+
/// let file = File::open("foo.txt").unwrap();
67+
/// mem::forget(file);
68+
/// ```
3269
#[stable(feature = "rust1", since = "1.0.0")]
33-
pub use intrinsics::forget;
70+
pub fn forget<T>(t: T) {
71+
unsafe { intrinsics::forget(t) }
72+
}
3473

3574
/// Returns the size of a type in bytes.
3675
///

branches/try/src/libcore/slice.rs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,8 @@ fn size_from_ptr<T>(_: *const T) -> usize {
631631
}
632632

633633

634-
// Use macros to be generic over const/mut
635-
//
636-
// They require non-negative `$by` because otherwise the expression
637-
// `(ptr as usize + $by)` would interpret `-1` as `usize::MAX` (and
638-
// thus trigger a panic when overflow checks are on).
639-
640-
// Use this to do `$ptr + $by`, where `$by` is non-negative.
641-
macro_rules! slice_add_offset {
634+
// Use macro to be generic over const/mut
635+
macro_rules! slice_offset {
642636
($ptr:expr, $by:expr) => {{
643637
let ptr = $ptr;
644638
if size_from_ptr(ptr) == 0 {
@@ -649,18 +643,6 @@ macro_rules! slice_add_offset {
649643
}};
650644
}
651645

652-
// Use this to do `$ptr - $by`, where `$by` is non-negative.
653-
macro_rules! slice_sub_offset {
654-
($ptr:expr, $by:expr) => {{
655-
let ptr = $ptr;
656-
if size_from_ptr(ptr) == 0 {
657-
transmute(ptr as usize - $by)
658-
} else {
659-
ptr.offset(-$by)
660-
}
661-
}};
662-
}
663-
664646
macro_rules! slice_ref {
665647
($ptr:expr) => {{
666648
let ptr = $ptr;
@@ -690,7 +672,7 @@ macro_rules! iterator {
690672
None
691673
} else {
692674
let old = self.ptr;
693-
self.ptr = slice_add_offset!(self.ptr, 1);
675+
self.ptr = slice_offset!(self.ptr, 1);
694676
Some(slice_ref!(old))
695677
}
696678
}
@@ -732,7 +714,7 @@ macro_rules! iterator {
732714
if self.end == self.ptr {
733715
None
734716
} else {
735-
self.end = slice_sub_offset!(self.end, 1);
717+
self.end = slice_offset!(self.end, -1);
736718
Some(slice_ref!(self.end))
737719
}
738720
}
@@ -794,7 +776,7 @@ impl<'a, T> Iter<'a, T> {
794776
fn iter_nth(&mut self, n: usize) -> Option<&'a T> {
795777
match self.as_slice().get(n) {
796778
Some(elem_ref) => unsafe {
797-
self.ptr = slice_add_offset!(elem_ref as *const _, 1);
779+
self.ptr = slice_offset!(elem_ref as *const _, 1);
798780
Some(slice_ref!(elem_ref))
799781
},
800782
None => {
@@ -867,7 +849,7 @@ impl<'a, T> IterMut<'a, T> {
867849
fn iter_nth(&mut self, n: usize) -> Option<&'a mut T> {
868850
match make_mut_slice!(T => &'a mut [T]: self.ptr, self.end).get_mut(n) {
869851
Some(elem_ref) => unsafe {
870-
self.ptr = slice_add_offset!(elem_ref as *mut _, 1);
852+
self.ptr = slice_offset!(elem_ref as *mut _, 1);
871853
Some(slice_ref!(elem_ref))
872854
},
873855
None => {

branches/try/src/librustc/middle/traits/error_reporting.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
5656
{
5757
let predicate =
5858
infcx.resolve_type_vars_if_possible(&obligation.predicate);
59-
// The ty_err created by normalize_to_error can end up being unified
60-
// into all obligations: for example, if our obligation is something
61-
// like `$X = <() as Foo<$X>>::Out` and () does not implement Foo<_>,
62-
// then $X will be unified with ty_err, but the error still needs to be
63-
// reported.
64-
if !infcx.tcx.sess.has_errors() || !predicate.references_error() {
59+
if !predicate.references_error() {
6560
span_err!(infcx.tcx.sess, obligation.cause.span, E0271,
6661
"type mismatch resolving `{}`: {}",
6762
predicate.user_string(infcx.tcx),
@@ -188,8 +183,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
188183
let trait_predicate =
189184
infcx.resolve_type_vars_if_possible(trait_predicate);
190185

191-
if !infcx.tcx.sess.has_errors() ||
192-
!trait_predicate.references_error() {
186+
if !trait_predicate.references_error() {
193187
let trait_ref = trait_predicate.to_poly_trait_ref();
194188
span_err!(infcx.tcx.sess, obligation.cause.span, E0277,
195189
"the trait `{}` is not implemented for the type `{}`",

branches/try/src/librustc/middle/traits/project.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,7 @@ fn opt_normalize_projection_type<'a,'b,'tcx>(
408408
}
409409

410410
/// in various error cases, we just set ty_err and return an obligation
411-
/// that, when fulfilled, will lead to an error.
412-
///
413-
/// FIXME: the ty_err created here can enter the obligation we create,
414-
/// leading to error messages involving ty_err.
411+
/// that, when fulfilled, will lead to an error
415412
fn normalize_to_error<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
416413
projection_ty: ty::ProjectionTy<'tcx>,
417414
cause: ObligationCause<'tcx>,

branches/try/src/librustdoc/html/render.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,9 +1460,7 @@ impl<'a> fmt::Display for Item<'a> {
14601460
try!(write!(fmt, "<span class='out-of-band'>"));
14611461
try!(write!(fmt,
14621462
r##"<span id='render-detail'>
1463-
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
1464-
[<span class='inner'>&#x2212;</span>]
1465-
</a>
1463+
<a id="toggle-all-docs" href="#" title="collapse all docs">[&minus;]</a>
14661464
</span>"##));
14671465

14681466
// Write `src` tag

branches/try/src/librustdoc/html/static/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ pre.rust { position: relative; }
581581

582582
.collapse-toggle > .inner {
583583
display: inline-block;
584-
width: 1.2ch;
584+
width: 1ch;
585585
text-align: center;
586586
}
587587

branches/try/src/librustdoc/html/static/main.js

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -806,35 +806,22 @@
806806
window.location = $('.srclink').attr('href');
807807
}
808808

809-
function labelForToggleButton(sectionIsCollapsed) {
810-
if (sectionIsCollapsed) {
811-
// button will expand the section
812-
return "+";
813-
} else {
814-
// button will collapse the section
815-
// note that this text is also set in the HTML template in render.rs
816-
return "\u2212"; // "\u2212" is '−' minus sign
817-
}
818-
}
819-
820809
$("#toggle-all-docs").on("click", function() {
821810
var toggle = $("#toggle-all-docs");
822-
if (toggle.hasClass("will-expand")) {
823-
toggle.removeClass("will-expand");
824-
toggle.children(".inner").text(labelForToggleButton(false));
825-
toggle.attr("title", "collapse all docs");
826-
$(".docblock").show();
827-
$(".toggle-label").hide();
828-
$(".toggle-wrapper").removeClass("collapsed");
829-
$(".collapse-toggle").children(".inner").text(labelForToggleButton(false));
830-
} else {
831-
toggle.addClass("will-expand");
832-
toggle.children(".inner").text(labelForToggleButton(true));
811+
if (toggle.html() == "[&minus;]") {
812+
toggle.html("[&plus;]");
833813
toggle.attr("title", "expand all docs");
834814
$(".docblock").hide();
835815
$(".toggle-label").show();
836816
$(".toggle-wrapper").addClass("collapsed");
837-
$(".collapse-toggle").children(".inner").text(labelForToggleButton(true));
817+
$(".collapse-toggle").children(".inner").html("&plus;");
818+
} else {
819+
toggle.html("[&minus;]");
820+
toggle.attr("title", "collapse all docs");
821+
$(".docblock").show();
822+
$(".toggle-label").hide();
823+
$(".toggle-wrapper").removeClass("collapsed");
824+
$(".collapse-toggle").children(".inner").html("&minus;");
838825
}
839826
});
840827

@@ -848,21 +835,20 @@
848835
if (relatedDoc.is(":visible")) {
849836
relatedDoc.slideUp({duration:'fast', easing:'linear'});
850837
toggle.parent(".toggle-wrapper").addClass("collapsed");
851-
toggle.children(".inner").text(labelForToggleButton(true));
838+
toggle.children(".inner").html("&plus;");
852839
toggle.children(".toggle-label").fadeIn();
853840
} else {
854841
relatedDoc.slideDown({duration:'fast', easing:'linear'});
855842
toggle.parent(".toggle-wrapper").removeClass("collapsed");
856-
toggle.children(".inner").text(labelForToggleButton(false));
843+
toggle.children(".inner").html("&minus;");
857844
toggle.children(".toggle-label").hide();
858845
}
859846
}
860847
});
861848

862849
$(function() {
863850
var toggle = $("<a/>", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'})
864-
.html("[<span class='inner'></span>]");
865-
toggle.children(".inner").text(labelForToggleButton(false));
851+
.html("[<span class='inner'>&minus;</span>]");
866852

867853
$(".method").each(function() {
868854
if ($(this).next().is(".docblock") ||

branches/try/src/libstd/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use fmt;
2323
use ffi::OsString;
2424
use io::{self, Error, ErrorKind, SeekFrom, Seek, Read, Write};
2525
use path::{Path, PathBuf};
26-
use sys::fs as fs_imp;
26+
use sys::fs2 as fs_imp;
2727
use sys_common::{AsInnerMut, FromInner, AsInner};
2828
use vec::Vec;
2929

branches/try/src/libstd/net/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use prelude::v1::*;
1616

1717
use io::{self, Error, ErrorKind};
18-
use sys_common::net as net_imp;
18+
use sys_common::net2 as net_imp;
1919

2020
pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
2121
pub use self::addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};

branches/try/src/libstd/net/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use io::prelude::*;
1717
use fmt;
1818
use io;
1919
use net::{ToSocketAddrs, SocketAddr, Shutdown};
20-
use sys_common::net as net_imp;
20+
use sys_common::net2 as net_imp;
2121
use sys_common::{AsInner, FromInner};
2222

2323
/// A structure which represents a TCP stream between a local socket and a

branches/try/src/libstd/net/udp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use prelude::v1::*;
1616
use fmt;
1717
use io::{self, Error, ErrorKind};
1818
use net::{ToSocketAddrs, SocketAddr, IpAddr};
19-
use sys_common::net as net_imp;
19+
use sys_common::net2 as net_imp;
2020
use sys_common::{AsInner, FromInner};
2121

2222
/// A User Datagram Protocol socket.

branches/try/src/libstd/os/android/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
pub mod raw;
1616

1717
pub mod fs {
18-
pub use sys::fs::MetadataExt;
18+
pub use sys::fs2::MetadataExt;
1919
}

branches/try/src/libstd/os/bitrig/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
pub mod raw;
1616

1717
pub mod fs {
18-
pub use sys::fs::MetadataExt;
18+
pub use sys::fs2::MetadataExt;
1919
}

branches/try/src/libstd/os/dragonfly/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
pub mod raw;
1616

1717
pub mod fs {
18-
pub use sys::fs::MetadataExt;
18+
pub use sys::fs2::MetadataExt;
1919
}

branches/try/src/libstd/os/freebsd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
pub mod raw;
1616

1717
pub mod fs {
18-
pub use sys::fs::MetadataExt;
18+
pub use sys::fs2::MetadataExt;
1919
}

branches/try/src/libstd/os/ios/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
pub mod raw;
1616

1717
pub mod fs {
18-
pub use sys::fs::MetadataExt;
18+
pub use sys::fs2::MetadataExt;
1919
}

0 commit comments

Comments
 (0)