Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #85711

Merged
merged 31 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c150772
rustdoc: avoid legacy Korean fonts in Windows
May 15, 2021
7e2e331
rustdoc: add the license of Noto Sans KR
May 15, 2021
b5e09dc
rustdoc: update static files
May 15, 2021
fe44fde
chore: format code
May 15, 2021
6b601d4
chore: update comment in rustdoc.css
May 15, 2021
8412d30
test: update unversioned-files.txt
May 18, 2021
8a2d663
test: fix the order in unversioned-files.txt
May 19, 2021
e587366
doc: clarify Mutex::try_lock, etc. errors
tlyu May 20, 2021
903e369
Fix boostrap using host exe suffix for cargo
jam1garner May 22, 2021
d7341f3
Don't reborrow self when computing the dest pointer in <[T]>::copy_wi…
SkiFire13 May 23, 2021
db8c6e0
Remove stray .stderr files
LeSeulArtichaut May 24, 2021
0e4f8cb
minor rewording after review
tlyu May 24, 2021
b63f7f9
Demote ControlFlow::{from|into}_try to pub(crate)
scottmcm May 24, 2021
ad30826
Revert "Move llvm submodule updates to rustbuild"
Mark-Simulacrum May 24, 2021
37588e9
Document shared_from_cow functions
fee1-dead May 25, 2021
79a5b12
Fix tasklist example in rustdoc book.
ehuss May 25, 2021
87cf2d4
Move stability attribute for methods under the `ip` feature from the …
CDirkx May 25, 2021
072b85c
Update books
ehuss May 25, 2021
8a7dc0d
Update cargo
ehuss May 25, 2021
0264f4f
Rollup merge of #84048 - konan8205:master, r=jsha
JohnTitor May 26, 2021
ae6a1a7
Rollup merge of #85529 - tlyu:trylock-errors, r=JohnTitor
JohnTitor May 26, 2021
d75521a
Rollup merge of #85590 - jam1garner:tool-bootstrap-su-fix, r=Mark-Sim…
JohnTitor May 26, 2021
b7b9ce3
Rollup merge of #85610 - SkiFire13:fix-copy-within-provenance, r=oli-obk
JohnTitor May 26, 2021
0bc3066
Rollup merge of #85623 - LeSeulArtichaut:stray-stderr, r=Mark-Simulacrum
JohnTitor May 26, 2021
587de8e
Rollup merge of #85645 - scottmcm:demote-from-into-try, r=yaahc
JohnTitor May 26, 2021
7508203
Rollup merge of #85647 - rust-lang:revert-81601-llvm-on-demand, r=jyn514
JohnTitor May 26, 2021
e87bc66
Rollup merge of #85666 - fee1-dead:document-shared-from-cow, r=dtolnay
JohnTitor May 26, 2021
1e51afa
Rollup merge of #85668 - ehuss:fix-rustdoc-tasklist, r=Mark-Simulacrum
JohnTitor May 26, 2021
7caf93f
Rollup merge of #85672 - CDirkx:ip, r=Mark-Simulacrum
JohnTitor May 26, 2021
bce257c
Rollup merge of #85699 - ehuss:update-books, r=ehuss
JohnTitor May 26, 2021
7c0677a
Rollup merge of #85701 - ehuss:update-cargo, r=ehuss
JohnTitor May 26, 2021
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
12 changes: 12 additions & 0 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,18 @@ where
B: ToOwned + ?Sized,
Rc<B>: From<&'a B> + From<B::Owned>,
{
/// Create a reference-counted pointer from
/// a clone-on-write pointer by copying its content.
///
/// # Example
///
/// ```rust
/// # use std::rc::Rc;
/// # use std::borrow::Cow;
/// let cow: Cow<str> = Cow::Borrowed("eggplant");
/// let shared: Rc<str> = Rc::from(cow);
/// assert_eq!("eggplant", &shared[..]);
/// ```
#[inline]
fn from(cow: Cow<'a, B>) -> Rc<B> {
match cow {
Expand Down
12 changes: 12 additions & 0 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2413,6 +2413,18 @@ where
B: ToOwned + ?Sized,
Arc<B>: From<&'a B> + From<B::Owned>,
{
/// Create an atomically reference-counted pointer from
/// a clone-on-write pointer by copying its content.
///
/// # Example
///
/// ```rust
/// # use std::sync::Arc;
/// # use std::borrow::Cow;
/// let cow: Cow<str> = Cow::Borrowed("eggplant");
/// let shared: Arc<str> = Arc::from(cow);
/// assert_eq!("eggplant", &shared[..]);
/// ```
#[inline]
fn from(cow: Cow<'a, B>) -> Arc<B> {
match cow {
Expand Down
15 changes: 7 additions & 8 deletions library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,42 +187,41 @@ impl<B, C> ControlFlow<B, C> {
#[cfg(bootstrap)]
impl<R: ops::TryV1> ControlFlow<R, R::Output> {
/// Create a `ControlFlow` from any type implementing `Try`.
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
#[inline]
pub fn from_try(r: R) -> Self {
pub(crate) fn from_try(r: R) -> Self {
match R::into_result(r) {
Ok(v) => ControlFlow::Continue(v),
Err(v) => ControlFlow::Break(R::from_error(v)),
}
}

/// Convert a `ControlFlow` into any type implementing `Try`;
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
#[inline]
pub fn into_try(self) -> R {
pub(crate) fn into_try(self) -> R {
match self {
ControlFlow::Continue(v) => R::from_ok(v),
ControlFlow::Break(v) => v,
}
}
}

/// These are used only as part of implementing the iterator adapters.
/// They have mediocre names and non-obvious semantics, so aren't
/// currently on a path to potential stabilization.
#[cfg(not(bootstrap))]
impl<R: ops::TryV2> ControlFlow<R, R::Output> {
/// Create a `ControlFlow` from any type implementing `Try`.
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
#[inline]
pub fn from_try(r: R) -> Self {
pub(crate) fn from_try(r: R) -> Self {
match R::branch(r) {
ControlFlow::Continue(v) => ControlFlow::Continue(v),
ControlFlow::Break(v) => ControlFlow::Break(R::from_residual(v)),
}
}

/// Convert a `ControlFlow` into any type implementing `Try`;
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
#[inline]
pub fn into_try(self) -> R {
pub(crate) fn into_try(self) -> R {
match self {
ControlFlow::Continue(v) => R::from_output(v),
ControlFlow::Break(v) => v,
Expand Down
6 changes: 5 additions & 1 deletion library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3096,7 +3096,11 @@ impl<T> [T] {
// SAFETY: the conditions for `ptr::copy` have all been checked above,
// as have those for `ptr::add`.
unsafe {
ptr::copy(self.as_ptr().add(src_start), self.as_mut_ptr().add(dest), count);
// Derive both `src_ptr` and `dest_ptr` from the same loan
let ptr = self.as_mut_ptr();
let src_ptr = ptr.add(src_start);
let dest_ptr = ptr.add(dest);
ptr::copy(src_ptr, dest_ptr, count);
}
}

Expand Down
25 changes: 17 additions & 8 deletions library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![unstable(
feature = "ip",
reason = "extra functionality has not been \
scrutinized to the level that it should \
be to be stable",
issue = "27709"
)]

// Tests for this module
#[cfg(all(test, not(target_os = "emscripten")))]
mod tests;
Expand Down Expand Up @@ -126,6 +118,7 @@ pub struct Ipv6Addr {

#[allow(missing_docs)]
#[derive(Copy, PartialEq, Eq, Clone, Hash, Debug)]
#[unstable(feature = "ip", issue = "27709")]
pub enum Ipv6MulticastScope {
InterfaceLocal,
LinkLocal,
Expand Down Expand Up @@ -199,6 +192,7 @@ impl IpAddr {
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1)).is_global(), true);
/// ```
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_global(&self) -> bool {
match self {
Expand Down Expand Up @@ -249,6 +243,7 @@ impl IpAddr {
/// );
/// ```
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_documentation(&self) -> bool {
match self {
Expand Down Expand Up @@ -549,6 +544,7 @@ impl Ipv4Addr {
/// assert_eq!(Ipv4Addr::new(80, 9, 12, 3).is_global(), true);
/// ```
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_global(&self) -> bool {
// check if this address is 192.0.0.9 or 192.0.0.10. These addresses are the only two
Expand Down Expand Up @@ -587,6 +583,7 @@ impl Ipv4Addr {
/// assert_eq!(Ipv4Addr::new(100, 128, 0, 0).is_shared(), false);
/// ```
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_shared(&self) -> bool {
self.octets()[0] == 100 && (self.octets()[1] & 0b1100_0000 == 0b0100_0000)
Expand Down Expand Up @@ -620,6 +617,7 @@ impl Ipv4Addr {
/// assert_eq!(Ipv4Addr::new(191, 255, 255, 255).is_ietf_protocol_assignment(), false);
/// ```
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_ietf_protocol_assignment(&self) -> bool {
self.octets()[0] == 192 && self.octets()[1] == 0 && self.octets()[2] == 0
Expand All @@ -644,6 +642,7 @@ impl Ipv4Addr {
/// assert_eq!(Ipv4Addr::new(198, 20, 0, 0).is_benchmarking(), false);
/// ```
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_benchmarking(&self) -> bool {
self.octets()[0] == 198 && (self.octets()[1] & 0xfe) == 18
Expand Down Expand Up @@ -677,6 +676,7 @@ impl Ipv4Addr {
/// assert_eq!(Ipv4Addr::new(255, 255, 255, 255).is_reserved(), false);
/// ```
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_reserved(&self) -> bool {
self.octets()[0] & 240 == 240 && !self.is_broadcast()
Expand Down Expand Up @@ -1234,6 +1234,7 @@ impl Ipv6Addr {
/// assert_eq!(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1).is_global(), true);
/// ```
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_global(&self) -> bool {
match self.multicast_scope() {
Expand All @@ -1260,6 +1261,7 @@ impl Ipv6Addr {
/// assert_eq!(Ipv6Addr::new(0xfc02, 0, 0, 0, 0, 0, 0, 0).is_unique_local(), true);
/// ```
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_unique_local(&self) -> bool {
(self.segments()[0] & 0xfe00) == 0xfc00
Expand Down Expand Up @@ -1315,6 +1317,7 @@ impl Ipv6Addr {
/// [IETF RFC 4291 section 2.5.6]: https://tools.ietf.org/html/rfc4291#section-2.5.6
/// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_unicast_link_local_strict(&self) -> bool {
matches!(self.segments(), [0xfe80, 0, 0, 0, ..])
Expand Down Expand Up @@ -1369,6 +1372,7 @@ impl Ipv6Addr {
/// [IETF RFC 4291 section 2.4]: https://tools.ietf.org/html/rfc4291#section-2.4
/// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_unicast_link_local(&self) -> bool {
(self.segments()[0] & 0xffc0) == 0xfe80
Expand Down Expand Up @@ -1409,6 +1413,7 @@ impl Ipv6Addr {
///
/// [RFC 3879]: https://tools.ietf.org/html/rfc3879
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_unicast_site_local(&self) -> bool {
(self.segments()[0] & 0xffc0) == 0xfec0
Expand All @@ -1432,6 +1437,7 @@ impl Ipv6Addr {
/// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true);
/// ```
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_documentation(&self) -> bool {
(self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8)
Expand Down Expand Up @@ -1468,6 +1474,7 @@ impl Ipv6Addr {
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_global(), true);
/// ```
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn is_unicast_global(&self) -> bool {
!self.is_multicast()
Expand All @@ -1494,6 +1501,7 @@ impl Ipv6Addr {
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).multicast_scope(), None);
/// ```
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn multicast_scope(&self) -> Option<Ipv6MulticastScope> {
if self.is_multicast() {
Expand Down Expand Up @@ -1555,6 +1563,7 @@ impl Ipv6Addr {
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None);
/// ```
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
#[unstable(feature = "ip", issue = "27709")]
#[inline]
pub const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr> {
match self.octets() {
Expand Down
10 changes: 8 additions & 2 deletions library/std/src/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,14 @@ impl<T: ?Sized> Mutex<T> {
/// # Errors
///
/// If another user of this mutex panicked while holding the mutex, then
/// this call will return an error if the mutex would otherwise be
/// acquired.
/// this call will return the [`Poisoned`] error if the mutex would
/// otherwise be acquired.
///
/// If the mutex could not be acquired because it is already locked, then
/// this call will return the [`WouldBlock`] error.
///
/// [`Poisoned`]: TryLockError::Poisoned
/// [`WouldBlock`]: TryLockError::WouldBlock
///
/// # Examples
///
Expand Down
27 changes: 20 additions & 7 deletions library/std/src/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,17 @@ impl<T: ?Sized> RwLock<T> {
///
/// # Errors
///
/// This function will return an error if the RwLock is poisoned. An RwLock
/// is poisoned whenever a writer panics while holding an exclusive lock. An
/// error will only be returned if the lock would have otherwise been
/// This function will return the [`Poisoned`] error if the RwLock is poisoned.
/// An RwLock is poisoned whenever a writer panics while holding an exclusive
/// lock. `Poisoned` will only be returned if the lock would have otherwise been
/// acquired.
///
/// This function will return the [`WouldBlock`] error if the RwLock could not
/// be acquired because it was already locked exclusively.
///
/// [`Poisoned`]: TryLockError::Poisoned
/// [`WouldBlock`]: TryLockError::WouldBlock
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -281,10 +287,17 @@ impl<T: ?Sized> RwLock<T> {
///
/// # Errors
///
/// This function will return an error if the RwLock is poisoned. An RwLock
/// is poisoned whenever a writer panics while holding an exclusive lock. An
/// error will only be returned if the lock would have otherwise been
/// acquired.
/// This function will return the [`Poisoned`] error if the RwLock is
/// poisoned. An RwLock is poisoned whenever a writer panics while holding
/// an exclusive lock. `Poisoned` will only be returned if the lock would have
/// otherwise been acquired.
///
/// This function will return the [`WouldBlock`] error if the RwLock could not
/// be acquired because it was already locked exclusively.
///
/// [`Poisoned`]: TryLockError::Poisoned
/// [`WouldBlock`]: TryLockError::WouldBlock
///
///
/// # Examples
///
Expand Down
16 changes: 12 additions & 4 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,20 +991,28 @@ def update_submodules(self):
).decode(default_encoding).splitlines()]
filtered_submodules = []
submodules_names = []
llvm_checked_out = os.path.exists(os.path.join(self.rust_root, "src/llvm-project/.git"))
external_llvm_provided = self.get_toml('llvm-config') or self.downloading_llvm()
llvm_needed = not self.get_toml('codegen-backends', 'rust') \
or "llvm" in self.get_toml('codegen-backends', 'rust')
for module in submodules:
# This is handled by native::Llvm in rustbuild, not here
if module.endswith("llvm-project"):
continue
# Don't sync the llvm-project submodule if an external LLVM was
# provided, if we are downloading LLVM or if the LLVM backend is
# not being built. Also, if the submodule has been initialized
# already, sync it anyways so that it doesn't mess up contributor
# pull requests.
if external_llvm_provided or not llvm_needed:
if self.get_toml('lld') != 'true' and not llvm_checked_out:
continue
check = self.check_submodule(module, slow_submodules)
filtered_submodules.append((module, check))
submodules_names.append(module)
recorded = subprocess.Popen(["git", "ls-tree", "HEAD"] + submodules_names,
cwd=self.rust_root, stdout=subprocess.PIPE)
recorded = recorded.communicate()[0].decode(default_encoding).strip().splitlines()
# { filename: hash }
recorded_submodules = {}
for data in recorded:
# [mode, kind, hash, filename]
data = data.split()
recorded_submodules[data[3]] = data[2]
for module in filtered_submodules:
Expand Down
10 changes: 0 additions & 10 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,22 +472,12 @@ impl Build {
slice::from_ref(&self.build.triple)
}

/// If the LLVM submodule has been initialized already, sync it unconditionally. This avoids
/// contributors checking in a submodule change by accident.
pub fn maybe_update_llvm_submodule(&self) {
if self.in_tree_llvm_info.is_git() {
native::update_llvm_submodule(self);
}
}

/// Executes the entire build, as configured by the flags and configuration.
pub fn build(&mut self) {
unsafe {
job::setup(self);
}

self.maybe_update_llvm_submodule();

if let Subcommand::Format { check, paths } = &self.config.cmd {
return format::format(self, *check, &paths);
}
Expand Down
Loading