-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add error note to illegal code snippet #37425
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a little update to do and it'll be good.
@@ -61,7 +61,7 @@ write something like this: | |||
|
|||
```rust,ignore | |||
struct Point { | |||
mut x: i32, | |||
mut x: i32, // this causes an error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This causes an error."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied this comment (capitalization, punctuation, spacing) from line 87 of the same file for consistency. The code sample comments in this file (lines 85, 87, and 237-238) are all lower case and without periods (terminating ellipsis at line 237). Formatting is similar in other files, e.g. "mutability.md", "traits.md". Let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yurk. Well, they shouldn't be. If you want you can fix them as well (in this PR or another, as you want).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to confirm as it will affect a bunch of files which are already fairly consistent in their current style.
Here are some examples:
benchmark-tests.md:113
- // note lack of
;(could also use an explicit
return)
+ // Note lack of
;(could also use an explicit
return).
casting-between-types.md:109
- let a = 300 as *const char; // a pointer to location 300
+ let a = 300 as *const char; // A pointer to location 300.
OR as a sentence with predicate:
+ let a = 300 as *const char; // 'a' is a pointer to location 300.
traits.md:422
- // can be called with T == i32
+ // Can be called with T == i32.
traits.md:479
- true // overrides the expected value of is_invalid()
+ true // Overrides the expected value of is_invalid().
choosing-your-guarantees.md:293-296
let guard = mutex.lock();
- // guard dereferences mutably to the inner type
+ // 'guard' dereferences mutably to the inner type.
There's only an empty stub here on the topic: http://aturon.github.io/style/comments.html#code-snippets
Nothing on the topic here: https://github.com/rust-lang-nursery/fmt-rfcs/blob/master/guide/guide.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your proposed changes are far better and it's exactly what I meant.
Thanks! @bors: r+ rollup |
📌 Commit 635ed48 has been approved by |
Add error note to illegal code snippet Mark intentionally invalid code snippet in documentation as such with a comment. Similar comments used elsewhere in this file. r? @steveklabnik
Mark intentionally invalid code snippet in documentation as such with a comment. Similar comments used elsewhere in this file.
r? @steveklabnik