Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #69879

Merged
merged 44 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1244ced
Remove "important traits" feature
GuillaumeGomez Feb 27, 2020
13c6d58
Remove spotlight usage
GuillaumeGomez Feb 27, 2020
7859f0e
Make PlaceRef lifetimes of Place::as_ref be both 'tcx
spastorino Mar 3, 2020
812e62f
Make PlaceRef lifetimes of LocalAnalyzer::process_place be both 'tcx
spastorino Mar 3, 2020
1a1dcfa
Make PlaceRef lifetimes of codegen_place be both 'tcx
spastorino Mar 3, 2020
2af5e87
Make PlaceRef lifetimes of monomorphized_place_ty be both 'tcx
spastorino Mar 3, 2020
a20d54f
Make PlaceRef lifetimes of RootPlace be both 'tcx
spastorino Mar 3, 2020
842af36
Make PlaceRef lifetimes of borrow_conflict_place be both 'tcx
spastorino Mar 4, 2020
f54e863
Make PlaceRef lifetimes of move_error_reported be both 'tcx
spastorino Mar 4, 2020
6200f5c
Make PlaceRef lifetimes of uninitialized_error_reported be both 'tcx
spastorino Mar 4, 2020
e32ee55
Make PlaceRef lifetimes of move_path_closest_to be both 'tcx
spastorino Mar 4, 2020
634a167
Make PlaceRef lifetimes of move_path_for_place be both 'tcx
spastorino Mar 4, 2020
c6f1244
Make PlaceRef lifetimes of is_upvar_field_projection be both 'tcx
spastorino Mar 4, 2020
6f23650
Make PlaceRef lifetimes of add_moved_or_invoked_closure_note be both …
spastorino Mar 4, 2020
eb67eca
Make PlaceRef lifetimes of describe_field be both 'tcx
spastorino Mar 4, 2020
a30f55f
Make PlaceRef lifetimes of borrowed_content_source be both 'tcx
spastorino Mar 4, 2020
bd4dad4
Make PlaceRef lifetimes of move_spans be both 'tcx
spastorino Mar 4, 2020
46d85e5
Make PlaceRef lifetimes of closure_span be both 'tcx
spastorino Mar 4, 2020
a32afa3
Make PlaceRef lifetimes of classify_drop_access_kind be both 'tcx
spastorino Mar 4, 2020
a5d1e18
Make PlaceRef lifetimes of is_prefix_of be both 'tcx
spastorino Mar 4, 2020
2cb2559
Make PlaceRef lifetimes of in_projection be both 'tcx
spastorino Mar 4, 2020
b11cd0b
PlaceRef<'a, 'tcx> -> PlaceRef<'tcx>
spastorino Mar 4, 2020
c1df945
rustc_metadata: Give decoder access to whole crate store
petrochenkov Mar 2, 2020
41374d7
rustc_metadata: Move some code from `impl CrateMetadataRef` to `impl …
petrochenkov Mar 3, 2020
f77afc8
Allow ZSTs in `AllocRef`
TimDiekmann Mar 7, 2020
d32924f
Check if output is immediate value
JohnTitor Mar 8, 2020
c06fa0b
clean up E0393 explanation
GuillaumeGomez Mar 9, 2020
b974d6f
test(patterns): add borrowck tests for combination of pattern features
thekuom Mar 8, 2020
6701215
Move `analysis` to the query macro
Zoxc Feb 25, 2020
cbce217
Remove the need for `no_force`
Zoxc Feb 26, 2020
f445077
Remove the `no_force` query attribute
Zoxc Feb 26, 2020
2f12009
Add a comment to `recover`.
Zoxc Mar 9, 2020
7c60405
Add note about localization to std::fmt docs
dylnuge Mar 9, 2020
a561962
Vec::new is const tstable in 1.39 not 1.32
CAD97 Mar 10, 2020
5b08aad
Rollup merge of #69475 - Zoxc:no-no-force, r=michaelwoerister
Centril Mar 10, 2020
6115035
Rollup merge of #69514 - GuillaumeGomez:remove-spotlight, r=kinnison
Centril Mar 10, 2020
5a62aca
Rollup merge of #69677 - petrochenkov:spancode, r=eddyb
Centril Mar 10, 2020
977d69f
Rollup merge of #69714 - spastorino:place-ref-lifetime, r=oli-obk
Centril Mar 10, 2020
6ad5e69
Rollup merge of #69799 - TimDiekmann:zst, r=Amanieu
Centril Mar 10, 2020
08095f4
Rollup merge of #69817 - thekuom:test/borrow-checking-pattern-feature…
Centril Mar 10, 2020
436f2ec
Rollup merge of #69836 - JohnTitor:immediate-outputs, r=nagisa
Centril Mar 10, 2020
6f1db99
Rollup merge of #69847 - GuillaumeGomez:cleanup-e0393, r=Dylan-DPC
Centril Mar 10, 2020
20361bd
Rollup merge of #69861 - Dylnuge:dylnuge/locale-doc, r=Mark-Simulacrum
Centril Mar 10, 2020
3e9efbd
Rollup merge of #69877 - CAD97:patch-1, r=dtolnay
Centril Mar 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,6 @@ Book][unstable-doc-cfg] and [its tracking issue][issue-doc-cfg].
[unstable-doc-cfg]: ../unstable-book/language-features/doc-cfg.html
[issue-doc-cfg]: https://github.com/rust-lang/rust/issues/43781

### Adding your trait to the "Important Traits" dialog

Rustdoc keeps a list of a few traits that are believed to be "fundamental" to a given type when
implemented on it. These traits are intended to be the primary interface for their types, and are
often the only thing available to be documented on their types. For this reason, Rustdoc will track
when a given type implements one of these traits and call special attention to it when a function
returns one of these types. This is the "Important Traits" dialog, visible as a circle-i button next
to the function, which, when clicked, shows the dialog.

In the standard library, the traits that qualify for inclusion are `Iterator`, `io::Read`, and
`io::Write`. However, rather than being implemented as a hard-coded list, these traits have a
special marker attribute on them: `#[doc(spotlight)]`. This means that you could apply this
attribute to your own trait to include it in the "Important Traits" dialog in documentation.

