Skip to content

Commit

Permalink
Auto merge of rust-lang#84490 - JohnTitor:rollup-wrdj4ko, r=JohnTitor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 23, 2021
2 parents 481ba16 + 62db03c commit bb491ed
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 92 deletions.
70 changes: 44 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,71 @@
# created during manual debugging and many people like to clean up instead of
# having git ignore such leftovers. You can use `.git/info/exclude` to
# configure your local ignore list.
# FIXME: This needs cleanup.
*~

## File system
.DS_Store
desktop.ini

## Editor
*.swp
*.swo
.#*
.DS_Store
Session.vim
.cproject
.hg/
.hgignore
.idea
*.iml
__pycache__/
*.py[cod]
*$py.class
.vscode
.project
.favorites.json
.settings/

## Tool
.valgrindrc
.vscode
.favorites.json
/Makefile
/build/
.cargo
# Included because it is part of the test case
!/src/test/run-make/thumb-none-qemu/example/.cargo

## Configuration
/config.toml
/dist/
/Makefile
config.mk
config.stamp
no_llvm_build

## Build
/dl/
/doc/
/inst/
/llvm/
/mingw-build/
/src/tools/x/target
# Created by default with `src/ci/docker/run.sh`:
/obj/
/build/
/dist/
/unicode-downloads
/target
# Generated by compiletest for incremental:
/src/tools/x/target
# Generated by compiletest for incremental
/tmp/
# Created by default with `src/ci/docker/run.sh`
/obj/

## Temporary files
*~
\#*
\#*\#
.#*

## Tags
tags
tags.*
TAGS
TAGS.*
\#*
\#*\#
config.mk
config.stamp
Session.vim
.cargo
!/src/test/run-make/thumb-none-qemu/example/.cargo
no_llvm_build

## Python
__pycache__/
*.py[cod]
*$py.class

## Node
**node_modules
**package-lock.json

