Rollup merge of #60972 - RalfJung:volatile, r=alexcrichton

remove confusing remarks about mixed volatile and non-volatile accesses

These comments were originally added by @ecstatic-morse in 911d35f0bf and then later edited by me. The intention, I think, was to make sure people do both their reads and writes with these methods if the affected memory really is used for communication with external devices.

However, [people read this as saying that mixed volatile/non-volatile accesses are UB](https://github.com/rust-lang/rust/issues/58599#issuecomment-493791130), which -- to my knowledge -- they are not. So better remove this.

Cc @rkruppe @rust-lang/wg-unsafe-code-guidelines
This commit is contained in:
Mazdak Farrokhzad 2019-05-20 23:03:08 +02:00 committed by GitHub
commit 44b5d4deb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 6 deletions

View File

@ -810,9 +810,6 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
/// to not be elided or reordered by the compiler across other volatile
/// operations.
///
/// Memory accessed with `read_volatile` or [`write_volatile`] should not be
/// accessed with non-volatile operations.
///
/// [`write_volatile`]: ./fn.write_volatile.html
///
/// # Notes
@ -881,9 +878,6 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
/// to not be elided or reordered by the compiler across other volatile
/// operations.
///
/// Memory accessed with [`read_volatile`] or `write_volatile` should not be
/// accessed with non-volatile operations.
///
/// `write_volatile` does not drop the contents of `dst`. This is safe, but it
/// could leak allocations or resources, so care should be taken not to overwrite
/// an object that should be dropped.