Skip to content

Commit 4512424

Browse files
committed
Auto merge of #41551 - frewsxcv:rollup, r=frewsxcv
Rollup of 9 pull requests - Successful merges: #39983, #41442, #41463, #41500, #41518, #41527, #41528, #41530, #41535 - Failed merges:
2 parents 7e7114f + 1fd8ba9 commit 4512424

File tree

9 files changed

+221
-16
lines changed

9 files changed

+221
-16
lines changed

Diff for: src/bootstrap/dist.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,12 @@ pub fn debugger_scripts(build: &Build,
254254
install(&build.src.join("src/etc/").join(file), &dst, 0o644);
255255
};
256256
if host.contains("windows-msvc") {
257-
// no debugger scripts
257+
// windbg debugger scripts
258+
install(&build.src.join("src/etc/rust-windbg.cmd"), &sysroot.join("bin"),
259+
0o755);
260+
261+
cp_debugger_script("natvis/libcore.natvis");
262+
cp_debugger_script("natvis/libcollections.natvis");
258263
} else {
259264
cp_debugger_script("debugger_pretty_printers_common.py");
260265

Diff for: src/doc/index.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,21 @@ nicknamed 'The Rust Bookshelf.'
3232
* [The Rustonomicon][nomicon] is your guidebook to the dark arts of unsafe Rust.
3333
* [The Reference][ref] is not a formal spec, but is more detailed and comprehensive than the book.
3434

35+
Initially, documentation lands in the Unstable Book, and then, as part of the
36+
stabilization process, is moved into the Book, Nomicon, or Reference.
37+
3538
Another few words about the reference: it is guaranteed to be accurate, but not
36-
complete. We now have a policy that all new features must be included in the
37-
reference before stabilization; however, we are still back-filling things that
38-
landed before then. That work is being tracked [here][38643].
39+
complete. We have a policy that features must have documentation to be stabilized,
40+
but we did not always have this policy, and so there are some stable things that
41+
are not yet in the reference. We're working on back-filling things that landed
42+
before this policy was put into place. That work is being tracked
43+
[here][refchecklist].
3944

4045
[Rust Learning]: https://github.com/ctjhoa/rust-learning
4146
[Docs.rs]: https://docs.rs/
4247
[api]: std/index.html
4348
[ref]: reference/index.html
44-
[38643]: https://github.com/rust-lang/rust/issues/38643
49+
[refchecklist]: https://github.com/rust-lang-nursery/reference/issues/9
4550
[err]: error-index.html
4651
[book]: book/index.html
4752
[nomicon]: nomicon/index.html

Diff for: src/doc/unstable-book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
- [linked_list_extras](library-features/linked-list-extras.md)
161161
- [lookup_host](library-features/lookup-host.md)
162162
- [manually_drop](library-features/manually-drop.md)
163+
- [more_io_inner_methods](library-features/more-io-inner-methods.md)
163164
- [mpsc_select](library-features/mpsc-select.md)
164165
- [n16](library-features/n16.md)
165166
- [never_type_impls](library-features/never-type-impls.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# `more_io_inner_methods`
2+
3+
The tracking issue for this feature is: [#41519]
4+
5+
[#41519]: https://github.com/rust-lang/rust/issues/41519
6+
7+
------------------------
8+
9+
This feature enables several internal accessor methods on structures in
10+
`std::io` including `Take::{get_ref, get_mut}` and `Chain::{into_inner, get_ref,
11+
get_mut}`.

Diff for: src/etc/rust-windbg.cmd

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@echo off
2+
setlocal
3+
4+
REM Copyright 2014 The Rust Project Developers. See the COPYRIGHT
5+
REM file at the top-level directory of this distribution and at
6+
REM http://rust-lang.org/COPYRIGHT.
7+
REM
8+
REM Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
9+
REM http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
10+
REM <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
11+
REM option. This file may not be copied, modified, or distributed
12+
REM except according to those terms.
13+
14+
for /f "delims=" %%i in ('rustc --print=sysroot') do set rustc_sysroot=%%i
15+
16+
set rust_etc=%rustc_sysroot%\lib\rustlib\etc
17+
18+
windbg -c ".nvload %rust_etc%\libcore.natvis;.nvload %rust_etc%\libcollections.natvis;" %*

Diff for: src/libcollections/vec.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ use Bound::{Excluded, Included, Unbounded};
275275
/// removed data to be erased for security purposes. Even if you drop a `Vec`, its
276276
/// buffer may simply be reused by another `Vec`. Even if you zero a `Vec`'s memory
277277
/// first, that may not actually happen because the optimizer does not consider
278-
/// this a side-effect that must be preserved.
278+
/// this a side-effect that must be preserved. There is one case which we will
279+
/// not break, however: using `unsafe` code to write to the excess capacity,
280+
/// and then increasing the length to match, is always valid.
279281
///
280282
/// `Vec` does not currently guarantee the order in which elements are dropped
281283
/// (the order has changed in the past, and may change again).
@@ -1147,7 +1149,8 @@ impl<T> Vec<T> {
11471149
self.truncate(0)
11481150
}
11491151

1150-
/// Returns the number of elements in the vector.
1152+
/// Returns the number of elements in the vector, also referred to
1153+
/// as its 'length'.
11511154
///
11521155
/// # Examples
11531156
///
@@ -2032,6 +2035,18 @@ impl<'a, T: Clone> From<&'a [T]> for Vec<T> {
20322035
}
20332036
}
20342037

2038+
#[stable(feature = "vec_from_mut", since = "1.21.0")]
2039+
impl<'a, T: Clone> From<&'a mut [T]> for Vec<T> {
2040+
#[cfg(not(test))]
2041+
fn from(s: &'a mut [T]) -> Vec<T> {
2042+
s.to_vec()
2043+
}
2044+
#[cfg(test)]
2045+
fn from(s: &'a mut [T]) -> Vec<T> {
2046+
::slice::to_vec(s)
2047+
}
2048+
}
2049+
20352050
#[stable(feature = "vec_from_cow_slice", since = "1.14.0")]
20362051
impl<'a, T> From<Cow<'a, [T]>> for Vec<T> where [T]: ToOwned<Owned=Vec<T>> {
20372052
fn from(s: Cow<'a, [T]>) -> Vec<T> {

Diff for: src/libcore/iter/iterator.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,9 @@ pub trait Iterator {
629629
///
630630
/// Note that the underlying iterator is still advanced when [`peek`] is
631631
/// called for the first time: In order to retrieve the next element,
632-
/// [`next`] is called on the underlying iterator, hence any side effects of
633-
/// the [`next`] method will occur.
632+
/// [`next`] is called on the underlying iterator, hence any side effects (i.e.
633+
/// anything other than fetching the next value) of the [`next`] method
634+
/// will occur.
634635
///
635636
/// [`peek`]: struct.Peekable.html#method.peek
636637
/// [`next`]: ../../std/iter/trait.Iterator.html#tymethod.next

Diff for: src/libstd/io/mod.rs

+155-6
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ pub trait Read {
466466
/// variant will be returned. If an error is returned then it must be
467467
/// guaranteed that no bytes were read.
468468
///
469+
/// An error of the `ErrorKind::Interrupted` kind is non-fatal and the read
470+
/// operation should be retried if there is nothing else to do.
471+
///
469472
/// # Examples
470473
///
471474
/// [`File`][file]s implement `Read`:
@@ -481,7 +484,7 @@ pub trait Read {
481484
/// let mut f = File::open("foo.txt")?;
482485
/// let mut buffer = [0; 10];
483486
///
484-
/// // read 10 bytes
487+
/// // read up to 10 bytes
485488
/// f.read(&mut buffer[..])?;
486489
/// # Ok(())
487490
/// # }
@@ -885,6 +888,9 @@ pub trait Write {
885888
/// It is **not** considered an error if the entire buffer could not be
886889
/// written to this writer.
887890
///
891+
/// An error of the `ErrorKind::Interrupted` kind is non-fatal and the
892+
/// write operation should be retried if there is nothing else to do.
893+
///
888894
/// # Examples
889895
///
890896
/// ```
@@ -894,6 +900,7 @@ pub trait Write {
894900
/// # fn foo() -> std::io::Result<()> {
895901
/// let mut buffer = File::create("foo.txt")?;
896902
///
903+
/// // Writes some prefix of the byte string, not necessarily all of it.
897904
/// buffer.write(b"some bytes")?;
898905
/// # Ok(())
899906
/// # }
@@ -929,14 +936,17 @@ pub trait Write {
929936

930937
/// Attempts to write an entire buffer into this write.
931938
///
932-
/// This method will continuously call `write` while there is more data to
933-
/// write. This method will not return until the entire buffer has been
934-
/// successfully written or an error occurs. The first error generated from
935-
/// this method will be returned.
939+
/// This method will continuously call `write` until there is no more data
940+
/// to be written or an error of non-`ErrorKind::Interrupted` kind is
941+
/// returned. This method will not return until the entire buffer has been
942+
/// successfully written or such an error occurs. The first error that is
943+
/// not of `ErrorKind::Interrupted` kind generated from this method will be
944+
/// returned.
936945
///
937946
/// # Errors
938947
///
939-
/// This function will return the first error that `write` returns.
948+
/// This function will return the first error of
949+
/// non-`ErrorKind::Interrupted` kind that `write` returns.
940950
///
941951
/// # Examples
942952
///
@@ -1494,6 +1504,87 @@ pub struct Chain<T, U> {
14941504
done_first: bool,
14951505
}
14961506

1507+
impl<T, U> Chain<T, U> {
1508+
/// Consumes the `Chain`, returning the wrapped readers.
1509+
///
1510+
/// # Examples
1511+
///
1512+
/// ```
1513+
/// #![feature(more_io_inner_methods)]
1514+
///
1515+
/// # use std::io;
1516+
/// use std::io::prelude::*;
1517+
/// use std::fs::File;
1518+
///
1519+
/// # fn foo() -> io::Result<()> {
1520+
/// let mut foo_file = File::open("foo.txt")?;
1521+
/// let mut bar_file = File::open("bar.txt")?;
1522+
///
1523+
/// let chain = foo_file.chain(bar_file);
1524+
/// let (foo_file, bar_file) = chain.into_inner();
1525+
/// # Ok(())
1526+
/// # }
1527+
/// ```
1528+
#[unstable(feature = "more_io_inner_methods", issue="41519")]
1529+
pub fn into_inner(self) -> (T, U) {
1530+
(self.first, self.second)
1531+
}
1532+
1533+
/// Gets references to the underlying readers in this `Chain`.
1534+
///
1535+
/// # Examples
1536+
///
1537+
/// ```
1538+
/// #![feature(more_io_inner_methods)]
1539+
///
1540+
/// # use std::io;
1541+
/// use std::io::prelude::*;
1542+
/// use std::fs::File;
1543+
///
1544+
/// # fn foo() -> io::Result<()> {
1545+
/// let mut foo_file = File::open("foo.txt")?;
1546+
/// let mut bar_file = File::open("bar.txt")?;
1547+
///
1548+
/// let chain = foo_file.chain(bar_file);
1549+
/// let (foo_file, bar_file) = chain.get_ref();
1550+
/// # Ok(())
1551+
/// # }
1552+
/// ```
1553+
#[unstable(feature = "more_io_inner_methods", issue="41519")]
1554+
pub fn get_ref(&self) -> (&T, &U) {
1555+
(&self.first, &self.second)
1556+
}
1557+
1558+
/// Gets mutable references to the underlying readers in this `Chain`.
1559+
///
1560+
/// Care should be taken to avoid modifying the internal I/O state of the
1561+
/// underlying readers as doing so may corrupt the internal state of this
1562+
/// `Chain`.
1563+
///
1564+
/// # Examples
1565+
///
1566+
/// ```
1567+
/// #![feature(more_io_inner_methods)]
1568+
///
1569+
/// # use std::io;
1570+
/// use std::io::prelude::*;
1571+
/// use std::fs::File;
1572+
///
1573+
/// # fn foo() -> io::Result<()> {
1574+
/// let mut foo_file = File::open("foo.txt")?;
1575+
/// let mut bar_file = File::open("bar.txt")?;
1576+
///
1577+
/// let mut chain = foo_file.chain(bar_file);
1578+
/// let (foo_file, bar_file) = chain.get_mut();
1579+
/// # Ok(())
1580+
/// # }
1581+
/// ```
1582+
#[unstable(feature = "more_io_inner_methods", issue="41519")]
1583+
pub fn get_mut(&mut self) -> (&mut T, &mut U) {
1584+
(&mut self.first, &mut self.second)
1585+
}
1586+
}
1587+
14971588
#[stable(feature = "std_debug", since = "1.16.0")]
14981589
impl<T: fmt::Debug, U: fmt::Debug> fmt::Debug for Chain<T, U> {
14991590
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -1606,6 +1697,64 @@ impl<T> Take<T> {
16061697
pub fn into_inner(self) -> T {
16071698
self.inner
16081699
}
1700+
1701+
/// Gets a reference to the underlying reader.
1702+
///
1703+
/// # Examples
1704+
///
1705+
/// ```
1706+
/// #![feature(more_io_inner_methods)]
1707+
///
1708+
/// use std::io;
1709+
/// use std::io::prelude::*;
1710+
/// use std::fs::File;
1711+
///
1712+
/// # fn foo() -> io::Result<()> {
1713+
/// let mut file = File::open("foo.txt")?;
1714+
///
1715+
/// let mut buffer = [0; 5];
1716+
/// let mut handle = file.take(5);
1717+
/// handle.read(&mut buffer)?;
1718+
///
1719+
/// let file = handle.get_ref();
1720+
/// # Ok(())
1721+
/// # }
1722+
/// ```
1723+
#[unstable(feature = "more_io_inner_methods", issue="41519")]
1724+
pub fn get_ref(&self) -> &T {
1725+
&self.inner
1726+
}
1727+
1728+
/// Gets a mutable reference to the underlying reader.
1729+
///
1730+
/// Care should be taken to avoid modifying the internal I/O state of the
1731+
/// underlying reader as doing so may corrupt the internal limit of this
1732+
/// `Take`.
1733+
///
1734+
/// # Examples
1735+
///
1736+
/// ```
1737+
/// #![feature(more_io_inner_methods)]
1738+
///
1739+
/// use std::io;
1740+
/// use std::io::prelude::*;
1741+
/// use std::fs::File;
1742+
///
1743+
/// # fn foo() -> io::Result<()> {
1744+
/// let mut file = File::open("foo.txt")?;
1745+
///
1746+
/// let mut buffer = [0; 5];
1747+
/// let mut handle = file.take(5);
1748+
/// handle.read(&mut buffer)?;
1749+
///
1750+
/// let file = handle.get_mut();
1751+
/// # Ok(())
1752+
/// # }
1753+
/// ```
1754+
#[unstable(feature = "more_io_inner_methods", issue="41519")]
1755+
pub fn get_mut(&mut self) -> &mut T {
1756+
&mut self.inner
1757+
}
16091758
}
16101759

16111760
#[stable(feature = "rust1", since = "1.0.0")]

Diff for: src/libstd/sys/unix/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ mod inner {
157157
pub fn sub_duration(&self, other: &Duration) -> Instant {
158158
Instant {
159159
t: self.t.checked_sub(dur2intervals(other))
160-
.expect("overflow when adding duration to instant"),
160+
.expect("overflow when subtracting duration from instant"),
161161
}
162162
}
163163
}

0 commit comments

Comments
 (0)