Skip to content

Commit f6fe99c

Browse files
committed
Auto merge of rust-lang#70734 - Dylan-DPC:rollup-xmncatq, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - rust-lang#70696 (Extend rust-lang#69020 test to include reversed operand order.) - rust-lang#70706 (Minor cleanup in rustdoc --check-theme) - rust-lang#70725 (Avoid `.unwrap()`s on `.span_to_snippet(...)`s) - rust-lang#70728 (Minor doc improvements on `AllocRef`) - rust-lang#70730 (Fix link in task::Wake docs) - rust-lang#70731 (Minor follow-up after renaming librustc(_middle)) Failed merges: r? @ghost
2 parents 34f7f55 + 04824f3 commit f6fe99c

File tree

31 files changed

+356
-220
lines changed

31 files changed

+356
-220
lines changed

src/liballoc/task.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ use crate::sync::Arc;
1212
/// to the tasks that are executed on that executor.
1313
///
1414
/// This trait is a memory-safe and ergonomic alternative to constructing a
15-
/// [`RawWaker`]. It supports the common executor design in which the data
16-
/// used to wake up a task is stored in an [`Arc`]. Some executors (especially
15+
/// [`RawWaker`]. It supports the common executor design in which the data used
16+
/// to wake up a task is stored in an [`Arc`][arc]. Some executors (especially
1717
/// those for embedded systems) cannot use this API, which is why [`RawWaker`]
1818
/// exists as an alternative for those systems.
19+
///
20+
/// [arc]: ../../std/sync/struct.Arc.html
1921
#[unstable(feature = "wake_trait", issue = "69912")]
2022
pub trait Wake {
2123
/// Wake this task.

src/libcore/alloc/mod.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub enum ReallocPlacement {
119119
///
120120
/// Unlike [`GlobalAlloc`][], zero-sized allocations are allowed in `AllocRef`. If an underlying
121121
/// allocator does not support this (like jemalloc) or return a null pointer (such as
122-
/// `libc::malloc`), this case must be caught.
122+
/// `libc::malloc`), this must be caught by the implementation.
123123
///
124124
/// ### Currently allocated memory
125125
///
@@ -157,18 +157,20 @@ pub enum ReallocPlacement {
157157
/// # Safety
158158
///
159159
/// * Memory blocks returned from an allocator must point to valid memory and retain their validity
160-
/// until the instance and all of its clones are dropped, and
160+
/// until the instance and all of its clones are dropped,
161161
///
162162
/// * cloning or moving the allocator must not invalidate memory blocks returned from this
163-
/// allocator. A cloned allocator must behave like the same allocator.
163+
/// allocator. A cloned allocator must behave like the same allocator, and
164164
///
165165
/// * any pointer to a memory block which is [*currently allocated*] may be passed to any other
166166
/// method of the allocator.
167167
///
168168
/// [*currently allocated*]: #currently-allocated-memory
169169
#[unstable(feature = "allocator_api", issue = "32838")]
170170
pub unsafe trait AllocRef {
171-
/// On success, returns a memory block meeting the size and alignment guarantees of `layout`.
171+
/// Attempts to allocate a block of memory.
172+
///
173+
/// On success, returns a [`MemoryBlock`][] meeting the size and alignment guarantees of `layout`.
172174
///
173175
/// The returned block may have a larger size than specified by `layout.size()` and is
174176
/// initialized as specified by [`init`], all the way up to the returned size of the block.
@@ -190,26 +192,26 @@ pub unsafe trait AllocRef {
190192
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
191193
fn alloc(&mut self, layout: Layout, init: AllocInit) -> Result<MemoryBlock, AllocErr>;
192194

193-
/// Deallocates the memory denoted by `memory`.
195+
/// Deallocates the memory referenced by `ptr`.
194196
///
195197
/// # Safety
196198
///
197-
/// * `ptr` must be [*currently allocated*] via this allocator, and
198-
/// * `layout` must [*fit*] the `ptr`.
199+
/// * `ptr` must denote a block of memory [*currently allocated*] via this allocator, and
200+
/// * `layout` must [*fit*] that block of memory.
199201
///
200202
/// [*currently allocated*]: #currently-allocated-memory
201203
/// [*fit*]: #memory-fitting
202204
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout);
203205

204206
/// Attempts to extend the memory block.
205207
///
206-
/// Returns a new memory block containing a pointer and the actual size of the allocated
207-
/// block. The pointer is suitable for holding data described by a new layout with `layout`’s
208+
/// Returns a new [`MemoryBlock`][] containing a pointer and the actual size of the allocated
209+
/// memory. The pointer is suitable for holding data described by a new layout with `layout`’s
208210
/// alignment and a size given by `new_size`. To accomplish this, the allocator may extend the
209211
/// allocation referenced by `ptr` to fit the new layout. If the [`placement`] is
210212
/// [`InPlace`], the returned pointer is guaranteed to be the same as the passed `ptr`.
211213
///
212-
/// If `ReallocPlacement::MayMove` is used then ownership of the memory block referenced by `ptr`
214+
/// If [`MayMove`] is used then ownership of the memory block referenced by `ptr`
213215
/// is transferred to this allocator. The memory may or may not be freed, and should be
214216
/// considered unusable (unless of course it is transferred back to the caller again via the
215217
/// return value of this method).
@@ -227,17 +229,18 @@ pub unsafe trait AllocRef {
227229
/// the size of the `MemoryBlock` returned by the `grow` call.
228230
///
229231
/// [`InPlace`]: ReallocPlacement::InPlace
232+
/// [`MayMove`]: ReallocPlacement::MayMove
230233
/// [`placement`]: ReallocPlacement
231234
/// [`init`]: AllocInit
232235
///
233236
/// # Safety
234237
///
235-
/// * `ptr` must be [*currently allocated*] via this allocator,
236-
/// * `layout` must [*fit*] the `ptr`. (The `new_size` argument need not fit it.)
238+
/// * `ptr` must denote a block of memory [*currently allocated*] via this allocator,
239+
/// * `layout` must [*fit*] that block of memory (The `new_size` argument need not fit it.),
237240
// We can't require that `new_size` is strictly greater than `memory.size` because of ZSTs.
238241
// An alternative would be
239242
// * `new_size must be strictly greater than `memory.size` or both are zero
240-
/// * `new_size` must be greater than or equal to `layout.size()`
243+
/// * `new_size` must be greater than or equal to `layout.size()`, and
241244
/// * `new_size`, when rounded up to the nearest multiple of `layout.align()`, must not overflow
242245
/// (i.e., the rounded value must be less than or equal to `usize::MAX`).
243246
///
@@ -289,8 +292,8 @@ pub unsafe trait AllocRef {
289292

290293
/// Attempts to shrink the memory block.
291294
///
292-
/// Returns a new memory block containing a pointer and the actual size of the allocated
293-
/// block. The pointer is suitable for holding data described by a new layout with `layout`’s
295+
/// Returns a new [`MemoryBlock`][] containing a pointer and the actual size of the allocated
296+
/// memory. The pointer is suitable for holding data described by a new layout with `layout`’s
294297
/// alignment and a size given by `new_size`. To accomplish this, the allocator may shrink the
295298
/// allocation referenced by `ptr` to fit the new layout. If the [`placement`] is
296299
/// [`InPlace`], the returned pointer is guaranteed to be the same as the passed `ptr`.
@@ -310,20 +313,20 @@ pub unsafe trait AllocRef {
310313
///
311314
/// # Safety
312315
///
313-
/// * `ptr` must be [*currently allocated*] via this allocator,
314-
/// * `layout` must [*fit*] the `ptr`. (The `new_size` argument need not fit it.)
316+
/// * `ptr` must denote a block of memory [*currently allocated*] via this allocator,
317+
/// * `layout` must [*fit*] that block of memory (The `new_size` argument need not fit it.), and
315318
// We can't require that `new_size` is strictly smaller than `memory.size` because of ZSTs.
316319
// An alternative would be
317320
// * `new_size must be strictly smaller than `memory.size` or both are zero
318-
/// * `new_size` must be smaller than or equal to `layout.size()`
321+
/// * `new_size` must be smaller than or equal to `layout.size()`.
319322
///
320323
/// [*currently allocated*]: #currently-allocated-memory
321324
/// [*fit*]: #memory-fitting
322325
///
323326
/// # Errors
324327
///
325328
/// Returns `Err` if the new layout does not meet the allocator's size and alignment
326-
/// constraints of the allocator, or if growing otherwise fails.
329+
/// constraints of the allocator, or if shrinking otherwise fails.
327330
///
328331
/// Implementations are encouraged to return `Err` on memory exhaustion rather than panicking or
329332
/// aborting, but this is not a strict requirement. (Specifically: it is *legal* to implement

src/libcore/clone.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ pub struct AssertParamIsCopy<T: Copy + ?Sized> {
169169
/// Implementations of `Clone` for primitive types.
170170
///
171171
/// Implementations that cannot be described in Rust
172-
/// are implemented in `SelectionContext::copy_clone_conditions()` in librustc_middle.
172+
/// are implemented in `traits::SelectionContext::copy_clone_conditions()`
173+
/// in `rustc_trait_selection`.
173174
mod impls {
174175

175176
use super::Clone;

src/libcore/marker.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ impl<T: ?Sized> Unpin for *mut T {}
759759
/// Implementations of `Copy` for primitive types.
760760
///
761761
/// Implementations that cannot be described in Rust
762-
/// are implemented in `SelectionContext::copy_clone_conditions()` in librustc_middle.
762+
/// are implemented in `traits::SelectionContext::copy_clone_conditions()`
763+
/// in `rustc_trait_selection`.
763764
mod copy_impls {
764765

765766
use super::Copy;

src/libcore/raw.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
//! They can be used as targets of transmutes in unsafe code for manipulating
77
//! the raw representations directly.
88
//!
9-
//! Their definition should always match the ABI defined in `rustc_target::abi`.
9+
//! Their definition should always match the ABI defined in
10+
//! `rustc_middle::ty::layout`.
1011
1112
/// The representation of a trait object like `&SomeTrait`.
1213
///

src/librustc_infer/infer/lexical_region_resolve/graphviz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! This module provides linkage between libgraphviz traits and
2-
//! `rustc_middle::middle::typeck::infer::region_constraints`, generating a
2+
//! `rustc_trait_selection::infer::region_constraints`, generating a
33
//! rendering of the graph represented by the list of `Constraint`
44
//! instances (which make up the edges of the graph), as well as the
55
//! origin for each constraint (which are attached to the labels on

src/librustc_mir/borrow_check/region_infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub(crate) enum Cause {
202202
///
203203
/// For more information about this translation, see
204204
/// `InferCtxt::process_registered_region_obligations` and
205-
/// `InferCtxt::type_must_outlive` in `rustc_middle::infer::outlives`.
205+
/// `InferCtxt::type_must_outlive` in `rustc_infer::infer::InferCtxt`.
206206
#[derive(Clone, Debug)]
207207
pub struct TypeTest<'tcx> {
208208
/// The type `T` that must outlive the region.

src/librustc_mir/borrow_check/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
10531053
/// regions which are extracted and stored as having occurred at
10541054
/// `locations`.
10551055
///
1056-
/// **Any `rustc_middle::infer` operations that might generate region
1056+
/// **Any `rustc_infer::infer` operations that might generate region
10571057
/// constraints should occur within this method so that those
10581058
/// constraints can be properly localized!**
10591059
fn fully_perform_op<R>(

src/librustc_parse/parser/stmt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ impl<'a> Parser<'a> {
165165
// Rewind to before attempting to parse the type and continue parsing.
166166
let parser_snapshot_after_type = self.clone();
167167
mem::replace(self, parser_snapshot_before_type);
168-
169-
let snippet = self.span_to_snippet(pat.span).unwrap();
170-
err.span_label(pat.span, format!("while parsing the type for `{}`", snippet));
168+
if let Ok(snip) = self.span_to_snippet(pat.span) {
169+
err.span_label(pat.span, format!("while parsing the type for `{}`", snip));
170+
}
171171
(Some((parser_snapshot_after_type, colon_sp, err)), None)
172172
}
173173
}

src/librustc_passes/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ pub struct Context {
2727
/// of the innermost fn body. Each fn forms its own disjoint tree
2828
/// in the region hierarchy. These fn bodies are themselves
2929
/// arranged into a tree. See the "Modeling closures" section of
30-
/// the README in `infer::region_constraints` for more
31-
/// details.
30+
/// the README in `rustc_trait_selection::infer::region_constraints`
31+
/// for more details.
3232
root_id: Option<hir::ItemLocalId>,
3333

3434
/// The scope that contains any new variables declared, plus its depth in

0 commit comments

Comments
 (0)