# Before adding new lines, see the comment at the top.
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,7 @@ impl PrimTy {

/// Like [`PrimTy::name`], but returns a &str instead of a symbol.
///
/// Used by rustdoc.
/// Used by clippy.
pub fn name_str(self) -> &'static str {
match self {
PrimTy::Int(i) => i.name_str(),
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_mir/src/transform/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
let body_span = hir_body.value.span;
let source_file = source_map.lookup_source_file(body_span.lo());
let fn_sig_span = match some_fn_sig.filter(|fn_sig| {
Lrc::ptr_eq(&source_file, &source_map.lookup_source_file(fn_sig.span.hi()))
fn_sig.span.ctxt() == body_span.ctxt()
&& Lrc::ptr_eq(&source_file, &source_map.lookup_source_file(fn_sig.span.hi()))
}) {
Some(fn_sig) => fn_sig.span.with_hi(body_span.lo()),
None => body_span.shrink_to_lo(),
Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_mir/src/transform/coverage/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
/// to be).
pub(super) fn generate_coverage_spans(
mir_body: &'a mir::Body<'tcx>,
fn_sig_span: Span,
fn_sig_span: Span, // Ensured to be same SourceFile and SyntaxContext as `body_span`
body_span: Span,
basic_coverage_blocks: &'a CoverageGraph,
) -> Vec<CoverageSpan> {
let mut coverage_spans = CoverageSpans {
mir_body,
fn_sig_span: fn_sig_source_span(fn_sig_span, body_span),
fn_sig_span,
body_span,
basic_coverage_blocks,
sorted_spans_iter: None,
Expand Down Expand Up @@ -731,11 +731,6 @@ pub(super) fn filtered_terminator_span(
}
}

#[inline]
fn fn_sig_source_span(fn_sig_span: Span, body_span: Span) -> Span {
original_sp(fn_sig_span, body_span).with_ctxt(body_span.ctxt())
}

#[inline]
fn function_source_span(span: Span, body_span: Span) -> Span {
let span = original_sp(span, body_span).with_ctxt(body_span.ctxt());
Expand Down
3 changes: 1 addition & 2 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2810,8 +2810,7 @@ impl<T, A: Allocator> From<Box<[T], A>> for Vec<T, A> {
/// assert_eq!(Vec::from(b), vec![1, 2, 3]);
/// ```
fn from(s: Box<[T], A>) -> Self {
let len = s.len();
Self { buf: RawVec::from_box(s), len }
s.into_vec()
}
}

Expand Down
16 changes: 12 additions & 4 deletions library/core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ impl_float_to_int!(f64 => u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);
macro_rules! impl_from {
($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => {
#[$attr]
#[doc = $doc]
impl From<$Small> for $Large {
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
// Rustdocs on functions do not.
#[doc = $doc]
#[inline]
fn from(small: $Small) -> Self {
small as Self
Expand Down Expand Up @@ -383,8 +385,10 @@ use crate::num::NonZeroUsize;
macro_rules! nzint_impl_from {
($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => {
#[$attr]
#[doc = $doc]
impl From<$Small> for $Large {
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
// Rustdocs on functions do not.
#[doc = $doc]
#[inline]
fn from(small: $Small) -> Self {
// SAFETY: input type guarantees the value is non-zero
Expand Down Expand Up @@ -450,10 +454,12 @@ nzint_impl_from! { NonZeroU64, NonZeroI128, #[stable(feature = "nz_int_conv", si
macro_rules! nzint_impl_try_from_int {
($Int: ty, $NonZeroInt: ty, #[$attr:meta], $doc: expr) => {
#[$attr]
#[doc = $doc]
impl TryFrom<$Int> for $NonZeroInt {
type Error = TryFromIntError;

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

// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
// Rustdocs on functions do not.
#[doc = $doc]
#[inline]
fn try_from(value: $From) -> Result<Self, Self::Error> {
TryFrom::try_from(value.get()).map(|v| {
Expand Down
31 changes: 8 additions & 23 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,31 +1646,16 @@ pub trait Iterator {
/// Basic usage:
///
/// ```
/// let a = [1, 2, 3];
///
/// let iter = a.iter();
///
/// let sum: i32 = iter.take(5).fold(0, |acc, i| acc + i);
///
/// assert_eq!(sum, 6);
///
/// // if we try to use iter again, it won't work. The following line
/// // gives "error: use of moved value: `iter`
/// // assert_eq!(iter.next(), None);
/// let mut words = vec!["hello", "world", "of", "Rust"].into_iter();
///
/// // let's try that again
/// let a = [1, 2, 3];
///
/// let mut iter = a.iter();
///
/// // instead, we add in a .by_ref()
/// let sum: i32 = iter.by_ref().take(2).fold(0, |acc, i| acc + i);
/// // Take the first two words.
/// let hello_world: Vec<_> = words.by_ref().take(2).collect();
/// assert_eq!(hello_world, vec!["hello", "world"]);
///
/// assert_eq!(sum, 3);
///
/// // now this is just fine:
/// assert_eq!(iter.next(), Some(&3));
/// assert_eq!(iter.next(), None);
/// // Collect the rest of the words.
/// // We can only do this because we used `by_ref` earlier.
/// let of_rust: Vec<_> = words.collect();
/// assert_eq!(of_rust, vec!["of", "Rust"]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn by_ref(&mut self) -> &mut Self
Expand Down
3 changes: 1 addition & 2 deletions library/std/src/sync/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
mod tests;

use crate::fmt;
use crate::sync::{mutex, MutexGuard, PoisonError};
use crate::sync::{mutex, poison, LockResult, MutexGuard, PoisonError};
use crate::sys_common::condvar as sys;
use crate::sys_common::poison::{self, LockResult};
use crate::time::{Duration, Instant};

/// A type indicating whether a timed wait on a condition variable returned
Expand Down
5 changes: 3 additions & 2 deletions library/std/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,15 @@ pub use self::mutex::{Mutex, MutexGuard};
#[allow(deprecated)]
pub use self::once::{Once, OnceState, ONCE_INIT};
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::sys_common::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};

pub mod mpsc;

mod barrier;
mod condvar;
mod mutex;
mod once;
mod poison;
mod rwlock;
2 changes: 1 addition & 1 deletion library/std/src/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::fmt;
use crate::mem;
use crate::ops::{Deref, DerefMut};
use crate::ptr;
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
use crate::sys_common::mutex as sys;
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};

/// A mutual exclusion primitive useful for protecting shared data
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use crate::fmt;
use crate::sync::atomic::{AtomicBool, Ordering};
use crate::thread;

#[allow(unused_imports)] // for intra-doc links
use crate::sync::{Mutex, RwLock};

pub struct Flag {
failed: AtomicBool,
}
Expand Down Expand Up @@ -80,6 +77,8 @@ pub struct Guard {
/// }
/// };
/// ```
/// [`Mutex`]: crate::sync::Mutex
/// [`RwLock`]: crate::sync::RwLock
#[stable(feature = "rust1", since = "1.0.0")]
pub struct PoisonError<T> {
guard: T,
Expand All @@ -89,9 +88,11 @@ pub struct PoisonError<T> {
/// can occur while trying to acquire a lock, from the [`try_lock`] method on a
/// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`].
///
/// [`try_lock`]: Mutex::try_lock
/// [`try_read`]: RwLock::try_read
/// [`try_write`]: RwLock::try_write
/// [`try_lock`]: crate::sync::Mutex::try_lock
/// [`try_read`]: crate::sync::RwLock::try_read
/// [`try_write`]: crate::sync::RwLock::try_write
/// [`Mutex`]: crate::sync::Mutex
/// [`RwLock`]: crate::sync::RwLock
#[stable(feature = "rust1", since = "1.0.0")]
pub enum TryLockError<T> {
/// The lock could not be acquired because another thread failed while holding
Expand Down Expand Up @@ -149,7 +150,8 @@ impl<T> Error for PoisonError<T> {
impl<T> PoisonError<T> {
/// Creates a `PoisonError`.
///
/// This is generally created by methods like [`Mutex::lock`] or [`RwLock::read`].
/// This is generally created by methods like [`Mutex::lock`](crate::sync::Mutex::lock)
/// or [`RwLock::read`](crate::sync::RwLock::read).
#[stable(feature = "sync_poison", since = "1.2.0")]
pub fn new(guard: T) -> PoisonError<T> {
PoisonError { guard }
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::fmt;
use crate::mem;
use crate::ops::{Deref, DerefMut};
use crate::ptr;
use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
use crate::sys_common::rwlock as sys;

/// A reader-writer lock
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub mod mutex;
// when generating documentation.
#[cfg(any(doc, not(windows)))]
pub mod os_str_bytes;
pub mod poison;
pub mod process;
pub mod remutex;
pub mod rwlock;
Expand Down
4 changes: 2 additions & 2 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ target | std | host | notes
`i386-apple-ios` | ✓ | | 32-bit x86 iOS
`i686-apple-darwin` | ✓ | ✓ | 32-bit macOS (10.7+, Lion+)
`i686-pc-windows-msvc` | ✓ | | 32-bit Windows XP support
`i686-unknown-uefi` | ? | | 32-bit UEFI
`i686-unknown-uefi` | * | | 32-bit UEFI
`i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku
`i686-unknown-netbsd` | ✓ | ✓ | NetBSD/i386 with SSE2
`i686-unknown-openbsd` | ✓ | ✓ | 32-bit OpenBSD
Expand Down Expand Up @@ -228,7 +228,7 @@ target | std | host | notes
`x86_64-unknown-none-hermitkernel` | ? | | HermitCore kernel
`x86_64-unknown-l4re-uclibc` | ? | |
`x86_64-unknown-openbsd` | ✓ | ✓ | 64-bit OpenBSD
`x86_64-unknown-uefi` | ? | |
`x86_64-unknown-uefi` | * | | 64-bit UEFI
`x86_64-uwp-windows-gnu` | ✓ | |
`x86_64-uwp-windows-msvc` | ✓ | |
`x86_64-wrs-vxworks` | ? | |
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum

use crate::clean::Variant;
if let clean::VariantItem(Variant::Struct(ref s)) = *variant.kind {
toggle_open(w, "fields");
let variant_id = cx.derive_id(format!(
"{}.{}.fields",
ItemType::Variant,
Expand Down Expand Up @@ -996,6 +997,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
}
}
w.write_str("</div></div>");
toggle_close(w);
}
render_stability_since(w, variant, it, cx.tcx());
}
Expand Down
Loading

0 comments on commit bb491ed

Please sign in to comment.