Skip to content

Conversation

steveklabnik
Copy link
Contributor

@steveklabnik steveklabnik commented Jan 7, 2017

r? @eddyb @bluss , who I asked about this on IRC

@@ -74,7 +74,10 @@ pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
///
/// # Safety
///
/// This is only unsafe because it accepts a raw pointer.
/// This function copies the memory through the raw pointers passed to it
/// as arguments, which means they will be dereferenced.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the warning is clear enough. I'd state something like:

"If the pointer is null or points to invalid data, the program will crash or have an undefined behaviour."

It seems very important to me to indicate the consequences.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already defined at the language level; repeating it here feels extraneous.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To say that it reads and writes through the raw pointers should be enough.

@steveklabnik
Copy link
Contributor Author

@bluss updated

Copy link
Member

@eddyb eddyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. r=me if @bluss is satisfied.

@bluss
Copy link
Contributor

bluss commented Jan 7, 2017

@bors r=eddyb

@bors
Copy link
Collaborator

bors commented Jan 7, 2017

📌 Commit 95fe6ac has been approved by eddyb

@bors
Copy link
Collaborator

bors commented Jan 9, 2017

⌛ Testing commit 95fe6ac with merge aee21e2...

bors added a commit that referenced this pull request Jan 9, 2017
Improve safety warning on ptr::swap

r? @eddyb @bluss , who I asked about this on IRC
@bors
Copy link
Collaborator

bors commented Jan 9, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing aee21e2 to master...

@bors bors merged commit 95fe6ac into rust-lang:master Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants