Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
127b6c4
cleanup code w/ pointers in std a little
WaffleLapkin Aug 1, 2022
a7c45ec
improve documentation of `pointer::align_offset`
WaffleLapkin Aug 1, 2022
be6bb56
add -Zextra-const-ub-checks to enable more UB checking in const-eval
RalfJung Aug 7, 2022
cc8259e
Adding more verbose documentation for `std::fmt::Write`
thedanvail Aug 8, 2022
7b2a5f2
dont rely on old macro-in-trait-impl bug
RalfJung Aug 9, 2022
2bd9479
compare with-flag to without-flag
RalfJung Aug 9, 2022
d52ed82
move an `assert!` to the right place
WaffleLapkin Aug 9, 2022
0436067
Merge branch 'rust-lang:master' into issue-98861-fix
thedanvail Aug 9, 2022
ee8a01f
Switching documentation to be more clear about potential errors
thedanvail Aug 9, 2022
2eebd34
errors: don't fail on broken primary translations
davidtwco Aug 10, 2022
3d21c37
std: optimize thread ID generation
joboet Aug 1, 2022
e1e25a8
Generalize trait object generic param check to aliases.
cjgillot Aug 7, 2022
0df84ae
Ban indirect references to `Self` too.
cjgillot Aug 7, 2022
98518c2
suggest const or static for global variable
chenyukang Aug 11, 2022
dd4613c
rustdoc: don't generate DOM element for operator
jsha Aug 11, 2022
e3c5bd6
let-else: add a test for warnings on let-else with diverging tail
cormacrelf Feb 15, 2022
9818526
Add regression test for #94176
est31 Jul 15, 2022
a8c799a
Rollup merge of #100022 - joboet:faster_threadid, r=joshtriplett
Dylan-DPC Aug 12, 2022
51eed00
Rollup merge of #100030 - WaffleLapkin:nice_pointer_sis, r=scottmcm
Dylan-DPC Aug 12, 2022
392ba5f
Rollup merge of #100229 - RalfJung:extra-const-ub-checks, r=lcnr
Dylan-DPC Aug 12, 2022
caac670
Rollup merge of #100247 - cjgillot:verify-dyn-trait-alias-defaults, r…
Dylan-DPC Aug 12, 2022
da3b89d
Rollup merge of #100255 - thedanvail:issue-98861-fix, r=joshtriplett
Dylan-DPC Aug 12, 2022
9e69dbc
Rollup merge of #100366 - davidtwco:translation-never-fail, r=compile…
Dylan-DPC Aug 12, 2022
9914c96
Rollup merge of #100396 - chenyukang:fix-100394, r=petrochenkov
Dylan-DPC Aug 12, 2022
0356034
Rollup merge of #100409 - jsha:highlight-lighter, r=GuillaumeGomez
Dylan-DPC Aug 12, 2022
3bc30bb
Rollup merge of #100443 - est31:let_else_regression_tests, r=Mark-Sim…
Dylan-DPC Aug 12, 2022
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
improve documentation of pointer::align_offset
  • Loading branch information
WaffleLapkin committed Aug 5, 2022
commit a7c45ec867fe93bdbbb2950ad9a69d5c5cb835e0
17 changes: 9 additions & 8 deletions library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,20 +1267,21 @@ impl<T: ?Sized> *const T {
/// Accessing adjacent `u8` as `u16`
///
/// ```
/// # fn foo(n: usize) {
/// # use std::mem::align_of;
/// use std::mem::align_of;
///
/// # unsafe {
/// let x = [5u8, 6, 7, 8, 9];
/// let ptr = x.as_ptr().add(n);
/// let x = [5_u8, 6, 7, 8, 9];
/// let ptr = x.as_ptr();
/// let offset = ptr.align_offset(align_of::<u16>());
/// if offset < x.len() - n - 1 {
/// let u16_ptr = ptr.add(offset) as *const u16;
/// assert_ne!(*u16_ptr, 500);
///
/// if offset < x.len() - 1 {
/// let u16_ptr = ptr.add(offset).cast::<u16>();
/// assert!(*u16_ptr == u16::from_ne_bytes([5, 6]) || *u16_ptr == u16::from_ne_bytes([6, 7]));
/// } else {
/// // while the pointer can be aligned via `offset`, it would point
/// // outside the allocation
/// }
/// # } }
/// # }
/// ```
#[stable(feature = "align_offset", since = "1.36.0")]
#[rustc_const_unstable(feature = "const_align_offset", issue = "90962")]
Expand Down
18 changes: 10 additions & 8 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,21 +1545,23 @@ impl<T: ?Sized> *mut T {
/// Accessing adjacent `u8` as `u16`
///
/// ```
/// # fn foo(n: usize) {
/// # use std::mem::align_of;
/// use std::mem::align_of;
///
/// # unsafe {
/// let mut x = [5u8, 6, 7, 8, 9];
/// let ptr = x.as_mut_ptr().add(n);
/// let mut x = [5_u8, 6, 7, 8, 9];
/// let ptr = x.as_mut_ptr();
/// let offset = ptr.align_offset(align_of::<u16>());
/// if offset < x.len() - n - 1 {
/// let u16_ptr = ptr.add(offset) as *mut u16;
/// assert_ne!(*u16_ptr, 500);
///
/// if offset < x.len() - 1 {
/// let u16_ptr = ptr.add(offset).cast::<u16>();
/// *u16_ptr = 0;
/// } else {
/// // while the pointer can be aligned via `offset`, it would point
/// // outside the allocation
/// }
/// # } }
///
/// assert!(x == [0, 0, 7, 8, 9] || x == [5, 0, 0, 8, 9]);
/// # }
/// ```
#[stable(feature = "align_offset", since = "1.36.0")]
#[rustc_const_unstable(feature = "const_align_offset", issue = "90962")]
Expand Down