Skip to content

Commit 1969c2e

Browse files
committed
Auto merge of rust-lang#85711 - JohnTitor:rollup-8why04t, r=JohnTitor
Rollup of 12 pull requests Successful merges: - rust-lang#84048 (Avoid CJK legacy fonts in Windows) - rust-lang#85529 (doc: clarify Mutex::try_lock, etc. errors) - rust-lang#85590 (Fix bootstrap using host exe suffix for cargo) - rust-lang#85610 (Fix pointer provenance in <[T]>::copy_within) - rust-lang#85623 (Remove stray .stderr files) - rust-lang#85645 (Demote `ControlFlow::{from|into}_try` to `pub(crate)`) - rust-lang#85647 (Revert "Move llvm submodule updates to rustbuild") - rust-lang#85666 (Document shared_from_cow functions) - rust-lang#85668 (Fix tasklist example in rustdoc book.) - rust-lang#85672 (Move stability attribute for items under the `ip` feature) - rust-lang#85699 (Update books) - rust-lang#85701 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 54bdfa1 + 7c0677a commit 1969c2e

27 files changed

+223
-198
lines changed

Diff for: library/alloc/src/rc.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,18 @@ where
18591859
B: ToOwned + ?Sized,
18601860
Rc<B>: From<&'a B> + From<B::Owned>,
18611861
{
1862+
/// Create a reference-counted pointer from
1863+
/// a clone-on-write pointer by copying its content.
1864+
///
1865+
/// # Example
1866+
///
1867+
/// ```rust
1868+
/// # use std::rc::Rc;
1869+
/// # use std::borrow::Cow;
1870+
/// let cow: Cow<str> = Cow::Borrowed("eggplant");
1871+
/// let shared: Rc<str> = Rc::from(cow);
1872+
/// assert_eq!("eggplant", &shared[..]);
1873+
/// ```
18621874
#[inline]
18631875
fn from(cow: Cow<'a, B>) -> Rc<B> {
18641876
match cow {

Diff for: library/alloc/src/sync.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2413,6 +2413,18 @@ where
24132413
B: ToOwned + ?Sized,
24142414
Arc<B>: From<&'a B> + From<B::Owned>,
24152415
{
2416+
/// Create an atomically reference-counted pointer from
2417+
/// a clone-on-write pointer by copying its content.
2418+
///
2419+
/// # Example
2420+
///
2421+
/// ```rust
2422+
/// # use std::sync::Arc;
2423+
/// # use std::borrow::Cow;
2424+
/// let cow: Cow<str> = Cow::Borrowed("eggplant");
2425+
/// let shared: Arc<str> = Arc::from(cow);
2426+
/// assert_eq!("eggplant", &shared[..]);
2427+
/// ```
24162428
#[inline]
24172429
fn from(cow: Cow<'a, B>) -> Arc<B> {
24182430
match cow {

Diff for: library/core/src/ops/control_flow.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -187,42 +187,41 @@ impl<B, C> ControlFlow<B, C> {
187187
#[cfg(bootstrap)]
188188
impl<R: ops::TryV1> ControlFlow<R, R::Output> {
189189
/// Create a `ControlFlow` from any type implementing `Try`.
190-
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
191190
#[inline]
192-
pub fn from_try(r: R) -> Self {
191+
pub(crate) fn from_try(r: R) -> Self {
193192
match R::into_result(r) {
194193
Ok(v) => ControlFlow::Continue(v),
195194
Err(v) => ControlFlow::Break(R::from_error(v)),
196195
}
197196
}
198197

199198
/// Convert a `ControlFlow` into any type implementing `Try`;
200-
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
201199
#[inline]
202-
pub fn into_try(self) -> R {
200+
pub(crate) fn into_try(self) -> R {
203201
match self {
204202
ControlFlow::Continue(v) => R::from_ok(v),
205203
ControlFlow::Break(v) => v,
206204
}
207205
}
208206
}
209207

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

222222
/// Convert a `ControlFlow` into any type implementing `Try`;
223-
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
224223
#[inline]
225-
pub fn into_try(self) -> R {
224+
pub(crate) fn into_try(self) -> R {
226225
match self {
227226
ControlFlow::Continue(v) => R::from_output(v),
228227
ControlFlow::Break(v) => v,

Diff for: library/core/src/slice/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -3096,7 +3096,11 @@ impl<T> [T] {
30963096
// SAFETY: the conditions for `ptr::copy` have all been checked above,
30973097
// as have those for `ptr::add`.
30983098
unsafe {
3099-
ptr::copy(self.as_ptr().add(src_start), self.as_mut_ptr().add(dest), count);
3099+
// Derive both `src_ptr` and `dest_ptr` from the same loan
3100+
let ptr = self.as_mut_ptr();
3101+
let src_ptr = ptr.add(src_start);
3102+
let dest_ptr = ptr.add(dest);
3103+
ptr::copy(src_ptr, dest_ptr, count);
31003104
}
31013105
}
31023106

Diff for: library/std/src/net/ip.rs

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#![unstable(
2-
feature = "ip",
3-
reason = "extra functionality has not been \
4-
scrutinized to the level that it should \
5-
be to be stable",
6-
issue = "27709"
7-
)]
8-
91
// Tests for this module
102
#[cfg(all(test, not(target_os = "emscripten")))]
113
mod tests;
@@ -126,6 +118,7 @@ pub struct Ipv6Addr {
126118

127119
#[allow(missing_docs)]
128120
#[derive(Copy, PartialEq, Eq, Clone, Hash, Debug)]
121+
#[unstable(feature = "ip", issue = "27709")]
129122
pub enum Ipv6MulticastScope {
130123
InterfaceLocal,
131124
LinkLocal,
@@ -199,6 +192,7 @@ impl IpAddr {
199192
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1)).is_global(), true);
200193
/// ```
201194
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
195+
#[unstable(feature = "ip", issue = "27709")]
202196
#[inline]
203197
pub const fn is_global(&self) -> bool {
204198
match self {
@@ -249,6 +243,7 @@ impl IpAddr {
249243
/// );
250244
/// ```
251245
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
246+
#[unstable(feature = "ip", issue = "27709")]
252247
#[inline]
253248
pub const fn is_documentation(&self) -> bool {
254249
match self {
@@ -549,6 +544,7 @@ impl Ipv4Addr {
549544
/// assert_eq!(Ipv4Addr::new(80, 9, 12, 3).is_global(), true);
550545
/// ```
551546
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
547+
#[unstable(feature = "ip", issue = "27709")]
552548
#[inline]
553549
pub const fn is_global(&self) -> bool {
554550
// check if this address is 192.0.0.9 or 192.0.0.10. These addresses are the only two
@@ -587,6 +583,7 @@ impl Ipv4Addr {
587583
/// assert_eq!(Ipv4Addr::new(100, 128, 0, 0).is_shared(), false);
588584
/// ```
589585
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
586+
#[unstable(feature = "ip", issue = "27709")]
590587
#[inline]
591588
pub const fn is_shared(&self) -> bool {
592589
self.octets()[0] == 100 && (self.octets()[1] & 0b1100_0000 == 0b0100_0000)
@@ -620,6 +617,7 @@ impl Ipv4Addr {
620617
/// assert_eq!(Ipv4Addr::new(191, 255, 255, 255).is_ietf_protocol_assignment(), false);
621618
/// ```
622619
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
620+
#[unstable(feature = "ip", issue = "27709")]
623621
#[inline]
624622
pub const fn is_ietf_protocol_assignment(&self) -> bool {
625623
self.octets()[0] == 192 && self.octets()[1] == 0 && self.octets()[2] == 0
@@ -644,6 +642,7 @@ impl Ipv4Addr {
644642
/// assert_eq!(Ipv4Addr::new(198, 20, 0, 0).is_benchmarking(), false);
645643
/// ```
646644
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
645+
#[unstable(feature = "ip", issue = "27709")]
647646
#[inline]
648647
pub const fn is_benchmarking(&self) -> bool {
649648
self.octets()[0] == 198 && (self.octets()[1] & 0xfe) == 18
@@ -677,6 +676,7 @@ impl Ipv4Addr {
677676
/// assert_eq!(Ipv4Addr::new(255, 255, 255, 255).is_reserved(), false);
678677
/// ```
679678
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
679+
#[unstable(feature = "ip", issue = "27709")]
680680
#[inline]
681681
pub const fn is_reserved(&self) -> bool {
682682
self.octets()[0] & 240 == 240 && !self.is_broadcast()
@@ -1234,6 +1234,7 @@ impl Ipv6Addr {
12341234
/// assert_eq!(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1).is_global(), true);
12351235
/// ```
12361236
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1237+
#[unstable(feature = "ip", issue = "27709")]
12371238
#[inline]
12381239
pub const fn is_global(&self) -> bool {
12391240
match self.multicast_scope() {
@@ -1260,6 +1261,7 @@ impl Ipv6Addr {
12601261
/// assert_eq!(Ipv6Addr::new(0xfc02, 0, 0, 0, 0, 0, 0, 0).is_unique_local(), true);
12611262
/// ```
12621263
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1264+
#[unstable(feature = "ip", issue = "27709")]
12631265
#[inline]
12641266
pub const fn is_unique_local(&self) -> bool {
12651267
(self.segments()[0] & 0xfe00) == 0xfc00
@@ -1315,6 +1317,7 @@ impl Ipv6Addr {
13151317
/// [IETF RFC 4291 section 2.5.6]: https://tools.ietf.org/html/rfc4291#section-2.5.6
13161318
/// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406
13171319
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1320+
#[unstable(feature = "ip", issue = "27709")]
13181321
#[inline]
13191322
pub const fn is_unicast_link_local_strict(&self) -> bool {
13201323
matches!(self.segments(), [0xfe80, 0, 0, 0, ..])
@@ -1369,6 +1372,7 @@ impl Ipv6Addr {
13691372
/// [IETF RFC 4291 section 2.4]: https://tools.ietf.org/html/rfc4291#section-2.4
13701373
/// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406
13711374
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1375+
#[unstable(feature = "ip", issue = "27709")]
13721376
#[inline]
13731377
pub const fn is_unicast_link_local(&self) -> bool {
13741378
(self.segments()[0] & 0xffc0) == 0xfe80
@@ -1409,6 +1413,7 @@ impl Ipv6Addr {
14091413
///
14101414
/// [RFC 3879]: https://tools.ietf.org/html/rfc3879
14111415
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1416+
#[unstable(feature = "ip", issue = "27709")]
14121417
#[inline]
14131418
pub const fn is_unicast_site_local(&self) -> bool {
14141419
(self.segments()[0] & 0xffc0) == 0xfec0
@@ -1432,6 +1437,7 @@ impl Ipv6Addr {
14321437
/// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true);
14331438
/// ```
14341439
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1440+
#[unstable(feature = "ip", issue = "27709")]
14351441
#[inline]
14361442
pub const fn is_documentation(&self) -> bool {
14371443
(self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8)
@@ -1468,6 +1474,7 @@ impl Ipv6Addr {
14681474
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_global(), true);
14691475
/// ```
14701476
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1477+
#[unstable(feature = "ip", issue = "27709")]
14711478
#[inline]
14721479
pub const fn is_unicast_global(&self) -> bool {
14731480
!self.is_multicast()
@@ -1494,6 +1501,7 @@ impl Ipv6Addr {
14941501
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).multicast_scope(), None);
14951502
/// ```
14961503
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1504+
#[unstable(feature = "ip", issue = "27709")]
14971505
#[inline]
14981506
pub const fn multicast_scope(&self) -> Option<Ipv6MulticastScope> {
14991507
if self.is_multicast() {
@@ -1555,6 +1563,7 @@ impl Ipv6Addr {
15551563
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None);
15561564
/// ```
15571565
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1566+
#[unstable(feature = "ip", issue = "27709")]
15581567
#[inline]
15591568
pub const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr> {
15601569
match self.octets() {

Diff for: library/std/src/sync/mutex.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,14 @@ impl<T: ?Sized> Mutex<T> {
294294
/// # Errors
295295
///
296296
/// If another user of this mutex panicked while holding the mutex, then
297-
/// this call will return an error if the mutex would otherwise be
298-
/// acquired.
297+
/// this call will return the [`Poisoned`] error if the mutex would
298+
/// otherwise be acquired.
299+
///
300+
/// If the mutex could not be acquired because it is already locked, then
301+
/// this call will return the [`WouldBlock`] error.
302+
///
303+
/// [`Poisoned`]: TryLockError::Poisoned
304+
/// [`WouldBlock`]: TryLockError::WouldBlock
299305
///
300306
/// # Examples
301307
///

Diff for: library/std/src/sync/rwlock.rs

+20-7
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,17 @@ impl<T: ?Sized> RwLock<T> {
199199
///
200200
/// # Errors
201201
///
202-
/// This function will return an error if the RwLock is poisoned. An RwLock
203-
/// is poisoned whenever a writer panics while holding an exclusive lock. An
204-
/// error will only be returned if the lock would have otherwise been
202+
/// This function will return the [`Poisoned`] error if the RwLock is poisoned.
203+
/// An RwLock is poisoned whenever a writer panics while holding an exclusive
204+
/// lock. `Poisoned` will only be returned if the lock would have otherwise been
205205
/// acquired.
206206
///
207+
/// This function will return the [`WouldBlock`] error if the RwLock could not
208+
/// be acquired because it was already locked exclusively.
209+
///
210+
/// [`Poisoned`]: TryLockError::Poisoned
211+
/// [`WouldBlock`]: TryLockError::WouldBlock
212+
///
207213
/// # Examples
208214
///
209215
/// ```
@@ -281,10 +287,17 @@ impl<T: ?Sized> RwLock<T> {
281287
///
282288
/// # Errors
283289
///
284-
/// This function will return an error if the RwLock is poisoned. An RwLock
285-
/// is poisoned whenever a writer panics while holding an exclusive lock. An
286-
/// error will only be returned if the lock would have otherwise been
287-
/// acquired.
290+
/// This function will return the [`Poisoned`] error if the RwLock is
291+
/// poisoned. An RwLock is poisoned whenever a writer panics while holding
292+
/// an exclusive lock. `Poisoned` will only be returned if the lock would have
293+
/// otherwise been acquired.
294+
///
295+
/// This function will return the [`WouldBlock`] error if the RwLock could not
296+
/// be acquired because it was already locked exclusively.
297+
///
298+
/// [`Poisoned`]: TryLockError::Poisoned
299+
/// [`WouldBlock`]: TryLockError::WouldBlock
300+
///
288301
///
289302
/// # Examples
290303
///

Diff for: src/bootstrap/bootstrap.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -991,20 +991,28 @@ def update_submodules(self):
991991
).decode(default_encoding).splitlines()]
992992
filtered_submodules = []
993993
submodules_names = []
994+
llvm_checked_out = os.path.exists(os.path.join(self.rust_root, "src/llvm-project/.git"))
995+
external_llvm_provided = self.get_toml('llvm-config') or self.downloading_llvm()
996+
llvm_needed = not self.get_toml('codegen-backends', 'rust') \
997+
or "llvm" in self.get_toml('codegen-backends', 'rust')
994998
for module in submodules:
995-
# This is handled by native::Llvm in rustbuild, not here
996999
if module.endswith("llvm-project"):
997-
continue
1000+
# Don't sync the llvm-project submodule if an external LLVM was
1001+
# provided, if we are downloading LLVM or if the LLVM backend is
1002+
# not being built. Also, if the submodule has been initialized
1003+
# already, sync it anyways so that it doesn't mess up contributor
1004+
# pull requests.
1005+
if external_llvm_provided or not llvm_needed:
1006+
if self.get_toml('lld') != 'true' and not llvm_checked_out:
1007+
continue
9981008
check = self.check_submodule(module, slow_submodules)
9991009
filtered_submodules.append((module, check))
10001010
submodules_names.append(module)
10011011
recorded = subprocess.Popen(["git", "ls-tree", "HEAD"] + submodules_names,
10021012
cwd=self.rust_root, stdout=subprocess.PIPE)
10031013
recorded = recorded.communicate()[0].decode(default_encoding).strip().splitlines()
1004-
# { filename: hash }
10051014
recorded_submodules = {}
10061015
for data in recorded:
1007-
# [mode, kind, hash, filename]
10081016
data = data.split()
10091017
recorded_submodules[data[3]] = data[2]
10101018
for module in filtered_submodules:

Diff for: src/bootstrap/lib.rs

-10
Original file line numberDiff line numberDiff line change
@@ -472,22 +472,12 @@ impl Build {
472472
slice::from_ref(&self.build.triple)
473473
}
474474

475-
/// If the LLVM submodule has been initialized already, sync it unconditionally. This avoids
476-
/// contributors checking in a submodule change by accident.
477-
pub fn maybe_update_llvm_submodule(&self) {
478-
if self.in_tree_llvm_info.is_git() {
479-
native::update_llvm_submodule(self);
480-
}
481-
}
482-
483475
/// Executes the entire build, as configured by the flags and configuration.
484476
pub fn build(&mut self) {
485477
unsafe {
486478
job::setup(self);
487479
}
488480

489-
self.maybe_update_llvm_submodule();
490-
491481
if let Subcommand::Format { check, paths } = &self.config.cmd {
492482
return format::format(self, *check, &paths);
493483
}

0 commit comments

Comments
 (0)