提交 bb491ed2 编写于 作者: B bors

Auto merge of #84490 - JohnTitor:rollup-wrdj4ko, r=JohnTitor

Rollup of 11 pull requests

Successful merges:

 - #80805 (Improve `Iterator::by_ref` example)
 - #84248 (Remove duplicated fn(Box<[T]>) -> Vec<T>)
 - #84321 (rustdoc: Convert sub-variant toggle to HTML)
 - #84359 ( rust-analyzer)
 - #84374 (Clean up .gitignore)
 - #84387 (Move `sys_common::poison` to `sync::poison`)
 - #84430 (doc/platform-support: clarify UEFI support)
 - #84433 (Prevent control, shift and alt keys to make search input lose focus)
 - #84444 (doc: Get rid of "[+] show undocumented items" toggle on numeric From impls)
 - #84456 (Fix ICE if original_span(fn_sig) returns a span not in body sourcefile)
 - #84469 (Update comment on `PrimTy::name_str`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
......@@ -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.
......@@ -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(),
......
......@@ -111,7 +111,8 @@ fn new(pass_name: &'a str, tcx: TyCtxt<'tcx>, mir_body: &'a mut mir::Body<'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(),
......
......@@ -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,
......@@ -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());
......
......@@ -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()
}
}
......
......@@ -45,8 +45,10 @@ unsafe fn to_int_unchecked(self) -> $Int {
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
......@@ -383,8 +385,10 @@ mod ptr_try_from_impls {
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
......@@ -450,10 +454,12 @@ fn from(small: $Small) -> Self {
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(()))
......@@ -489,10 +495,12 @@ fn try_from(value: $Int) -> Result<Self, Self::Error> {
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| {
......
......@@ -1646,31 +1646,16 @@ fn inspect<F>(self, f: F) -> Inspect<Self, F>
/// 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
......
......@@ -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
......
......@@ -166,9 +166,9 @@
#[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;
......@@ -176,4 +176,5 @@
mod condvar;
mod mutex;
mod once;
mod poison;
mod rwlock;
......@@ -6,8 +6,8 @@
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
///
......
......@@ -3,9 +3,6 @@
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,
}
......@@ -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,
......@@ -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
......@@ -149,7 +150,8 @@ fn description(&self) -> &str {
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 }
......
......@@ -6,7 +6,7 @@
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
......
......@@ -59,7 +59,6 @@
// 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;
......
......@@ -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
......@@ -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` | ? | |
......
......@@ -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,
......@@ -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());
}
......
......@@ -455,6 +455,15 @@ function hideThemeButtonState() {
handleHashes(ev);
}
function openParentDetails(elem) {
while (elem) {
if (elem.tagName === "DETAILS") {
elem.open = true;
}
elem = elem.parentNode;
}
}
function expandSection(id) {
var elem = document.getElementById(id);
if (elem && isHidden(elem)) {
......@@ -469,6 +478,8 @@ function hideThemeButtonState() {
// The element is not visible, we need to make it appear!
collapseDocs(collapses[0], "show");
}
// Open all ancestor <details> to make this element visible.
openParentDetails(h3.parentNode);
}
}
}
......@@ -1009,7 +1020,7 @@ function hideThemeButtonState() {
if (hasClass(relatedDoc, "item-info")) {
relatedDoc = relatedDoc.nextElementSibling;
}
if (hasClass(relatedDoc, "docblock") || hasClass(relatedDoc, "sub-variant")) {
if (hasClass(relatedDoc, "docblock")) {
if (mode === "toggle") {
if (hasClass(relatedDoc, "hidden-by-usual-hider")) {
action = "show";
......@@ -1318,8 +1329,6 @@ function hideThemeButtonState() {
if (hasClass(e, "type-decl")) {
// We do something special for these
return;
} else if (hasClass(e, "sub-variant")) {
otherMessage = "&nbsp;Show&nbsp;fields";
} else if (hasClass(e, "non-exhaustive")) {
otherMessage = "&nbsp;This&nbsp;";
if (hasClass(e, "non-exhaustive-struct")) {
......@@ -1351,7 +1360,6 @@ function hideThemeButtonState() {
}
onEachLazy(document.getElementsByClassName("docblock"), buildToggleWrapper);
onEachLazy(document.getElementsByClassName("sub-variant"), buildToggleWrapper);
autoCollapse(getSettingValue("collapse") === "true");
......
......@@ -1046,10 +1046,11 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
}
.sub-variant, .sub-variant > h3 {
margin-top: 1px !important;
margin-top: 0px !important;
padding-top: 1px;
}
#main > .sub-variant > h3 {
#main > details > .sub-variant > h3 {
font-size: 15px;
margin-left: 25px;
margin-bottom: 5px;
......
......@@ -935,6 +935,9 @@ window.initSearch = function(rawSearchIndex) {
});
current += 1;
});
var SHIFT = 16;
var CTRL = 17;
var ALT = 18;
var currentTab = searchState.currentTab;
if (e.which === 38) { // up
......@@ -967,10 +970,10 @@ window.initSearch = function(rawSearchIndex) {
e.preventDefault();
} else if (e.which === 13) { // return
if (actives[currentTab].length) {
document.location.href =
actives[currentTab][0].getElementsByTagName("a")[0].href;
var elem = actives[currentTab][0].getElementsByTagName("a")[0];
document.location.href = elem.href;
}
} else if (e.which === 16) { // shift
} else if ([SHIFT, CTRL, ALT].indexOf(e.which) !== -1) {
// Does nothing, it's just to avoid losing "focus" on the highlighted element.
} else if (actives[currentTab].length > 0) {
removeClass(actives[currentTab][0], "highlighted");
......
......@@ -29,7 +29,9 @@ pub fn foo() {}
impl Foo {
#[must_use]
pub fn must_use(&self) -> bool { true }
pub fn must_use(&self) -> bool {
true
}
}
/// Just a normal enum.
......@@ -85,3 +87,7 @@ pub trait AnotherOne {
/// let x = 12;
/// ```
pub fn check_list_code_block() {}
pub enum AnEnum {
WithVariants { and: usize, sub: usize, variants: usize },
}
......@@ -62,7 +62,8 @@ pub struct PrivStruct {
}
// @has 'item_hide_threshold/enum.Enum.html'
// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 0
// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1
// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show fields'
pub enum Enum {
A, B, C,
D {
......
Subproject commit 7be06139b632ee615fc18af04dd67947e2c794b2
Subproject commit 7570212a544b8e973a7d57be3657aae6465028a7
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册