8000 Rollup of 11 pull requests by m-ou-se · Pull Request #80449 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 11 pull requests #80449

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

Merged
merged 24 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3533204
clarify wrapping ptr arithmetic docs
RalfJung Dec 26, 2020
8543388
address review feedback
RalfJung Dec 26, 2020
be3a5a1
BTreeMap: rename the area access methods
ssomers Dec 17, 2020
142764f
Add links to the source for the rustc and rustdoc books.
ehuss Dec 26, 2020
eeed311
Use raw version of align_of in rc data_offset
CAD97 Dec 26, 2020
6aea014
Document `InferTy` & co.
camelid Dec 27, 2020
cb17785
fix: small typo error in chalk/mod.rs
0xflotus Dec 27, 2020
f57152f
rustdoc book: fix example
marcoieni Dec 27, 2020
fcc88fa
Add regression test for #80375
LeSeulArtichaut Dec 27, 2020
cdad0c8
Also show the displayed version of IntVar and FloatVar
camelid Dec 27, 2020
9e77998
Add "length" as doc alias to len methods
LunaBorowska Dec 28, 2020
b3be9e1
Add "chr" as doc alias to char::from_u32
LunaBorowska Dec 28, 2020
10d6ff7
Fix stabilization version of deque_range feature.
m-ou-se Dec 28, 2020
9fdd95f
Rollup merge of #80383 - RalfJung:wrapping-ptr-arithmetic, r=dtolnay
m-ou-se Dec 28, 2020
255fde3
Rollup merge of #80390 - ssom 8000 ers:btree_cleanup_slices_2, r=Mark-Simul…
m-ou-se Dec 28, 2020
bae6475
Rollup merge of #80393 - ehuss:doc-git-link, r=jyn514
m-ou-se Dec 28, 2020
7003537
Rollup merge of #80398 - CAD97:fix-80365, r=dtolnay
m-ou-se Dec 28, 2020
803b375
Rollup merge of #80402 - camelid:inferty-docs, r=matthewjasper
m-ou-se Dec 28, 2020
8b43932
Rollup merge of #80403 - 0xflotus:patch-1, r=jyn514
m-ou-se Dec 28, 2020
7800c70
Rollup merge of #80410 - MarcoIeni:patch-1, r=jonas-schievink
m-ou-se Dec 28, 2020
a570928
Rollup merge of #80419 - LeSeulArtichaut:80375-test-case, r=lcnr
m-ou-se Dec 28, 2020
e351a3b
Rollup merge of #80430 - xfix:add-length-as-doc-alias, r=steveklabnik
m-ou-se Dec 28, 2020
5a08162
Rollup merge of #80431 - xfix:add-chr-as-doc-alias, r=steveklabnik
m-ou-se Dec 28, 2020
e3d26e0
Rollup merge of #80448 - m-ou-se:deque-range-version, r=m-ou-se
m-ou-se Dec 28, 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
Prev Previous commit
Next Next commit
address review feedback
  • Loading branch information
