Auto merge of #60986 - Centril:rollup-nhpgrfb, r=Centril

Rollup of 11 pull requests

Successful merges:

 - #60383 (Fix position source code files toggle)
 - #60453 (Fall back to `/dev/urandom` on `EPERM` for `getrandom`)
 - #60487 (Fix search sidebar width when no crate select is present)
 - #60511 (Fix intra-doc link resolution failure on re-exporting libstd)
 - #60823 (Fix incremental compilation of cdylib emitting spurious unused_attributes lint)
 - #60915 (stable hashing: Remove unused field and add documentation.)
 - #60942 (Misc changes to rustc_metadata)
 - #60952 (Document BinaryHeap time complexity)
 - #60959 (rustc: Improve type size assertions)
 - #60972 (remove confusing remarks about mixed volatile and non-volatile accesses)
 - #60983 (Set -funwind-tables and -fno-exceptions unconditionally for LLVM's libunwind)

Failed merges:

r? @ghost
This commit is contained in:
bors 2019-05-20 21:38:19 +00:00
commit 09189591c4
39 changed files with 441 additions and 287 deletions

View File

@ -37,6 +37,8 @@ extern "Rust" {
///
/// Note: while this type is unstable, the functionality it provides can be
/// accessed through the [free functions in `alloc`](index.html#functions).
///
/// [`Alloc`]: trait.Alloc.html
#[unstable(feature = "allocator_api", issue = "32838")]
#[derive(Copy, Clone, Default, Debug)]
pub struct Global;
@ -54,6 +56,10 @@ pub struct Global;
///
/// See [`GlobalAlloc::alloc`].
///
/// [`Global`]: struct.Global.html
/// [`Alloc`]: trait.Alloc.html
/// [`GlobalAlloc::alloc`]: trait.GlobalAlloc.html#tymethod.alloc
///
/// # Examples
///
/// ```
@ -87,6 +93,10 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 {
/// # Safety
///
/// See [`GlobalAlloc::dealloc`].
///
/// [`Global`]: struct.Global.html
/// [`Alloc`]: trait.Alloc.html
/// [`GlobalAlloc::dealloc`]: trait.GlobalAlloc.html#tymethod.dealloc
#[stable(feature = "global_alloc", since = "1.28.0")]
#[inline]
pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {
@ -105,6 +115,10 @@ pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {
/// # Safety
///
/// See [`GlobalAlloc::realloc`].
///
/// [`Global`]: struct.Global.html
/// [`Alloc`]: trait.Alloc.html
/// [`GlobalAlloc::realloc`]: trait.GlobalAlloc.html#method.realloc
#[stable(feature = "global_alloc", since = "1.28.0")]
#[inline]
pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
@ -124,6 +138,10 @@ pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8
///
/// See [`GlobalAlloc::alloc_zeroed`].
///
/// [`Global`]: struct.Global.html
/// [`Alloc`]: trait.Alloc.html
/// [`GlobalAlloc::alloc_zeroed`]: trait.GlobalAlloc.html#method.alloc_zeroed
///
/// # Examples
///
/// ```

View File

@ -231,6 +231,20 @@ use super::SpecExtend;
/// assert_eq!(heap.pop(), Some(Reverse(5)));
/// assert_eq!(heap.pop(), None);
/// ```
///
/// # Time complexity
///
/// | [push] | [pop] | [peek]/[peek\_mut] |
/// |--------|----------|--------------------|
/// | O(1)~ | O(log n) | O(1) |
///
/// The value for `push` is an expected cost; the method documentation gives a
/// more detailed analysis.
///
/// [push]: #method.push
/// [pop]: #method.pop
/// [peek]: #method.peek
/// [peek\_mut]: #method.peek_mut
#[stable(feature = "rust1", since = "1.0.0")]
pub struct BinaryHeap<T> {
data: Vec<T>,
@ -384,6 +398,10 @@ impl<T: Ord> BinaryHeap<T> {
/// }
/// assert_eq!(heap.peek(), Some(&2));
/// ```
///
/// # Time complexity
///
/// Cost is O(1) in the worst case.
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T>> {
if self.is_empty() {
@ -411,6 +429,11 @@ impl<T: Ord> BinaryHeap<T> {
/// assert_eq!(heap.pop(), Some(1));
/// assert_eq!(heap.pop(), None);
/// ```
///
/// # Time complexity
///
/// The worst case cost of `pop` on a heap containing *n* elements is O(log
/// n).
#[stable(feature = "rust1", since = "1.0.0")]
pub fn pop(&mut self) -> Option<T> {
self.data.pop().map(|mut item| {
@ -438,6 +461,22 @@ impl<T: Ord> BinaryHeap<T> {
/// assert_eq!(heap.len(), 3);
/// assert_eq!(heap.peek(), Some(&5));
/// ```
///
/// # Time complexity
///
/// The expected cost of `push`, averaged over every possible ordering of
/// the elements being pushed, and over a sufficiently large number of
/// pushes, is O(1). This is the most meaningful cost metric when pushing
/// elements that are *not* already in any sorted pattern.
///
/// The time complexity degrades if elements are pushed in predominantly
/// ascending order. In the worst case, elements are pushed in ascending
/// sorted order and the amortized cost per push is O(log n) against a heap
/// containing *n* elements.
///
/// The worst case cost of a *single* call to `push` is O(n). The worst case
/// occurs when capacity is exhausted and needs a resize. The resize cost
/// has been amortized in the previous figures.
#[stable(feature = "rust1", since = "1.0.0")]
pub fn push(&mut self, item: T) {
let old_len = self.len();
@ -650,6 +689,10 @@ impl<T> BinaryHeap<T> {
/// assert_eq!(heap.peek(), Some(&5));
///
/// ```
///
/// # Time complexity
///
/// Cost is O(1) in the worst case.
#[stable(feature = "rust1", since = "1.0.0")]
pub fn peek(&self) -> Option<&T> {
self.data.get(0)

View File

@ -810,9 +810,6 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
/// to not be elided or reordered by the compiler across other volatile
/// operations.
///
/// Memory accessed with `read_volatile` or [`write_volatile`] should not be
/// accessed with non-volatile operations.
///
/// [`write_volatile`]: ./fn.write_volatile.html
///
/// # Notes
@ -881,9 +878,6 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
/// to not be elided or reordered by the compiler across other volatile
/// operations.
///
/// Memory accessed with [`read_volatile`] or `write_volatile` should not be
/// accessed with non-volatile operations.
///
/// `write_volatile` does not drop the contents of `dst`. This is safe, but it
/// could leak allocations or resources, so care should be taken not to overwrite
/// an object that should be dropped.

View File

@ -10,6 +10,8 @@ use crate::marker::{PhantomData, Unpin};
///
/// It consists of a data pointer and a [virtual function pointer table (vtable)][vtable] that
/// customizes the behavior of the `RawWaker`.
///
/// [`Waker`]: struct.Waker.html
#[derive(PartialEq, Debug)]
#[stable(feature = "futures_api", since = "1.36.0")]
pub struct RawWaker {
@ -55,6 +57,8 @@ impl RawWaker {
/// pointer of a properly constructed [`RawWaker`] object from inside the
/// [`RawWaker`] implementation. Calling one of the contained functions using
/// any other `data` pointer will cause undefined behavior.
///
/// [`RawWaker`]: struct.RawWaker.html
#[stable(feature = "futures_api", since = "1.36.0")]
#[derive(PartialEq, Copy, Clone, Debug)]
pub struct RawWakerVTable {
@ -65,6 +69,9 @@ pub struct RawWakerVTable {
/// required for this additional instance of a [`RawWaker`] and associated
/// task. Calling `wake` on the resulting [`RawWaker`] should result in a wakeup
/// of the same task that would have been awoken by the original [`RawWaker`].
///
/// [`Waker`]: struct.Waker.html
/// [`RawWaker`]: struct.RawWaker.html
clone: unsafe fn(*const ()) -> RawWaker,
/// This function will be called when `wake` is called on the [`Waker`].
@ -73,6 +80,9 @@ pub struct RawWakerVTable {
/// The implementation of this function must make sure to release any
/// resources that are associated with this instance of a [`RawWaker`] and
/// associated task.
///
/// [`Waker`]: struct.Waker.html
/// [`RawWaker`]: struct.RawWaker.html
wake: unsafe fn(*const ()),
/// This function will be called when `wake_by_ref` is called on the [`Waker`].
@ -80,6 +90,9 @@ pub struct RawWakerVTable {
///
/// This function is similar to `wake`, but must not consume the provided data
/// pointer.
///
/// [`Waker`]: struct.Waker.html
/// [`RawWaker`]: struct.RawWaker.html
wake_by_ref: unsafe fn(*const ()),
/// This function gets called when a [`RawWaker`] gets dropped.
@ -87,6 +100,8 @@ pub struct RawWakerVTable {
/// The implementation of this function must make sure to release any
/// resources that are associated with this instance of a [`RawWaker`] and
/// associated task.
///
/// [`RawWaker`]: struct.RawWaker.html
drop: unsafe fn(*const ()),
}
@ -128,6 +143,9 @@ impl RawWakerVTable {
/// The implementation of this function must make sure to release any
/// resources that are associated with this instance of a [`RawWaker`] and
/// associated task.
///
/// [`Waker`]: struct.Waker.html
/// [`RawWaker`]: struct.RawWaker.html
#[rustc_promotable]
#[cfg_attr(stage0, unstable(feature = "futures_api_const_fn_ptr", issue = "50547"))]
#[cfg_attr(not(stage0), stable(feature = "futures_api", since = "1.36.0"))]
@ -201,6 +219,8 @@ impl fmt::Debug for Context<'_> {
/// executor-specific wakeup behavior.
///
/// Implements [`Clone`], [`Send`], and [`Sync`].
///
/// [`RawWaker`]: struct.RawWaker.html
#[repr(transparent)]
#[stable(feature = "futures_api", since = "1.36.0")]
pub struct Waker {
@ -266,6 +286,9 @@ impl Waker {
/// The behavior of the returned `Waker` is undefined if the contract defined
/// in [`RawWaker`]'s and [`RawWakerVTable`]'s documentation is not upheld.
/// Therefore this method is unsafe.
///
/// [`RawWaker`]: struct.RawWaker.html
/// [`RawWakerVTable`]: struct.RawWakerVTable.html
#[inline]
#[stable(feature = "futures_api", since = "1.36.0")]
pub unsafe fn from_raw(waker: RawWaker) -> Waker {

View File

@ -1356,7 +1356,7 @@ pub struct Expr {
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_EXPR: std::mem::size_of::<Expr>() == 72);
static_assert_size!(Expr, 72);
impl Expr {
pub fn precedence(&self) -> ExprPrecedence {

View File

@ -158,7 +158,7 @@ newtype_index! {
impl_stable_hash_for!(struct crate::middle::region::FirstStatementIndex { private });
// compilation error if size of `ScopeData` is not the same as a `u32`
static_assert!(ASSERT_SCOPE_DATA: mem::size_of::<ScopeData>() == 4);
static_assert_size!(ScopeData, 4);
impl Scope {
/// Returns a item-local ID associated with this scope.

View File

@ -78,7 +78,7 @@ pub struct Pointer<Tag=(),Id=AllocId> {
pub tag: Tag,
}
static_assert!(POINTER_SIZE: ::std::mem::size_of::<Pointer>() == 16);
static_assert_size!(Pointer, 16);
/// Produces a `Pointer` which points to the beginning of the Allocation
impl From<AllocId> for Pointer {

View File

@ -54,7 +54,7 @@ pub enum ConstValue<'tcx> {
}
#[cfg(target_arch = "x86_64")]
static_assert!(CONST_SIZE: ::std::mem::size_of::<ConstValue<'static>>() == 40);
static_assert_size!(ConstValue<'_>, 40);
impl<'tcx> ConstValue<'tcx> {
#[inline]
@ -111,7 +111,7 @@ pub enum Scalar<Tag=(), Id=AllocId> {
}
#[cfg(target_arch = "x86_64")]
static_assert!(SCALAR_SIZE: ::std::mem::size_of::<Scalar>() == 24);
static_assert_size!(Scalar, 24);
impl<Tag> fmt::Display for Scalar<Tag> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View File

@ -1738,7 +1738,7 @@ pub struct Statement<'tcx> {
// `Statement` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_STATEMENT: mem::size_of::<Statement<'_>>() == 56);
static_assert_size!(Statement<'_>, 56);
impl<'tcx> Statement<'tcx> {
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
@ -1997,10 +1997,9 @@ pub type PlaceProjection<'tcx> = Projection<Place<'tcx>, Local, Ty<'tcx>>;
/// and the index is a local.
pub type PlaceElem<'tcx> = ProjectionElem<Local, Ty<'tcx>>;
// at least on 64 bit systems, `PlaceElem` should not be larger than two pointers
static_assert!(PROJECTION_ELEM_IS_2_PTRS_LARGE:
mem::size_of::<PlaceElem<'_>>() <= 16
);
// At least on 64 bit systems, `PlaceElem` should not be larger than two pointers.
#[cfg(target_arch = "x86_64")]
static_assert_size!(PlaceElem<'_>, 16);
/// Alias for projections as they appear in `UserTypeProjection`, where we
/// need neither the `V` parameter for `Index` nor the `T` for `Field`.

View File

@ -17,9 +17,9 @@ pub struct PlaceTy<'tcx> {
pub variant_index: Option<VariantIdx>,
}
static_assert!(PLACE_TY_IS_3_PTRS_LARGE:
mem::size_of::<PlaceTy<'_>>() <= 24
);
// At least on 64 bit systems, `PlaceTy` should not be larger than two or three pointers.
#[cfg(target_arch = "x86_64")]
static_assert_size!(PlaceTy<'_>, 16);
impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {

View File

@ -510,7 +510,7 @@ pub struct TyS<'tcx> {
// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_TY_S: ::std::mem::size_of::<TyS<'_>>() == 32);
static_assert_size!(TyS<'_>, 32);
impl<'tcx> Ord for TyS<'tcx> {
fn cmp(&self, other: &TyS<'tcx>) -> Ordering {

View File

@ -211,7 +211,7 @@ pub enum TyKind<'tcx> {
// `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_TY_KIND: ::std::mem::size_of::<TyKind<'_>>() == 24);
static_assert_size!(TyKind<'_>, 24);
/// A closure can be modeled as a struct that looks like:
///
@ -2207,7 +2207,7 @@ pub struct Const<'tcx> {
}
#[cfg(target_arch = "x86_64")]
static_assert!(CONST_SIZE: ::std::mem::size_of::<Const<'static>>() == 48);
static_assert_size!(Const<'_>, 48);
impl<'tcx> Const<'tcx> {
#[inline]

View File

@ -10,3 +10,12 @@ macro_rules! static_assert {
static $name: () = [()][!($test: bool) as usize];
}
}
/// Type size assertion. The first argument is a type and the second argument is its expected size.
#[macro_export]
#[allow_internal_unstable(underscore_const_names)]
macro_rules! static_assert_size {
($ty:ty, $size:expr) => {
const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()];
}
}

View File

@ -15,7 +15,6 @@ use crate::bit_set;
/// extended to 64 bits if needed.
pub struct StableHasher<W> {
state: SipHasher128,
bytes_hashed: u64,
width: PhantomData<W>,
}
@ -33,7 +32,6 @@ impl<W: StableHasherResult> StableHasher<W> {
pub fn new() -> Self {
StableHasher {
state: SipHasher128::new_with_keys(0, 0),
bytes_hashed: 0,
width: PhantomData,
}
}
@ -61,11 +59,6 @@ impl<W> StableHasher<W> {
pub fn finalize(self) -> (u64, u64) {
self.state.finish128()
}
#[inline]
pub fn bytes_hashed(&self) -> u64 {
self.bytes_hashed
}
}
impl<W> Hasher for StableHasher<W> {
@ -76,37 +69,31 @@ impl<W> Hasher for StableHasher<W> {
#[inline]
fn write(&mut self, bytes: &[u8]) {
self.state.write(bytes);
self.bytes_hashed += bytes.len() as u64;
}
#[inline]
fn write_u8(&mut self, i: u8) {
self.state.write_u8(i);
self.bytes_hashed += 1;
}
#[inline]
fn write_u16(&mut self, i: u16) {
self.state.write_u16(i.to_le());
self.bytes_hashed += 2;
}
#[inline]
fn write_u32(&mut self, i: u32) {
self.state.write_u32(i.to_le());
self.bytes_hashed += 4;
}
#[inline]
fn write_u64(&mut self, i: u64) {
self.state.write_u64(i.to_le());
self.bytes_hashed += 8;
}
#[inline]
fn write_u128(&mut self, i: u128) {
self.state.write_u128(i.to_le());
self.bytes_hashed += 16;
}
#[inline]
@ -115,37 +102,31 @@ impl<W> Hasher for StableHasher<W> {
// platforms. This is important for symbol hashes when cross compiling,
// for example.
self.state.write_u64((i as u64).to_le());
self.bytes_hashed += 8;
}
#[inline]
fn write_i8(&mut self, i: i8) {
self.state.write_i8(i);
self.bytes_hashed += 1;
}
#[inline]
fn write_i16(&mut self, i: i16) {
self.state.write_i16(i.to_le());
self.bytes_hashed += 2;
}
#[inline]
fn write_i32(&mut self, i: i32) {
self.state.write_i32(i.to_le());
self.bytes_hashed += 4;
}
#[inline]
fn write_i64(&mut self, i: i64) {
self.state.write_i64(i.to_le());
self.bytes_hashed += 8;
}
#[inline]
fn write_i128(&mut self, i: i128) {
self.state.write_i128(i.to_le());
self.bytes_hashed += 16;
}
#[inline]
@ -154,12 +135,35 @@ impl<W> Hasher for StableHasher<W> {
// platforms. This is important for symbol hashes when cross compiling,
// for example.
self.state.write_i64((i as i64).to_le());
self.bytes_hashed += 8;
}
}
/// Something that implements `HashStable<CTX>` can be hashed in a way that is
/// stable across multiple compilation sessions.
///
/// Note that `HashStable` imposes rather more strict requirements than usual
/// hash functions:
///
/// - Stable hashes are sometimes used as identifiers. Therefore they must
/// conform to the corresponding `PartialEq` implementations:
///
/// - `x == y` implies `hash_stable(x) == hash_stable(y)`, and
/// - `x != y` implies `hash_stable(x) != hash_stable(y)`.
///
/// That second condition is usually not required for hash functions
/// (e.g. `Hash`). In practice this means that `hash_stable` must feed any
/// information into the hasher that a `PartialEq` comparision takes into
/// account. See [#49300](https://github.com/rust-lang/rust/issues/49300)
/// for an example where violating this invariant has caused trouble in the
/// past.
///
/// - `hash_stable()` must be independent of the current
/// compilation session. E.g. they must not hash memory addresses or other
/// things that are "randomly" assigned per compilation session.
///
/// - `hash_stable()` must be independent of the host architecture. The
/// `StableHasher` takes care of endianness and `isize`/`usize` platform
/// differences.
pub trait HashStable<CTX> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut CTX,

View File

@ -95,7 +95,7 @@ enum LoadError<'a> {
impl<'a> LoadError<'a> {
fn report(self) -> ! {
match self {
LoadError::LocatorError(mut locate_ctxt) => locate_ctxt.report_errs(),
LoadError::LocatorError(locate_ctxt) => locate_ctxt.report_errs(),
}
}
}
@ -365,8 +365,8 @@ impl<'a> CrateLoader<'a> {
span,
ident,
crate_name: name,
hash: hash.map(|a| &*a),
extra_filename: extra_filename,
hash,
extra_filename,
filesearch: self.sess.target_filesearch(path_kind),
target: &self.sess.target.target,
triple: self.sess.opts.target_triple.clone(),

View File

@ -321,7 +321,7 @@ impl<'a> Context<'a> {
}
}
pub fn report_errs(&mut self) -> ! {
pub fn report_errs(self) -> ! {
let add = match self.root {
&None => String::new(),
&Some(ref r) => format!(" which `{}` depends on", r.ident),
@ -901,8 +901,7 @@ fn get_metadata_section_imp(target: &Target,
let mut inflated = Vec::new();
match DeflateDecoder::new(compressed_bytes).read_to_end(&mut inflated) {
Ok(_) => {
let buf = unsafe { OwningRef::new_assert_stable_address(inflated) };
rustc_erase_owner!(buf.map_owner_box())
rustc_erase_owner!(OwningRef::new(inflated).map_owner_box())
}
Err(_) => {
return Err(format!("failed to decompress metadata: {}", filename.display()));

View File

@ -671,18 +671,18 @@ a {
transition: border-color 300ms ease;
transition: border-radius 300ms ease-in-out;
transition: box-shadow 300ms ease-in-out;
width: calc(100% - 32px);
width: 100%;
}
#crate-search + .search-input {
border-radius: 0 1px 1px 0;
width: calc(100% - 32px);
}
.search-input:focus {
border-radius: 2px;
border: 0;
outline: 0;
box-shadow: 0 0 8px #078dd8;
}
.search-results .desc {
@ -1011,6 +1011,195 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
opacity: 1;
}
.information {
position: absolute;
left: -20px;
margin-top: 7px;
z-index: 1;
}
.tooltip {
position: relative;
display: inline-block;
cursor: pointer;
}
.tooltip .tooltiptext {
width: 120px;
display: none;
text-align: center;
padding: 5px 3px;
border-radius: 6px;
margin-left: 5px;
top: -5px;
left: 105%;
z-index: 10;
}
.tooltip:hover .tooltiptext {
display: inline;
}
.tooltip .tooltiptext::after {
content: " ";
position: absolute;
top: 50%;
left: 11px;
margin-top: -5px;
border-width: 5px;
border-style: solid;
}
.important-traits .tooltip .tooltiptext {
border: 1px solid;
}
pre.rust {
position: relative;
tab-width: 4;
-moz-tab-width: 4;
}
.search-failed {
text-align: center;
margin-top: 20px;
}
.search-failed > ul {
text-align: left;
max-width: 570px;
margin-left: auto;
margin-right: auto;
}
#titles {
height: 35px;
}
#titles > div {
float: left;
width: 33.3%;
text-align: center;
font-size: 18px;
cursor: pointer;
border-top: 2px solid;
}
#titles > div:not(:last-child) {
margin-right: 1px;
width: calc(33.3% - 1px);
}
#titles > div > div.count {
display: inline-block;
font-size: 16px;
}
.important-traits {
cursor: pointer;
z-index: 2;
}
h4 > .important-traits {
position: absolute;
left: -44px;
top: 2px;
}
#all-types {
text-align: center;
border: 1px solid;
margin: 0 10px;
margin-bottom: 10px;
display: block;
border-radius: 7px;
}
#all-types > p {
margin: 5px 0;
}
#sidebar-toggle {
position: fixed;
top: 30px;
left: 300px;
z-index: 10;
padding: 3px;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
cursor: pointer;
font-weight: bold;
transition: left .5s;
font-size: 1.2em;
border: 1px solid;
border-left: 0;
}
#source-sidebar {
position: fixed;
top: 0;
bottom: 0;
left: 0;
width: 300px;
z-index: 1;
overflow: auto;
transition: left .5s;
border-right: 1px solid;
}
#source-sidebar > .title {
font-size: 1.5em;
text-align: center;
border-bottom: 1px solid;
margin-bottom: 6px;
}
.theme-picker {
position: absolute;
left: 211px;
top: 19px;
}
.theme-picker button {
outline: none;
}
#settings-menu {
position: absolute;
right: 0;
top: 10px;
outline: none;
}
#theme-picker, #settings-menu {
padding: 4px;
width: 27px;
height: 29px;
border: 1px solid;
border-radius: 3px;
cursor: pointer;
}
#theme-choices {
display: none;
position: absolute;
left: 0;
top: 28px;
border: 1px solid;
border-radius: 3px;
z-index: 1;
cursor: pointer;
}
#theme-choices > button {
border: none;
width: 100%;
padding: 4px;
text-align: center;
background: rgba(0,0,0,0);
}
#theme-choices > button:not(:first-child) {
border-top: 1px solid;
}
/* Media Queries */
@media (max-width: 700px) {
@ -1137,125 +1326,12 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
overflow: initial;
}
#main > .line-numbers {
margin-top: 0;
.theme-picker {
left: 10px;
top: 54px;
z-index: 1;
}
}
@media print {
nav.sub, .content .out-of-band, .collapse-toggle {
display: none;
}
}
.information {
position: absolute;
left: -20px;
margin-top: 7px;
z-index: 1;
}
.tooltip {
position: relative;
display: inline-block;
cursor: pointer;
}
.tooltip .tooltiptext {
width: 120px;
display: none;
text-align: center;
padding: 5px 3px;
border-radius: 6px;
margin-left: 5px;
top: -5px;
left: 105%;
z-index: 10;
}
.tooltip:hover .tooltiptext {
display: inline;
}
.tooltip .tooltiptext::after {
content: " ";
position: absolute;
top: 50%;
left: 11px;
margin-top: -5px;
border-width: 5px;
border-style: solid;
}
.important-traits .tooltip .tooltiptext {
border: 1px solid;
}
pre.rust {
position: relative;
tab-width: 4;
-moz-tab-width: 4;
}
.search-failed {
text-align: center;
margin-top: 20px;
}
.search-failed > ul {
text-align: left;
max-width: 570px;
margin-left: auto;
margin-right: auto;
}
#titles {
height: 35px;
}
#titles > div {
float: left;
width: 33.3%;
text-align: center;
font-size: 18px;
cursor: pointer;
border-top: 2px solid;
}
#titles > div:not(:last-child) {
margin-right: 1px;
width: calc(33.3% - 1px);
}
#titles > div > div.count {
display: inline-block;
font-size: 16px;
}
.important-traits {
cursor: pointer;
z-index: 2;
}
h4 > .important-traits {
position: absolute;
left: -44px;
top: 2px;
}
#all-types {
text-align: center;
border: 1px solid;
margin: 0 10px;
margin-bottom: 10px;
display: block;
border-radius: 7px;
}
#all-types > p {
margin: 5px 0;
}
@media (max-width: 700px) {
h4 > .important-traits {
position: absolute;
left: -22px;
@ -1330,8 +1406,29 @@ h4 > .important-traits {
#all-types {
margin: 10px;
}
#sidebar-toggle {
top: 100px;
width: 30px;
font-size: 1.5rem;
text-align: center;
padding: 0;
}
#source-sidebar {
z-index: 11;
}
#main > .line-numbers {
margin-top: 0;
}
}
@media print {
nav.sub, .content .out-of-band, .collapse-toggle {
display: none;
}
}
@media (max-width: 416px) {
#titles {
@ -1431,63 +1528,6 @@ kbd {
cursor: default;
}
.theme-picker {
position: absolute;
left: 211px;
top: 19px;
}
.theme-picker button {
outline: none;
}
#settings-menu {
position: absolute;
right: 0;
top: 10px;
outline: none;
}
#theme-picker, #settings-menu {
padding: 4px;
width: 27px;
height: 29px;
border: 1px solid;
border-radius: 3px;
cursor: pointer;
}
#theme-choices {
display: none;
position: absolute;
left: 0;
top: 28px;
border: 1px solid;
border-radius: 3px;
z-index: 1;
cursor: pointer;
}
#theme-choices > button {
border: none;
width: 100%;
padding: 4px;
text-align: center;
background: rgba(0,0,0,0);
}
#theme-choices > button:not(:first-child) {
border-top: 1px solid;
}
@media (max-width: 700px) {
.theme-picker {
left: 10px;
top: 54px;
z-index: 1;
}
}
.hidden-by-impl-hider,
.hidden-by-usual-hider {
/* important because of conflicting rule for small screens */
@ -1539,39 +1579,6 @@ kbd {
margin-bottom: 1em;
}
#sidebar-toggle {
position: fixed;
top: 30px;
left: 300px;
z-index: 10;
padding: 3px;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
cursor: pointer;
font-weight: bold;
transition: left .5s;
font-size: 1.2em;
border: 1px solid;
border-left: 0;
}
#source-sidebar {
position: fixed;
top: 0;
bottom: 0;
left: 0;
width: 300px;
z-index: 1;
overflow: auto;
transition: left .5s;
border-right: 1px solid;
}
#source-sidebar > .title {
font-size: 1.5em;
text-align: center;
border-bottom: 1px solid;
margin-bottom: 6px;
}
div.children {
padding-left: 27px;
display: none;

View File

@ -164,20 +164,21 @@ a.test-arrow {
color: #111;
background-color: #f0f0f0;
border-color: #000;
box-shadow: 0 0 0 1px #000, 0 0 0 2px transparent;
}
.search-input {
color: #111;
box-shadow: 0 0 0 1px #000, 0 0 0 2px transparent;
background-color: #f0f0f0;
box-shadow: 0 0 0 1px #000, 0 0 0 2px transparent;
}
.search-input:focus {
border-color: #008dfd;
}
#crate-search + .search-input {
box-shadow: 1px 0 0 1px #000, 0 0 0 2px transparent;
#crate-search + .search-input:focus {
box-shadow: 0 0 8px 4px #078dd8;
}
.module-item .stab {

View File

@ -164,21 +164,21 @@ a.test-arrow {
color: #555;
background-color: white;
border-color: #e0e0e0;
box-shadow: 0px 0 0 1px #e0e0e0, 0 0 0 2px transparent;
box-shadow: 0 0 0 1px #e0e0e0, 0 0 0 2px transparent;
}
.search-input {
color: #555;
box-shadow: 0 0 0 1px #e0e0e0, 0 0 0 2px transparent;
background-color: white;
box-shadow: 0 0 0 1px #e0e0e0, 0 0 0 2px transparent;
}
.search-input:focus {
border-color: #66afe9;
}
#crate-search + .search-input {
box-shadow: 1px 0 0 1px #e0e0e0, 0 0 0 2px transparent;
#crate-search + .search-input:focus {
box-shadow: 0 0 8px #078dd8;
}
.module-item .stab {

View File

@ -173,6 +173,9 @@ static HOOK: AtomicPtr<()> = AtomicPtr::new(ptr::null_mut());
/// about the allocation that failed.
///
/// The allocation error hook is a global resource.
///
/// [`set_alloc_error_hook`]: fn.set_alloc_error_hook.html
/// [`take_alloc_error_hook`]: fn.take_alloc_error_hook.html
#[unstable(feature = "alloc_error_hook", issue = "51245")]
pub fn set_alloc_error_hook(hook: fn(Layout)) {
HOOK.store(hook as *mut (), Ordering::SeqCst);
@ -183,6 +186,8 @@ pub fn set_alloc_error_hook(hook: fn(Layout)) {
/// *See also the function [`set_alloc_error_hook`].*
///
/// If no custom hook is registered, the default hook will be returned.
///
/// [`set_alloc_error_hook`]: fn.set_alloc_error_hook.html
#[unstable(feature = "alloc_error_hook", issue = "51245")]
pub fn take_alloc_error_hook() -> fn(Layout) {
let hook = HOOK.swap(ptr::null_mut(), Ordering::SeqCst);

View File

@ -2494,7 +2494,10 @@ impl DefaultHasher {
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
impl Default for DefaultHasher {
/// Creates a new `DefaultHasher` using [`new`][DefaultHasher::new].
// FIXME: here should link `new` to [DefaultHasher::new], but it occurs intra-doc link
// resolution failure when re-exporting libstd items. When #56922 fixed,
// link `new` to [DefaultHasher::new] again.
/// Creates a new `DefaultHasher` using `new`.
/// See its documentation for more.
fn default() -> DefaultHasher {
DefaultHasher::new()

View File

@ -218,6 +218,8 @@ mod private {
impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
/// Converts a type of [`Error`] into a box of dyn [`Error`].
///
/// [`Error`]: ../error/trait.Error.html
///
/// # Examples
///
/// ```
@ -255,6 +257,8 @@ impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync +
/// Converts a type of [`Error`] + [`Send`] + [`Sync`] into a box of dyn [`Error`] +
/// [`Send`] + [`Sync`].
///
/// [`Error`]: ../error/trait.Error.html
///
/// # Examples
///
/// ```
@ -296,6 +300,8 @@ impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync +
impl From<String> for Box<dyn Error + Send + Sync> {
/// Converts a [`String`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
///
/// [`Error`]: ../error/trait.Error.html
///
/// # Examples
///
/// ```
@ -329,6 +335,8 @@ impl From<String> for Box<dyn Error + Send + Sync> {
impl From<String> for Box<dyn Error> {
/// Converts a [`String`] into a box of dyn [`Error`].
///
/// [`Error`]: ../error/trait.Error.html
///
/// # Examples
///
/// ```
@ -350,6 +358,8 @@ impl From<String> for Box<dyn Error> {
impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a> {
/// Converts a [`str`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
///
/// [`Error`]: ../error/trait.Error.html
///
/// # Examples
///
/// ```
@ -370,6 +380,8 @@ impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a> {
impl From<&str> for Box<dyn Error> {
/// Converts a [`str`] into a box of dyn [`Error`].
///
/// [`Error`]: ../error/trait.Error.html
///
/// # Examples
///
/// ```
@ -389,6 +401,9 @@ impl From<&str> for Box<dyn Error> {
impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
/// Converts a [`Cow`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
///
/// [`Cow`]: ../borrow/enum.Cow.html
/// [`Error`]: ../error/trait.Error.html
///
/// # Examples
///
/// ```
@ -410,6 +425,9 @@ impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
/// Converts a [`Cow`] into a box of dyn [`Error`].
///
/// [`Cow`]: ../borrow/enum.Cow.html
/// [`Error`]: ../error/trait.Error.html
///
/// # Examples
///
/// ```

View File

@ -351,6 +351,8 @@ impl From<String> for OsString {
/// Converts a [`String`] into a [`OsString`].
///
/// The conversion copies the data, and includes an allocation on the heap.
///
/// [`OsString`]: ../../std/ffi/struct.OsString.html
fn from(s: String) -> OsString {
OsString { inner: Buf::from_string(s) }
}

View File

@ -1812,6 +1812,8 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
/// function.)
/// * `path` already exists.
///
/// [`create_dir_all`]: fn.create_dir_all.html
///
/// # Examples
///
/// ```no_run

View File

@ -754,7 +754,7 @@ impl<W> fmt::Display for IntoInnerError<W> {
/// completed, rather than the entire buffer at once. Enter `LineWriter`. It
/// does exactly that.
///
/// Like [`BufWriter`], a `LineWriter`s buffer will also be flushed when the
/// Like [`BufWriter`][bufwriter], a `LineWriter`s buffer will also be flushed when the
/// `LineWriter` goes out of scope or when its internal buffer is full.
///
/// [bufwriter]: struct.BufWriter.html

View File

@ -546,6 +546,9 @@ impl FromInner<c::sockaddr_in6> for SocketAddrV6 {
#[stable(feature = "ip_from_ip", since = "1.16.0")]
impl From<SocketAddrV4> for SocketAddr {
/// Converts a [`SocketAddrV4`] into a [`SocketAddr::V4`].
///
/// [`SocketAddrV4`]: ../../std/net/struct.SocketAddrV4.html
/// [`SocketAddr::V4`]: ../../std/net/enum.SocketAddr.html#variant.V4
fn from(sock4: SocketAddrV4) -> SocketAddr {
SocketAddr::V4(sock4)
}
@ -554,6 +557,9 @@ impl From<SocketAddrV4> for SocketAddr {
#[stable(feature = "ip_from_ip", since = "1.16.0")]
impl From<SocketAddrV6> for SocketAddr {
/// Converts a [`SocketAddrV6`] into a [`SocketAddr::V6`].
///
/// [`SocketAddrV6`]: ../../std/net/struct.SocketAddrV6.html
/// [`SocketAddr::V6`]: ../../std/net/enum.SocketAddr.html#variant.V6
fn from(sock6: SocketAddrV6) -> SocketAddr {
SocketAddr::V6(sock6)
}
@ -567,6 +573,13 @@ impl<I: Into<IpAddr>> From<(I, u16)> for SocketAddr {
/// and creates a [`SocketAddr::V6`] for a [`IpAddr::V6`].
///
/// `u16` is treated as port of the newly created [`SocketAddr`].
///
/// [`IpAddr`]: ../../std/net/enum.IpAddr.html
/// [`IpAddr::V4`]: ../../std/net/enum.IpAddr.html#variant.V4
/// [`IpAddr::V6`]: ../../std/net/enum.IpAddr.html#variant.V6
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
/// [`SocketAddr::V4`]: ../../std/net/enum.SocketAddr.html#variant.V4
/// [`SocketAddr::V6`]: ../../std/net/enum.SocketAddr.html#variant.V6
fn from(pieces: (I, u16)) -> SocketAddr {
SocketAddr::new(pieces.0.into(), pieces.1)
}

View File

@ -376,6 +376,8 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> {
impl<T> From<T> for Mutex<T> {
/// Creates a new mutex in an unlocked state ready for use.
/// This is equivalent to [`Mutex::new`].
///
/// [`Mutex::new`]: ../../std/sync/struct.Mutex.html#method.new
fn from(t: T) -> Self {
Mutex::new(t)
}

View File

@ -453,6 +453,8 @@ impl<T: Default> Default for RwLock<T> {
impl<T> From<T> for RwLock<T> {
/// Creates a new instance of an `RwLock<T>` which is unlocked.
/// This is equivalent to [`RwLock::new`].
///
/// [`RwLock::new`]: ../../std/sync/struct.RwLock.html#method.new
fn from(t: T) -> Self {
RwLock::new(t)
}

View File

@ -47,7 +47,12 @@ mod imp {
let err = errno() as libc::c_int;
if err == libc::EINTR {
continue;
} else if err == libc::ENOSYS {
} else if err == libc::ENOSYS || err == libc::EPERM {
// Fall back to reading /dev/urandom if `getrandom` is not
// supported on the current kernel.
//
// Also fall back in case it is disabled by something like
// seccomp or inside of virtual machines.
GETRANDOM_UNAVAILABLE.store(true, Ordering::Relaxed);
return false;
} else if err == libc::EAGAIN {

View File

@ -443,6 +443,7 @@ impl Builder {
/// [`Builder::spawn`]: ../../std/thread/struct.Builder.html#method.spawn
/// [`io::Result`]: ../../std/io/type.Result.html
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
/// [`JoinHandle::join`]: ../../std/thread/struct.JoinHandle.html#method.join
#[unstable(feature = "thread_spawn_unchecked", issue = "55132")]
pub unsafe fn spawn_unchecked<'a, F, T>(self, f: F) -> io::Result<JoinHandle<T>> where
F: FnOnce() -> T, F: Send + 'a, T: Send + 'a

View File

@ -16,7 +16,7 @@ use crate::ThinVec;
use rustc_data_structures::indexed_vec::Idx;
#[cfg(target_arch = "x86_64")]
use rustc_data_structures::static_assert;
use rustc_data_structures::static_assert_size;
use rustc_target::spec::abi::Abi;
use syntax_pos::{Span, DUMMY_SP};
@ -964,7 +964,7 @@ pub struct Expr {
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_EXPR: std::mem::size_of::<Expr>() == 96);
static_assert_size!(Expr, 96);
impl Expr {
/// Whether this expression would be valid somewhere that expects a value; for example, an `if`

View File

@ -998,7 +998,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
(sym::repr, Normal, template!(List: "C, packed, ..."), Ungated),
(sym::path, Normal, template!(NameValueStr: "file"), Ungated),
(sym::automatically_derived, Normal, template!(Word), Ungated),
(sym::no_mangle, Normal, template!(Word), Ungated),
(sym::no_mangle, Whitelisted, template!(Word), Ungated),
(sym::no_link, Normal, template!(Word), Ungated),
(sym::derive, Normal, template!(List: "Trait1, Trait2, ..."), Ungated),
(

View File

@ -19,7 +19,7 @@ use log::info;
use std::fmt;
use std::mem;
#[cfg(target_arch = "x86_64")]
use rustc_data_structures::static_assert;
use rustc_data_structures::static_assert_size;
use rustc_data_structures::sync::Lrc;
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
@ -74,7 +74,7 @@ pub enum Lit {
}
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_LIT: mem::size_of::<Lit>() == 8);
static_assert_size!(Lit, 8);
impl Lit {
crate fn literal_name(&self) -> &'static str {
@ -220,7 +220,7 @@ pub enum Token {
// `Token` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_STATEMENT: mem::size_of::<Token>() == 16);
static_assert_size!(Token, 16);
impl Token {
/// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary.

View File

@ -21,7 +21,7 @@ use crate::print::pprust;
use syntax_pos::{BytePos, Mark, Span, DUMMY_SP};
#[cfg(target_arch = "x86_64")]
use rustc_data_structures::static_assert;
use rustc_data_structures::static_assert_size;
use rustc_data_structures::sync::Lrc;
use serialize::{Decoder, Decodable, Encoder, Encodable};
use smallvec::{SmallVec, smallvec};
@ -158,7 +158,7 @@ pub type TreeAndJoint = (TokenTree, IsJoint);
// `TokenStream` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_TOKEN_STREAM: mem::size_of::<TokenStream>() == 8);
static_assert_size!(TokenStream, 8);
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum IsJoint {

View File

@ -67,13 +67,10 @@ mod llvm_libunwind {
cfg.flag("-std=c99");
cfg.flag("-std=c++11");
cfg.flag("-nostdinc++");
if cfg.is_flag_supported("-funwind-tables").unwrap_or_default() &&
cfg.is_flag_supported("-fno-exceptions").unwrap_or_default() {
cfg.flag("-funwind-tables");
cfg.flag("-fno-exceptions");
}
cfg.flag("-fno-exceptions");
cfg.flag("-fno-rtti");
cfg.flag("-fstrict-aliasing");
cfg.flag("-funwind-tables");
}
let mut unwind_sources = vec![

View File

@ -0,0 +1,10 @@
// revisions:rpass1 rpass2
// compile-flags: --crate-type cdylib
// skip-codegen
#![deny(unused_attributes)]
#[no_mangle]
pub extern "C" fn rust_no_mangle() -> i32 {
42
}

View File

@ -0,0 +1,3 @@
#![deny(intra_doc_link_resolution_failure)]
pub use std::*;

View File

@ -52,7 +52,7 @@
//~^ WARN unused attribute
#![path = "3800"] //~ WARN unused attribute
#![automatically_derived] //~ WARN unused attribute
#![no_mangle] //~ WARN unused attribute
#![no_mangle]
#![no_link] //~ WARN unused attribute
// see issue-43106-gating-of-derive.rs
#![should_panic] //~ WARN unused attribute

View File

@ -1152,12 +1152,6 @@ warning: unused attribute
LL | #![automatically_derived]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:55:1
|
LL | #![no_mangle]
| ^^^^^^^^^^^^^
warning: unused attribute
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:56:1
|