diff options
| author | bors <bors@rust-lang.org> | 2021-05-05 17:45:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-05 17:45:41 +0000 |
| commit | bacf770f2983a52f31e3537db5f0fe1ef2eaa874 (patch) | |
| tree | f35a4695fe4ea4a79e83c87b0fe6c8ea2e80f687 /library/std | |
| parent | 342db70ae4ecc3cd17e4fa6497f0a8d9534ccfeb (diff) | |
| parent | 2cbcfae6548e08fe079ae0b7db0d97ec30e006d8 (diff) | |
| download | rust-bacf770f2983a52f31e3537db5f0fe1ef2eaa874.tar.gz rust-bacf770f2983a52f31e3537db5f0fe1ef2eaa874.zip | |
Auto merge of #84956 - RalfJung:rollup-m70mx2n, r=RalfJung
Rollup of 11 pull requests Successful merges: - #83553 (Update `ptr` docs with regards to `ptr::addr_of!`) - #84183 (Update RELEASES.md for 1.52.0) - #84709 (Add doc alias for `chdir` to `std::env::set_current_dir`) - #84803 (Reduce duplication in `impl_dep_tracking_hash` macros) - #84808 (Account for unsatisfied bounds in E0599) - #84843 (use else if in std library ) - #84865 (rustbuild: Pass a `threads` flag that works to windows-gnu lld) - #84878 (Clarify documentation for `[T]::contains`) - #84882 (platform-support: Center the contents of the `std` and `host` columns) - #84903 (Remove `rustc_middle::mir::interpret::CheckInAllocMsg::NullPointerTest`) - #84913 (Do not ICE on invalid const param) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/env.rs | 1 | ||||
| -rw-r--r-- | library/std/src/primitive_docs.rs | 22 |
2 files changed, 22 insertions, 1 deletions
diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 821e7d4cfe7..11d052dae9e 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -61,6 +61,7 @@ pub fn current_dir() -> io::Result<PathBuf> { /// assert!(env::set_current_dir(&root).is_ok()); /// println!("Successfully changed working directory to {}!", root.display()); /// ``` +#[doc(alias = "chdir")] #[stable(feature = "env", since = "1.0.0")] pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { os_imp::chdir(path.as_ref()) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index cd6b0b2d7ee..96ab32104ea 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -445,7 +445,27 @@ mod prim_unit {} /// Note that here the call to [`drop`] is for clarity - it indicates /// that we are done with the given value and it should be destroyed. /// -/// ## 3. Get it from C. +/// ## 3. Create it using `ptr::addr_of!` +/// +/// Instead of coercing a reference to a raw pointer, you can use the macros +/// [`ptr::addr_of!`] (for `*const T`) and [`ptr::addr_of_mut!`] (for `*mut T`). +/// These macros allow you to create raw pointers to fields to which you cannot +/// create a reference (without causing undefined behaviour), such as an +/// unaligned field. This might be necessary if packed structs or uninitialized +/// memory is involved. +/// +/// ``` +/// #[derive(Debug, Default, Copy, Clone)] +/// #[repr(C, packed)] +/// struct S { +/// aligned: u8, +/// unaligned: u32, +/// } +/// let s = S::default(); +/// let p = std::ptr::addr_of!(s.unaligned); // not allowed with coercion +/// ``` +/// +/// ## 4. Get it from C. /// /// ``` /// # #![feature(rustc_private)] |
