Skip to content

Commit 16c1a9d

Browse files
committed
Auto merge of rust-lang#93220 - matthiaskrgr:rollup-9bkrlk0, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#90666 (Stabilize arc_new_cyclic) - rust-lang#91122 (impl Not for !) - rust-lang#93068 (Fix spacing for `·` between stability and source) - rust-lang#93103 (Tweak `expr.await` desugaring `Span`) - rust-lang#93113 (Unify search input and buttons size) - rust-lang#93168 (update uclibc instructions for new toolchain, add link from platforms doc) - rust-lang#93185 (rustdoc: Make some `pub` items crate-private) - rust-lang#93196 (Remove dead code from build_helper) Failed merges: - rust-lang#93188 (rustdoc: fix bump down typing search on Safari) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d13e8dd + 1a935a5 commit 16c1a9d

File tree

25 files changed

+191
-187
lines changed

25 files changed

+191
-187
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -625,18 +625,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
625625
/// }
626626
/// }
627627
/// ```
628-
fn lower_expr_await(&mut self, await_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
629-
let dot_await_span = expr.span.shrink_to_hi().to(await_span);
628+
fn lower_expr_await(&mut self, dot_await_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
629+
let full_span = expr.span.to(dot_await_span);
630630
match self.generator_kind {
631631
Some(hir::GeneratorKind::Async(_)) => {}
632632
Some(hir::GeneratorKind::Gen) | None => {
633633
let mut err = struct_span_err!(
634634
self.sess,
635-
await_span,
635+
dot_await_span,
636636
E0728,
637637
"`await` is only allowed inside `async` functions and blocks"
638638
);
639-
err.span_label(await_span, "only allowed inside `async` functions and blocks");
639+
err.span_label(dot_await_span, "only allowed inside `async` functions and blocks");
640640
if let Some(item_sp) = self.current_item {
641641
err.span_label(item_sp, "this is not `async`");
642642
}
@@ -646,7 +646,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
646646
let span = self.mark_span_with_reason(DesugaringKind::Await, dot_await_span, None);
647647
let gen_future_span = self.mark_span_with_reason(
648648
DesugaringKind::Await,
649-
await_span,
649+
full_span,
650650
self.allow_gen_future.clone(),
651651
);
652652
let expr = self.lower_expr_mut(expr);
@@ -699,9 +699,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
699699
let loop_hir_id = self.lower_node_id(loop_node_id);
700700
let ready_arm = {
701701
let x_ident = Ident::with_dummy_span(sym::result);
702-
let (x_pat, x_pat_hid) = self.pat_ident(span, x_ident);
703-
let x_expr = self.expr_ident(span, x_ident, x_pat_hid);
704-
let ready_field = self.single_pat_field(span, x_pat);
702+
let (x_pat, x_pat_hid) = self.pat_ident(gen_future_span, x_ident);
703+
let x_expr = self.expr_ident(gen_future_span, x_ident, x_pat_hid);
704+
let ready_field = self.single_pat_field(gen_future_span, x_pat);
705705
let ready_pat = self.pat_lang_item_variant(
706706
span,
707707
hir::LangItem::PollReady,
@@ -711,7 +711,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
711711
let break_x = self.with_loop_scope(loop_node_id, move |this| {
712712
let expr_break =
713713
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
714-
this.arena.alloc(this.expr(span, expr_break, ThinVec::new()))
714+
this.arena.alloc(this.expr(gen_future_span, expr_break, ThinVec::new()))
715715
});
716716
self.arm(ready_pat, break_x)
717717
};
@@ -783,7 +783,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
783783
// `match ::std::future::IntoFuture::into_future(<expr>) { ... }`
784784
let into_future_span = self.mark_span_with_reason(
785785
DesugaringKind::Await,
786-
await_span,
786+
dot_await_span,
787787
self.allow_into_future.clone(),
788788
);
789789
let into_future_expr = self.expr_call_lang_item_fn(

library/alloc/src/rc.rs

+31-13
Original file line numberDiff line numberDiff line change
@@ -374,33 +374,51 @@ impl<T> Rc<T> {
374374
}
375375
}
376376

377-
/// Constructs a new `Rc<T>` using a weak reference to itself. Attempting
378-
/// to upgrade the weak reference before this function returns will result
379-
/// in a `None` value. However, the weak reference may be cloned freely and
380-
/// stored for use at a later time.
377+
/// Constructs a new `Rc<T>` using a closure `data_fn` that has access to a
378+
/// weak reference to the constructing `Rc<T>`.
379+
///
380+
/// Generally, a structure circularly referencing itself, either directly or
381+
/// indirectly, should not hold a strong reference to prevent a memory leak.
382+
/// In `data_fn`, initialization of `T` can make use of the weak reference
383+
/// by cloning and storing it inside `T` for use at a later time.
384+
///
385+
/// Since the new `Rc<T>` is not fully-constructed until `Rc<T>::new_cyclic`
386+
/// returns, calling [`upgrade`] on the weak reference inside `data_fn` will
387+
/// fail and result in a `None` value.
388+
///
389+
/// # Panics
390+
/// If `data_fn` panics, the panic is propagated to the caller, and the
391+
/// temporary [`Weak<T>`] is dropped normally.
381392
///
382393
/// # Examples
383394
///
384395
/// ```
385-
/// #![feature(arc_new_cyclic)]
386396
/// #![allow(dead_code)]
387397
/// use std::rc::{Rc, Weak};
388398
///
389399
/// struct Gadget {
390-
/// self_weak: Weak<Self>,
391-
/// // ... more fields
400+
/// me: Weak<Gadget>,
392401
/// }
402+
///
393403
/// impl Gadget {
394-
/// pub fn new() -> Rc<Self> {
395-
/// Rc::new_cyclic(|self_weak| {
396-
/// Gadget { self_weak: self_weak.clone(), /* ... */ }
397-
/// })
404+
/// /// Construct a reference counted Gadget.
405+
/// fn new() -> Rc<Self> {
406+
/// Rc::new_cyclic(|me| Gadget { me: me.clone() })
407+
/// }
408+
///
409+
/// /// Return a reference counted pointer to Self.
410+
/// fn me(&self) -> Rc<Self> {
411+
/// self.me.upgrade().unwrap()
398412
/// }
399413
/// }
400414
/// ```
415+
/// [`upgrade`]: Weak::upgrade
401416
#[cfg(not(no_global_oom_handling))]
402-
#[unstable(feature = "arc_new_cyclic", issue = "75861")]
403-
pub fn new_cyclic(data_fn: impl FnOnce(&Weak<T>) -> T) -> Rc<T> {
417+
#[stable(feature = "arc_new_cyclic", since = "1.60.0")]
418+
pub fn new_cyclic<F>(data_fn: F) -> Rc<T>
419+
where
420+
F: FnOnce(&Weak<T>) -> T,
421+
{
404422
// Construct the inner in the "uninitialized" state with a single
405423
// weak reference.
406424
let uninit_ptr: NonNull<_> = Box::leak(box RcBox {

library/alloc/src/sync.rs

+35-14
Original file line numberDiff line numberDiff line change
@@ -351,30 +351,51 @@ impl<T> Arc<T> {
351351
unsafe { Self::from_inner(Box::leak(x).into()) }
352352
}
353353

354-
/// Constructs a new `Arc<T>` using a weak reference to itself. Attempting
355-
/// to upgrade the weak reference before this function returns will result
356-
/// in a `None` value. However, the weak reference may be cloned freely and
357-
/// stored for use at a later time.
354+
/// Constructs a new `Arc<T>` using a closure `data_fn` that has access to
355+
/// a weak reference to the constructing `Arc<T>`.
358356
///
359-
/// # Examples
357+
/// Generally, a structure circularly referencing itself, either directly or
358+
/// indirectly, should not hold a strong reference to prevent a memory leak.
359+
/// In `data_fn`, initialization of `T` can make use of the weak reference
360+
/// by cloning and storing it inside `T` for use at a later time.
361+
///
362+
/// Since the new `Arc<T>` is not fully-constructed until
363+
/// `Arc<T>::new_cyclic` returns, calling [`upgrade`] on the weak
364+
/// reference inside `data_fn` will fail and result in a `None` value.
365+
///
366+
/// # Panics
367+
/// If `data_fn` panics, the panic is propagated to the caller, and the
368+
/// temporary [`Weak<T>`] is dropped normally.
369+
///
370+
/// # Example
360371
/// ```
361-
/// #![feature(arc_new_cyclic)]
362372
/// #![allow(dead_code)]
363-
///
364373
/// use std::sync::{Arc, Weak};
365374
///
366-
/// struct Foo {
367-
/// me: Weak<Foo>,
375+
/// struct Gadget {
376+
/// me: Weak<Gadget>,
368377
/// }
369378
///
370-
/// let foo = Arc::new_cyclic(|me| Foo {
371-
/// me: me.clone(),
372-
/// });
379+
/// impl Gadget {
380+
/// /// Construct a reference counted Gadget.
381+
/// fn new() -> Arc<Self> {
382+
/// Arc::new_cyclic(|me| Gadget { me: me.clone() })
383+
/// }
384+
///
385+
/// /// Return a reference counted pointer to Self.
386+
/// fn me(&self) -> Arc<Self> {
387+
/// self.me.upgrade().unwrap()
388+
/// }
389+
/// }
373390
/// ```
391+
/// [`upgrade`]: Weak::upgrade
374392
#[cfg(not(no_global_oom_handling))]
375393
#[inline]
376-
#[unstable(feature = "arc_new_cyclic", issue = "75861")]
377-
pub fn new_cyclic(data_fn: impl FnOnce(&Weak<T>) -> T) -> Arc<T> {
394+
#[stable(feature = "arc_new_cyclic", since = "1.60.0")]
395+
pub fn new_cyclic<F>(data_fn: F) -> Arc<T>
396+
where
397+
F: FnOnce(&Weak<T>) -> T,
398+
{
378399
// Construct the inner in the "uninitialized" state with a single
379400
// weak reference.
380401
let uninit_ptr: NonNull<_> = Box::leak(box ArcInner {

library/core/src/ops/bit.rs

+11
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ macro_rules! not_impl {
6868

6969
not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
7070

71+
#[stable(feature = "not_never", since = "1.60.0")]
72+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
73+
impl const Not for ! {
74+
type Output = !;
75+
76+
#[inline]
77+
fn not(self) -> ! {
78+
match self {}
79+
}
80+
}
81+
7182
/// The bitwise AND operator `&`.
7283
///
7384
/// Note that `Rhs` is `Self` by default, but this is not mandatory.

library/core/tests/ops.rs

+6
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,9 @@ fn deref_on_ref() {
232232
let y = deref(&mut x);
233233
assert_eq!(y, 4);
234234
}
235+
236+
#[test]
237+
#[allow(unreachable_code)]
238+
fn test_not_never() {
239+
if !return () {}
240+
}

src/build_helper/lib.rs

-16
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ pub fn restore_library_path() {
5555
}
5656
}
5757

58-
/// Run the command, printing what we are running.
59-
pub fn run_verbose(cmd: &mut Command) {
60-
println!("running: {:?}", cmd);
61-
run(cmd);
62-
}
63-
6458
pub fn run(cmd: &mut Command) {
6559
if !try_run(cmd) {
6660
std::process::exit(1);
@@ -108,16 +102,6 @@ pub fn try_run_suppressed(cmd: &mut Command) -> bool {
108102
output.status.success()
109103
}
110104

111-
pub fn gnu_target(target: &str) -> &str {
112-
match target {
113-
"i686-pc-windows-msvc" => "i686-pc-win32",
114-
"x86_64-pc-windows-msvc" => "x86_64-pc-win32",
115-
"i686-pc-windows-gnu" => "i686-w64-mingw32",
116-
"x86_64-pc-windows-gnu" => "x86_64-w64-mingw32",
117-
s => s,
118-
}
119-
}
120-
121105
pub fn make(host: &str) -> PathBuf {
122106
if host.contains("dragonfly")
123107
|| host.contains("freebsd")

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [Platform Support](platform-support.md)
1616
- [Template for target-specific documentation](platform-support/TEMPLATE.md)
1717
- [aarch64-apple-ios-sim](platform-support/aarch64-apple-ios-sim.md)
18+
- [armv7-unknown-linux-uclibceabihf](platform-support/armv7-unknown-linux-uclibceabihf.md)
1819
- [\*-kmc-solid_\*](platform-support/kmc-solid.md)
1920
- [x86_64-unknown-none](platform-support/x86_64-unknown-none.md)
2021
- [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md)

src/doc/rustc/src/platform-support.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ target | std | host | notes
220220
`armv6-unknown-netbsd-eabihf` | ? | |
221221
`armv6k-nintendo-3ds` | * | | ARMv6K Nintendo 3DS, Horizon (Requires devkitARM toolchain)
222222
`armv7-apple-ios` | ✓ | | ARMv7 iOS, Cortex-a8
223-
`armv7-unknown-linux-uclibceabihf` | ✓ | ? | ARMv7 Linux uClibc
223+
[`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | ARMv7 Linux uClibc
224224
`armv7-unknown-freebsd` | ✓ | ✓ | ARMv7 FreeBSD
225225
`armv7-unknown-netbsd-eabihf` | ✓ | ✓ |
226226
`armv7-wrs-vxworks-eabihf` | ? | |

src/doc/rustc/src/platform-support/armv7-unknown-linux-uclibceabihf.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This target is cross compiled, and requires a cross toolchain. You can find sui
1818

1919
Compiling rust for this target has been tested on `x86_64` linux hosts. Other host types have not been tested, but may work, if you can find a suitable cross compilation toolchain for them.
2020

21-
If you don't already have a suitable toolchain, download one [here](https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--bleeding-edge-2020.08-1.tar.bz2), and unpack it into a directory.
21+
If you don't already have a suitable toolchain, download one [here](https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--bleeding-edge-2021.11-1.tar.bz2), and unpack it into a directory.
2222

2323
### Configure rust
2424

src/librustdoc/clean/types.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl Item {
429429

430430
/// Convenience wrapper around [`Self::from_def_id_and_parts`] which converts
431431
/// `hir_id` to a [`DefId`]
432-
pub fn from_hir_id_and_parts(
432+
crate fn from_hir_id_and_parts(
433433
hir_id: hir::HirId,
434434
name: Option<Symbol>,
435435
kind: ItemKind,
@@ -438,7 +438,7 @@ impl Item {
438438
Item::from_def_id_and_parts(cx.tcx.hir().local_def_id(hir_id).to_def_id(), name, kind, cx)
439439
}
440440

441-
pub fn from_def_id_and_parts(
441+
crate fn from_def_id_and_parts(
442442
def_id: DefId,
443443
name: Option<Symbol>,
444444
kind: ItemKind,
@@ -456,7 +456,7 @@ impl Item {
456456
)
457457
}
458458

459-
pub fn from_def_id_and_attrs_and_parts(
459+
crate fn from_def_id_and_attrs_and_parts(
460460
def_id: DefId,
461461
name: Option<Symbol>,
462462
kind: ItemKind,
@@ -984,26 +984,26 @@ crate fn collapse_doc_fragments(doc_strings: &[DocFragment]) -> String {
984984
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
985985
crate struct ItemLink {
986986
/// The original link written in the markdown
987-
pub(crate) link: String,
987+
crate link: String,
988988
/// The link text displayed in the HTML.
989989
///
990990
/// This may not be the same as `link` if there was a disambiguator
991991
/// in an intra-doc link (e.g. \[`fn@f`\])
992-
pub(crate) link_text: String,
993-
pub(crate) did: DefId,
992+
crate link_text: String,
993+
crate did: DefId,
994994
/// The url fragment to append to the link
995-
pub(crate) fragment: Option<UrlFragment>,
995+
crate fragment: Option<UrlFragment>,
996996
}
997997

998998
pub struct RenderedLink {
999999
/// The text the link was original written as.
10001000
///
10011001
/// This could potentially include disambiguators and backticks.
1002-
pub(crate) original_text: String,
1002+
crate original_text: String,
10031003
/// The text to display in the HTML
1004-
pub(crate) new_text: String,
1004+
crate new_text: String,
10051005
/// The URL to put in the `href`
1006-
pub(crate) href: String,
1006+
crate href: String,
10071007
}
10081008

10091009
/// The attributes on an [`Item`], including attributes like `#[derive(...)]` and `#[inline]`,

src/librustdoc/core.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use crate::passes::{self, Condition::*};
3333
crate use rustc_session::config::{DebuggingOptions, Input, Options};
3434

3535
crate struct ResolverCaches {
36-
pub all_traits: Option<Vec<DefId>>,
37-
pub all_trait_impls: Option<Vec<DefId>>,
36+
crate all_traits: Option<Vec<DefId>>,
37+
crate all_trait_impls: Option<Vec<DefId>>,
3838
}
3939

4040
crate struct DocContext<'tcx> {

src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ crate struct StylePath {
175175
}
176176

177177
impl StylePath {
178-
pub fn basename(&self) -> Result<String, Error> {
178+
crate fn basename(&self) -> Result<String, Error> {
179179
Ok(try_none!(try_none!(self.path.file_stem(), &self.path).to_str(), &self.path).to_string())
180180
}
181181
}

0 commit comments

Comments
 (0)