The `#[doc(spotlight)]` attribute currently requires the `#![feature(doc_spotlight)]` feature gate.
For more information, see [its chapter in the Unstable Book][unstable-spotlight] and [its tracking
issue][issue-spotlight].

[unstable-spotlight]: ../unstable-book/language-features/doc-spotlight.html
[issue-spotlight]: https://github.com/rust-lang/rust/issues/45040

### Exclude certain dependencies from documentation

The standard library uses several dependencies which, in turn, use several types and traits from the
Expand Down
30 changes: 0 additions & 30 deletions src/doc/unstable-book/src/language-features/doc-spotlight.md

This file was deleted.

34 changes: 28 additions & 6 deletions src/liballoc/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,19 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
#[unstable(feature = "allocator_api", issue = "32838")]
unsafe impl AllocRef for Global {
#[inline]
unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
NonNull::new(alloc(layout)).ok_or(AllocErr).map(|p| (p, layout.size()))
fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
if layout.size() == 0 {
Ok((layout.dangling(), 0))
} else {
unsafe { NonNull::new(alloc(layout)).ok_or(AllocErr).map(|p| (p, layout.size())) }
}
}

#[inline]
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
dealloc(ptr.as_ptr(), layout)
if layout.size() != 0 {
dealloc(ptr.as_ptr(), layout)
}
}

#[inline]
Expand All @@ -181,12 +187,28 @@ unsafe impl AllocRef for Global {
layout: Layout,
new_size: usize,
) -> Result<(NonNull<u8>, usize), AllocErr> {
NonNull::new(realloc(ptr.as_ptr(), layout, new_size)).ok_or(AllocErr).map(|p| (p, new_size))
match (layout.size(), new_size) {
(0, 0) => Ok((layout.dangling(), 0)),
(0, _) => self.alloc(Layout::from_size_align_unchecked(new_size, layout.align())),
(_, 0) => {
self.dealloc(ptr, layout);
Ok((layout.dangling(), 0))
}
(_, _) => NonNull::new(realloc(ptr.as_ptr(), layout, new_size))
.ok_or(AllocErr)
.map(|p| (p, new_size)),
}
}

#[inline]
unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
NonNull::new(alloc_zeroed(layout)).ok_or(AllocErr).map(|p| (p, layout.size()))
fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
if layout.size() == 0 {
Ok((layout.dangling(), 0))
} else {
unsafe {
NonNull::new(alloc_zeroed(layout)).ok_or(AllocErr).map(|p| (p, layout.size()))
}
}
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/liballoc/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,21 @@
//! Hello, ` 123` has 3 right-aligned characters
//! ```
//!
//! ## Localization
//!
//! In some programming languages, the behavior of string formatting functions
//! depends on the operating system's locale setting. The format functions
//! provided by Rust's standard library do not have any concept of locale, and
//! will produce the same results on all systems regardless of user
//! configuration.
//!
//! For example, the following code will always print `1.5` even if the system
//! locale uses a decimal separator other than a dot.
//!
//! ```
//! println!("The value is {}", 1.5);
//! ```
//!
//! # Escaping
//!
//! The literal characters `{` and `}` may be included in a string by preceding
Expand Down
38 changes: 18 additions & 20 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,28 @@ impl<T, A: AllocRef> RawVec<T, A> {
}