RalfJung committed Dec 26, 2020
commit 8543388beb52785897b87e3f0a5ffd3c8560f956
35 changes: 20 additions & 15 deletions library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,21 @@ impl<T: ?Sized> *const T {
/// It may *not* be used to access a different allocated object. Note that in Rust, every
/// (stack-allocated) variable is considered a separate allocated object.
///
/// In other words, `let z = x.wrapping_add((y as usize).wrapping_sub(x as usize) /
/// size_of::<T>())` does *not* make `z` the same as `y`: `z` is still attached to the object `x` is
/// attached to, and dereferencing it is Undefined Behavior unless `x` and `y` point into the
/// same allocated object.
/// In other words, `let z = x.wrapping_offset((y as isize) - (x as isize))` does *not* make `z`
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
/// `x` and `y` point into the same allocated object.
///
/// Compared to [`offset`], this method basically delays the requirement of staying within the
/// same allocated object: [`offset`] is immediate Undefined Behavior when crossing object
/// boundaries; `wrapping_offset` produces a pointer but still leads to Undefined Behavior if a
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`offset`]
/// can be optimized better and is thus preferable in performance-sensitive code.
///
/// `x.wrapping_offset(o).wrapping_offset(-o)` is always the same as `x` (if `-o` does not
/// overflow). In other words, leaving the allocated object and then re-entering it later is
/// permitted.
/// The delayed check only considers the value of the pointer that was dereferenced, not the
/// intermediate values used during the computation of the final result. For example,
/// `x.wrapping_offset(o).wrapping_offset(o.wrapping_neg())` is always the same as `x`. In other
/// words, leaving the allocated object and then re-entering it later is permitted.
///
/// If you need to cross object boundaries, cast the pointer to an integer and
/// do the arithmetic there.
Expand Down Expand Up @@ -580,17 +581,19 @@ impl<T: ?Sized> *const T {
/// It may *not* be used to access a different allocated object. Note that in Rust, every
/// (stack-allocated) variable is considered a separate allocated object.
///
/// In other words, `let z = x.wrapping_add((y as usize).wrapping_sub(x as usize) /
/// size_of::<T>())` does *not* make `z` the same as `y`: `z` is still attached to the object `x` is
/// attached to, and dereferencing it is Undefined Behavior unless `x` and `y` point into the
/// same allocated object.
/// In other words, `let z = x.wrapping_add((y as usize) - (x as usize))` does *not* make `z`
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
/// `x` and `y` point into the same allocated object.
///
/// Compared to [`add`], this method basically delays the requirement of staying within the
/// same allocated object: [`add`] is immediate Undefined Behavior when crossing object
/// boundaries; `wrapping_add` produces a pointer but still leads to Undefined Behavior if a
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`add`]
/// can be optimized better and is thus preferable in performance-sensitive code.
///
/// The delayed check only considers the value of the pointer that was dereferenced, not the
/// intermediate values used during the computation of the final result. For example,
/// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
/// allocated object and then re-entering it later is permitted.
///
Expand Down Expand Up @@ -643,17 +646,19 @@ impl<T: ?Sized> *const T {
/// It may *not* be used to access a different allocated object. Note that in Rust, every
/// (stack-allocated) variable is considered a separate allocated object.
///
/// In other words, `let z = x.wrapping_add((y as usize).wrapping_sub(x as usize) /
/// size_of::<T>())` does *not* make `z` the same as `y`: `z` is still attached to the object `x` is
/// attached to, and dereferencing it is Undefined Behavior unless `x` and `y` point into the
/// same allocated object.
/// In other words, `let z = x.wrapping_sub((x as usize) - (y as usize))` does *not* make `z`
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
/// `x` and `y` point into the same allocated object.
///
/// Compared to [`sub`], this method basically delays the requirement of staying within the
/// same allocated object: [`sub`] is immediate Undefined Behavior when crossing object
/// boundaries; `wrapping_sub` produces a pointer but still leads to Undefined Behavior if a
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`sub`]
/// can be optimized better and is thus preferable in performance-sensitive code.
///
/// The delayed check only considers the value of the pointer that was dereferenced, not the
/// intermediate values used during the computation of the final result. For example,
/// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
/// allocated object and then re-entering it later is permitted.
///
Expand Down
35 changes: 20 additions & 15 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,21 @@ impl<T: ?Sized> *mut T {
/// It may *not* be used to access a different allocated object. Note that in Rust, every
/// (stack-allocated) variable is considered a separate allocated object.
///
/// In other words, `let z = x.wrapping_add((y as usize).wrapping_sub(x as usize) /
/// size_of::<T>())` does *not* make `z` the same as `y`: `z` is still attached to the object `x` is
/// attached to, and dereferencing it is Undefined Behavior unless `x` and `y` point into the
/// same allocated object.
/// In other words, `let z = x.wrapping_offset((y as isize) - (x as isize))` does *not* make `z`
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
/// `x` and `y` point into the same allocated object.
///
/// Compared to [`offset`], this method basically delays the requirement of staying within the
/// same allocated object: [`offset`] is immediate Undefined Behavior when crossing object
/// boundaries; `wrapping_offset` produces a pointer but still leads to Undefined Behavior if a
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`offset`]
/// can be optimized better and is thus preferable in performance-sensitive code.
///
/// `x.wrapping_offset(o).wrapping_offset(-o)` is always the same as `x` (if `-o` does not
/// overflow). In other words, leaving the allocated object and then re-entering it later is
/// permitted.
/// The delayed check only considers the value of the pointer that was dereferenced, not the
/// intermediate values used during the computation of the final result. For example,
/// `x.wrapping_offset(o).wrapping_offset(o.wrapping_neg())` is always the same as `x`. In other
/// words, leaving the allocated object and then re-entering it later is permitted.
///
/// If you need to cross object boundaries, cast the pointer to an integer and
/// do the arithmetic there.
Expand Down Expand Up @@ -687,17 +688,19 @@ impl<T: ?Sized> *mut T {
/// It may *not* be used to access a different allocated object. Note that in Rust, every
/// (stack-allocated) variable is considered a separate allocated object.
///
/// In other words, `let z = x.wrapping_add((y as usize).wrapping_sub(x as usize) /
/// size_of::<T>())` does *not* make `z` the same as `y`: `z` is still attached to the object `x` is
/// attached to, and dereferencing it is Undefined Behavior unless `x` and `y` point into the
/// same allocated object.
/// In other words, `let z = x.wrapping_add((y as usize) - (x as usize))` does *not* make `z`
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
/// `x` and `y` point into the same allocated object.
///
/// Compared to [`add`], this method basically delays the requirement of staying within the
/// same allocated object: [`add`] is immediate Undefined Behavior when crossing object
/// boundaries; `wrapping_add` produces a pointer but still leads to Undefined Behavior if a
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`add`]
/// can be optimized better and is thus preferable in performance-sensitive code.
///
/// The delayed check only considers the value of the pointer that was dereferenced, not the
/// intermediate values used during the computation of the final result. For example,
/// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
/// allocated object and then re-entering it later is permitted.
///
Expand Down Expand Up @@ -750,17 +753,19 @@ impl<T: ?Sized> *mut T {
/// It may *not* be used to access a different allocated object. Note that in Rust, every
/// (stack-allocated) variable is considered a separate allocated object.
///
/// In other words, `let z = x.wrapping_add((y as usize).wrapping_sub(x as usize) /
/// size_of::<T>())` does *not* make `z` the same as `y`: `z` is still attached to the object `x` is
/// attached to, and dereferencing it is Undefined Behavior unless `x` and `y` point into the
/// same allocated object.
/// In other words, `let z = x.wrapping_sub((x as usize) - (y as usize))` does *not* make `z`
/// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still
/// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless
/// `x` and `y` point into the same allocated object.
///
/// Compared to [`sub`], this method basically delays the requirement of staying within the
/// same allocated object: [`sub`] is immediate Undefined Behavior when crossing object
/// boundaries; `wrapping_sub` produces a pointer but still leads to Undefined Behavior if a
/// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`sub`]
/// can be optimized better and is thus preferable in performance-sensitive code.
///
/// The delayed check only considers the value of the pointer that was dereferenced, not the
/// intermediate values used during the computation of the final result. For example,
/// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the
/// allocated object and then re-entering it later is permitted.
///
Expand Down
0