Skip to content

Commit bb491ed

Browse files
committed
Auto merge of rust-lang#84490 - JohnTitor:rollup-wrdj4ko, r=JohnTitor
Rollup of 11 pull requests Successful merges: - rust-lang#80805 (Improve `Iterator::by_ref` example) - rust-lang#84248 (Remove duplicated fn(Box<[T]>) -> Vec<T>) - rust-lang#84321 (rustdoc: Convert sub-variant toggle to HTML) - rust-lang#84359 (:arrow_up: rust-analyzer) - rust-lang#84374 (Clean up .gitignore) - rust-lang#84387 (Move `sys_common::poison` to `sync::poison`) - rust-lang#84430 (doc/platform-support: clarify UEFI support) - rust-lang#84433 (Prevent control, shift and alt keys to make search input lose focus) - rust-lang#84444 (doc: Get rid of "[+] show undocumented items" toggle on numeric From impls) - rust-lang#84456 (Fix ICE if original_span(fn_sig) returns a span not in body sourcefile) - rust-lang#84469 (Update comment on `PrimTy::name_str`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 481ba16 + 62db03c commit bb491ed

File tree

21 files changed

+120
-92
lines changed

21 files changed

+120
-92
lines changed

.gitignore

+44-26
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,71 @@
55
# created during manual debugging and many people like to clean up instead of
66
# having git ignore such leftovers. You can use `.git/info/exclude` to
77
# configure your local ignore list.
8-
# FIXME: This needs cleanup.
9-
*~
8+
9+
## File system
10+
.DS_Store
11+
desktop.ini
12+
13+
## Editor
1014
*.swp
1115
*.swo
12-
.#*
13-
.DS_Store
16+
Session.vim
1417
.cproject
15-
.hg/
16-
.hgignore
1718
.idea
1819
*.iml
19-
__pycache__/
20-
*.py[cod]
21-
*$py.class
20+
.vscode
2221
.project
22+
.favorites.json
2323
.settings/
24+
25+
## Tool
2426
.valgrindrc
25-
.vscode
26-
.favorites.json
27-
/Makefile
28-
/build/
27+
.cargo
28+
# Included because it is part of the test case
29+
!/src/test/run-make/thumb-none-qemu/example/.cargo
30+
31+
## Configuration
2932
/config.toml
30-
/dist/
33+
/Makefile
34+
config.mk
35+
config.stamp
36+
no_llvm_build
37+
38+
## Build
3139
/dl/
3240
/doc/
3341
/inst/
3442
/llvm/
3543
/mingw-build/
36-
/src/tools/x/target
37-
# Created by default with `src/ci/docker/run.sh`:
38-
/obj/
44+
/build/
45+
/dist/
3946
/unicode-downloads
4047
/target
41-
# Generated by compiletest for incremental:
48+
/src/tools/x/target
49+
# Generated by compiletest for incremental
4250
/tmp/
51+
# Created by default with `src/ci/docker/run.sh`
52+
/obj/
53+
54+
## Temporary files
55+
*~
56+
\#*
57+
\#*\#
58+
.#*
59+
60+
## Tags
4361
tags
4462
tags.*
4563
TAGS
4664
TAGS.*
47-
\#*
48-
\#*\#
49-
config.mk
50-
config.stamp
51-
Session.vim
52-
.cargo
53-
!/src/test/run-make/thumb-none-qemu/example/.cargo
54-
no_llvm_build
65+
66+
## Python
67+
__pycache__/
68+
*.py[cod]
69+
*$py.class
70+
71+
## Node
5572
**node_modules
5673
**package-lock.json
74+
5775
# Before adding new lines, see the comment at the top.

compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2201,7 +2201,7 @@ impl PrimTy {
22012201

22022202
/// Like [`PrimTy::name`], but returns a &str instead of a symbol.
22032203
///
2204-
/// Used by rustdoc.
2204+
/// Used by clippy.
22052205
pub fn name_str(self) -> &'static str {
22062206
match self {
22072207
PrimTy::Int(i) => i.name_str(),

compiler/rustc_mir/src/transform/coverage/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
111111
let body_span = hir_body.value.span;
112112
let source_file = source_map.lookup_source_file(body_span.lo());
113113
let fn_sig_span = match some_fn_sig.filter(|fn_sig| {
114-
Lrc::ptr_eq(&source_file, &source_map.lookup_source_file(fn_sig.span.hi()))
114+
fn_sig.span.ctxt() == body_span.ctxt()
115+
&& Lrc::ptr_eq(&source_file, &source_map.lookup_source_file(fn_sig.span.hi()))
115116
}) {
116117
Some(fn_sig) => fn_sig.span.with_hi(body_span.lo()),
117118
None => body_span.shrink_to_lo(),

compiler/rustc_mir/src/transform/coverage/spans.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
240240
/// to be).
241241
pub(super) fn generate_coverage_spans(
242242
mir_body: &'a mir::Body<'tcx>,
243-
fn_sig_span: Span,
243+
fn_sig_span: Span, // Ensured to be same SourceFile and SyntaxContext as `body_span`
244244
body_span: Span,
245245
basic_coverage_blocks: &'a CoverageGraph,
246246
) -> Vec<CoverageSpan> {
247247
let mut coverage_spans = CoverageSpans {
248248
mir_body,
249-
fn_sig_span: fn_sig_source_span(fn_sig_span, body_span),
249+
fn_sig_span,
250250
body_span,
251251
basic_coverage_blocks,
252252
sorted_spans_iter: None,
@@ -731,11 +731,6 @@ pub(super) fn filtered_terminator_span(
731731
}
732732
}
733733

734-
#[inline]
735-
fn fn_sig_source_span(fn_sig_span: Span, body_span: Span) -> Span {
736-
original_sp(fn_sig_span, body_span).with_ctxt(body_span.ctxt())
737-
}
738-
739734
#[inline]
740735
fn function_source_span(span: Span, body_span: Span) -> Span {
741736
let span = original_sp(span, body_span).with_ctxt(body_span.ctxt());

library/alloc/src/vec/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2810,8 +2810,7 @@ impl<T, A: Allocator> From<Box<[T], A>> for Vec<T, A> {
28102810
/// assert_eq!(Vec::from(b), vec![1, 2, 3]);
28112811
/// ```
28122812
fn from(s: Box<[T], A>) -> Self {
2813-
let len = s.len();
2814-
Self { buf: RawVec::from_box(s), len }
2813+
s.into_vec()
28152814
}
28162815
}
28172816

library/core/src/convert/num.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ impl_float_to_int!(f64 => u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);
4545
macro_rules! impl_from {
4646
($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => {
4747
#[$attr]
48-
#[doc = $doc]
4948
impl From<$Small> for $Large {
49+
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
50+
// Rustdocs on functions do not.
51+
#[doc = $doc]
5052
#[inline]
5153
fn from(small: $Small) -> Self {
5254
small as Self
@@ -383,8 +385,10 @@ use crate::num::NonZeroUsize;
383385
macro_rules! nzint_impl_from {
384386
($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => {
385387
#[$attr]
386-
#[doc = $doc]
387388
impl From<$Small> for $Large {
389+
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
390+
// Rustdocs on functions do not.
391+
#[doc = $doc]
388392
#[inline]
389393
fn from(small: $Small) -> Self {
390394
// SAFETY: input type guarantees the value is non-zero
@@ -450,10 +454,12 @@ nzint_impl_from! { NonZeroU64, NonZeroI128, #[stable(feature = "nz_int_conv", si
450454
macro_rules! nzint_impl_try_from_int {
451455
($Int: ty, $NonZeroInt: ty, #[$attr:meta], $doc: expr) => {
452456
#[$attr]
453-
#[doc = $doc]
454457
impl TryFrom<$Int> for $NonZeroInt {
455458
type Error = TryFromIntError;
456459

460+
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
461+
// Rustdocs on functions do not.
462+
#[doc = $doc]
457463
#[inline]
458464
fn try_from(value: $Int) -> Result<Self, Self::Error> {
459465
Self::new(value).ok_or(TryFromIntError(()))
@@ -489,10 +495,12 @@ nzint_impl_try_from_int! { isize, NonZeroIsize, #[stable(feature = "nzint_try_fr
489495
macro_rules! nzint_impl_try_from_nzint {
490496
($From:ty => $To:ty, $doc: expr) => {
491497
#[stable(feature = "nzint_try_from_nzint_conv", since = "1.49.0")]
492-
#[doc = $doc]
493498
impl TryFrom<$From> for $To {
494499
type Error = TryFromIntError;
495500

501+
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
502+
// Rustdocs on functions do not.
503+
#[doc = $doc]
496504
#[inline]
497505
fn try_from(value: $From) -> Result<Self, Self::Error> {
498506
TryFrom::try_from(value.get()).map(|v| {

library/core/src/iter/traits/iterator.rs

+8-23
Original file line numberDiff line numberDiff line change
@@ -1646,31 +1646,16 @@ pub trait Iterator {
16461646
/// Basic usage:
16471647
///
16481648
/// ```
1649-
/// let a = [1, 2, 3];
1650-
///
1651-
/// let iter = a.iter();
1652-
///
1653-
/// let sum: i32 = iter.take(5).fold(0, |acc, i| acc + i);
1654-
///
1655-
/// assert_eq!(sum, 6);
1656-
///
1657-
/// // if we try to use iter again, it won't work. The following line
1658-
/// // gives "error: use of moved value: `iter`
1659-
/// // assert_eq!(iter.next(), None);
1649+
/// let mut words = vec!["hello", "world", "of", "Rust"].into_iter();
16601650
///
1661-
/// // let's try that again
1662-
/// let a = [1, 2, 3];
1663-
///
1664-
/// let mut iter = a.iter();
1665-
///
1666-
/// // instead, we add in a .by_ref()
1667-
/// let sum: i32 = iter.by_ref().take(2).fold(0, |acc, i| acc + i);
1651+
/// // Take the first two words.
1652+
/// let hello_world: Vec<_> = words.by_ref().take(2).collect();
1653+
/// assert_eq!(hello_world, vec!["hello", "world"]);
16681654
///
1669-
/// assert_eq!(sum, 3);
1670-
///
1671-
/// // now this is just fine:
1672-
/// assert_eq!(iter.next(), Some(&3));
1673-
/// assert_eq!(iter.next(), None);
1655+
/// // Collect the rest of the words.
1656+
/// // We can only do this because we used `by_ref` earlier.
1657+
/// let of_rust: Vec<_> = words.collect();
1658+
/// assert_eq!(of_rust, vec!["of", "Rust"]);
16741659
/// ```
16751660
#[stable(feature = "rust1", since = "1.0.0")]
16761661
fn by_ref(&mut self) -> &mut Self

library/std/src/sync/condvar.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
mod tests;
33

44
use crate::fmt;
5-
use crate::sync::{mutex, MutexGuard, PoisonError};
5+
use crate::sync::{mutex, poison, LockResult, MutexGuard, PoisonError};
66
use crate::sys_common::condvar as sys;
7-
use crate::sys_common::poison::{self, LockResult};
87
use crate::time::{Duration, Instant};
98

109
/// A type indicating whether a timed wait on a condition variable returned

library/std/src/sync/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,15 @@ pub use self::mutex::{Mutex, MutexGuard};
166166
#[allow(deprecated)]
167167
pub use self::once::{Once, OnceState, ONCE_INIT};
168168
#[stable(feature = "rust1", since = "1.0.0")]
169-
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
169+
pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
170170
#[stable(feature = "rust1", since = "1.0.0")]
171-
pub use crate::sys_common::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
171+
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
172172

173173
pub mod mpsc;
174174

175175
mod barrier;
176176
mod condvar;
177177
mod mutex;
178178
mod once;
179+
mod poison;
179180
mod rwlock;

library/std/src/sync/mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::fmt;
66
use crate::mem;
77
use crate::ops::{Deref, DerefMut};
88
use crate::ptr;
9+
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
910
use crate::sys_common::mutex as sys;
10-
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
1111

1212
/// A mutual exclusion primitive useful for protecting shared data
1313
///

library/std/src/sys_common/poison.rs library/std/src/sync/poison.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ use crate::fmt;
33
use crate::sync::atomic::{AtomicBool, Ordering};
44
use crate::thread;
55

6-
#[allow(unused_imports)] // for intra-doc links
7-
use crate::sync::{Mutex, RwLock};
8-
96
pub struct Flag {
107
failed: AtomicBool,
118
}
@@ -80,6 +77,8 @@ pub struct Guard {
8077
/// }
8178
/// };
8279
/// ```
80+
/// [`Mutex`]: crate::sync::Mutex
81+
/// [`RwLock`]: crate::sync::RwLock
8382
#[stable(feature = "rust1", since = "1.0.0")]
8483
pub struct PoisonError<T> {
8584
guard: T,
@@ -89,9 +88,11 @@ pub struct PoisonError<T> {
8988
/// can occur while trying to acquire a lock, from the [`try_lock`] method on a
9089
/// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`].
9190
///
92-
/// [`try_lock`]: Mutex::try_lock
93-
/// [`try_read`]: RwLock::try_read
94-
/// [`try_write`]: RwLock::try_write
91+
/// [`try_lock`]: crate::sync::Mutex::try_lock
92+
/// [`try_read`]: crate::sync::RwLock::try_read
93+
/// [`try_write`]: crate::sync::RwLock::try_write
94+
/// [`Mutex`]: crate::sync::Mutex
95+
/// [`RwLock`]: crate::sync::RwLock
9596
#[stable(feature = "rust1", since = "1.0.0")]
9697
pub enum TryLockError<T> {
9798
/// The lock could not be acquired because another thread failed while holding
@@ -149,7 +150,8 @@ impl<T> Error for PoisonError<T> {
149150
impl<T> PoisonError<T> {
150151
/// Creates a `PoisonError`.
151152
///
152-
/// This is generally created by methods like [`Mutex::lock`] or [`RwLock::read`].
153+
/// This is generally created by methods like [`Mutex::lock`](crate::sync::Mutex::lock)
154+
/// or [`RwLock::read`](crate::sync::RwLock::read).
153155
#[stable(feature = "sync_poison", since = "1.2.0")]
154156
pub fn new(guard: T) -> PoisonError<T> {
155157
PoisonError { guard }

library/std/src/sync/rwlock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::fmt;
66
use crate::mem;
77
use crate::ops::{Deref, DerefMut};
88
use crate::ptr;
9-
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
9+
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
1010
use crate::sys_common::rwlock as sys;
1111

1212
/// A reader-writer lock

library/std/src/sys_common/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub mod mutex;
5959
// when generating documentation.
6060
#[cfg(any(doc, not(windows)))]
6161
pub mod os_str_bytes;
62-
pub mod poison;
6362
pub mod process;
6463
pub mod remutex;
6564
pub mod rwlock;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ target | std | host | notes
179179
`i386-apple-ios` | ✓ | | 32-bit x86 iOS
180180
`i686-apple-darwin` | ✓ | ✓ | 32-bit macOS (10.7+, Lion+)
181181
`i686-pc-windows-msvc` | ✓ | | 32-bit Windows XP support
182-
`i686-unknown-uefi` | ? | | 32-bit UEFI
182+
`i686-unknown-uefi` | * | | 32-bit UEFI
183183
`i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku
184184
`i686-unknown-netbsd` | ✓ | ✓ | NetBSD/i386 with SSE2
185185
`i686-unknown-openbsd` | ✓ | ✓ | 32-bit OpenBSD
@@ -228,7 +228,7 @@ target | std | host | notes
228228
`x86_64-unknown-none-hermitkernel` | ? | | HermitCore kernel
229229
`x86_64-unknown-l4re-uclibc` | ? | |
230230
`x86_64-unknown-openbsd` | ✓ | ✓ | 64-bit OpenBSD
231-
`x86_64-unknown-uefi` | ? | |
231+
`x86_64-unknown-uefi` | * | | 64-bit UEFI
232232
`x86_64-uwp-windows-gnu` | ✓ | |
233233
`x86_64-uwp-windows-msvc` | ✓ | |
234234
`x86_64-wrs-vxworks` | ? | |

src/librustdoc/html/render/print_item.rs

+2
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
963963

964964
use crate::clean::Variant;
965965
if let clean::VariantItem(Variant::Struct(ref s)) = *variant.kind {
966+
toggle_open(w, "fields");
966967
let variant_id = cx.derive_id(format!(
967968
"{}.{}.fields",
968969
ItemType::Variant,
@@ -996,6 +997,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
996997
}
997998
}
998999
w.write_str("</div></div>");
1000+
toggle_close(w);
9991001
}
10001002
render_stability_since(w, variant, it, cx.tcx());
10011003
}

0 commit comments

Comments
 (0)