fn allocate_in(mut capacity: usize, zeroed: bool, mut a: A) -> Self {
unsafe {
let elem_size = mem::size_of::<T>();
let elem_size = mem::size_of::<T>();

let alloc_size = capacity.checked_mul(elem_size).unwrap_or_else(|| capacity_overflow());
alloc_guard(alloc_size).unwrap_or_else(|_| capacity_overflow());
let alloc_size = capacity.checked_mul(elem_size).unwrap_or_else(|| capacity_overflow());
alloc_guard(alloc_size).unwrap_or_else(|_| capacity_overflow());

// Handles ZSTs and `capacity == 0` alike.
let ptr = if alloc_size == 0 {
NonNull::<T>::dangling()
} else {
let align = mem::align_of::<T>();
let layout = Layout::from_size_align(alloc_size, align).unwrap();
let result = if zeroed { a.alloc_zeroed(layout) } else { a.alloc(layout) };
match result {
Ok((ptr, size)) => {
capacity = size / elem_size;
ptr.cast()
}
Err(_) => handle_alloc_error(layout),
// Handles ZSTs and `capacity == 0` alike.
let ptr = if alloc_size == 0 {
NonNull::<T>::dangling()
} else {
let align = mem::align_of::<T>();
let layout = Layout::from_size_align(alloc_size, align).unwrap();
let result = if zeroed { a.alloc_zeroed(layout) } else { a.alloc(layout) };
match result {
Ok((ptr, size)) => {
capacity = size / elem_size;
ptr.cast()
}
};
Err(_) => handle_alloc_error(layout),
}
};

RawVec { ptr: ptr.into(), cap: capacity, a }
}
RawVec { ptr: ptr.into(), cap: capacity, a }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/raw_vec/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn allocator_param() {
fuel: usize,
}
unsafe impl AllocRef for BoundedAlloc {
unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
let size = layout.size();
if size > self.fuel {
return Err(AllocErr);
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl<T> Vec<T> {
/// let mut vec: Vec<i32> = Vec::new();
/// ```
#[inline]
#[rustc_const_stable(feature = "const_vec_new", since = "1.32.0")]
#[rustc_const_stable(feature = "const_vec_new", since = "1.39.0")]
#[stable(feature = "rust1", since = "1.0.0")]
pub const fn new() -> Vec<T> {
Vec { buf: RawVec::NEW, len: 0 }
Expand Down
56 changes: 13 additions & 43 deletions src/libcore/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,20 +606,11 @@ pub unsafe trait GlobalAlloc {
/// method (`dealloc`) or by being passed to a reallocation method
/// (see above) that returns `Ok`.
///
/// A note regarding zero-sized types and zero-sized layouts: many
/// methods in the `AllocRef` trait state that allocation requests
/// must be non-zero size, or else undefined behavior can result.
///
/// * If an `AllocRef` implementation chooses to return `Ok` in this
/// case (i.e., the pointer denotes a zero-sized inaccessible block)
/// then that returned pointer must be considered "currently
/// allocated". On such an allocator, *all* methods that take
/// currently-allocated pointers as inputs must accept these
/// zero-sized pointers, *without* causing undefined behavior.
///
/// * In other words, if a zero-sized pointer can flow out of an
/// allocator, then that allocator must likewise accept that pointer
/// flowing back into its deallocation and reallocation methods.
/// Unlike [`GlobalAlloc`], zero-sized allocations are allowed in
/// `AllocRef`. If an underlying allocator does not support this (like
/// jemalloc) or return a null pointer (such as `libc::malloc`), this case
/// must be caught. In this case [`Layout::dangling()`] can be used to
/// create a dangling, but aligned `NonNull<u8>`.
///
/// Some of the methods require that a layout *fit* a memory block.
/// What it means for a layout to "fit" a memory block means (or
Expand Down Expand Up @@ -649,6 +640,9 @@ pub unsafe trait GlobalAlloc {
/// * if an allocator does not support overallocating, it is fine to
/// simply return `layout.size()` as the allocated size.
///
/// [`GlobalAlloc`]: self::GlobalAlloc
/// [`Layout::dangling()`]: self::Layout::dangling
///
/// # Safety
///
/// The `AllocRef` trait is an `unsafe` trait for a number of reasons, and
Expand All @@ -669,14 +663,6 @@ pub unsafe trait GlobalAlloc {
/// the future.
#[unstable(feature = "allocator_api", issue = "32838")]
pub unsafe trait AllocRef {
// (Note: some existing allocators have unspecified but well-defined
// behavior in response to a zero size allocation request ;
// e.g., in C, `malloc` of 0 will either return a null pointer or a
// unique pointer, but will not have arbitrary undefined
// behavior.
// However in jemalloc for example,
// `mallocx(0)` is documented as undefined behavior.)

/// On success, returns a pointer meeting the size and alignment
/// guarantees of `layout` and the actual size of the allocated block,
/// which must be greater than or equal to `layout.size()`.
Expand All @@ -690,15 +676,6 @@ pub unsafe trait AllocRef {
/// behavior, e.g., to ensure initialization to particular sets of
/// bit patterns.)
///
/// # Safety
///
/// This function is unsafe because undefined behavior can result
/// if the caller does not ensure that `layout` has non-zero size.
///
/// (Extension subtraits might provide more specific bounds on
/// behavior, e.g., guarantee a sentinel address or a null pointer
/// in response to a zero-size allocation request.)
///
/// # Errors
///
/// Returning `Err` indicates that either memory is exhausted or
Expand All @@ -716,7 +693,7 @@ pub unsafe trait AllocRef {
/// rather than directly invoking `panic!` or similar.
///
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr>;
fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr>;

/// Deallocate the memory referenced by `ptr`.
///
Expand All @@ -738,10 +715,6 @@ pub unsafe trait AllocRef {
/// Behaves like `alloc`, but also ensures that the contents
/// are set to zero before being returned.
///
/// # Safety
///
/// This function is unsafe for the same reasons that `alloc` is.
///
/// # Errors
///
/// Returning `Err` indicates that either memory is exhausted or
Expand All @@ -753,17 +726,17 @@ pub unsafe trait AllocRef {
/// rather than directly invoking `panic!` or similar.
///
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
let size = layout.size();
let result = self.alloc(layout);
if let Ok((p, _)) = result {
ptr::write_bytes(p.as_ptr(), 0, size);
unsafe { ptr::write_bytes(p.as_ptr(), 0, size) }
}
result
}

// == METHODS FOR MEMORY REUSE ==
// realloc. alloc_excess, realloc_excess
// realloc, realloc_zeroed, grow_in_place, grow_in_place_zeroed, shrink_in_place

/// Returns a pointer suitable for holding data described by
/// a new layout with `layout`’s alignment and a size given
Expand Down Expand Up @@ -793,8 +766,6 @@ pub unsafe trait AllocRef {
/// * `layout` must *fit* the `ptr` (see above). (The `new_size`
/// argument need not fit it.)
///
/// * `new_size` must be greater than zero.
///
/// * `new_size`, when rounded up to the nearest multiple of `layout.align()`,
/// must not overflow (i.e., the rounded value must be less than `usize::MAX`).
///
Expand Down Expand Up @@ -1009,8 +980,7 @@ pub unsafe trait AllocRef {
/// * `layout` must *fit* the `ptr` (see above); note the
/// `new_size` argument need not fit it,
///
/// * `new_size` must not be greater than `layout.size()`
/// (and must be greater than zero),
/// * `new_size` must not be greater than `layout.size()`,
///
/// # Errors
///
Expand Down
1 change: 0 additions & 1 deletion src/libcore/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use crate::task::{Context, Poll};
/// `.await` the value.
///
/// [`Waker`]: ../task/struct.Waker.html
#[doc(spotlight)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
#[stable(feature = "futures_api", since = "1.36.0")]
#[lang = "future_trait"]
Expand Down
1 change: 0 additions & 1 deletion src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
label = "`{Self}` is not an iterator",
message = "`{Self}` is not an iterator"
)]
#[doc(spotlight)]
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub trait Iterator {
/// The type of the elements being iterated over.
Expand Down
1 change: 0 additions & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
#![feature(custom_inner_attributes)]
#![feature(decl_macro)]
#![feature(doc_cfg)]
#![feature(doc_spotlight)]
#![feature(extern_types)]
#![feature(fundamental)]
#![feature(intrinsics)]
Expand Down
Loading