-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustfmt librand/distributions #29054
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (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. 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. |
@mseri in general, rustfmt does not try to align tokens between sequential items, for example the |
@bors: r+ rollup Thanks for the PR, this looks great! |
📌 Commit 84b77f1 has been approved by |
Ok. Thanks for the explanations. Should I submit a PR to the style guide adding some of the missing style guidelines that I saw while doing these rustfmt (and the ones in preparation)? |
You can if you like, the style guide is lacking a lot of the detail of rustfmt. I expect we'll revamp it properly at some point in the future |
r? @nrc I was wondering, what is the standard for pattern matching in presence of guards? I liked more the original alignment of `distributions/gamma.rs` line 91 than the new one.
@@ -103,7 +107,8 @@ impl<'a, T: Clone> WeightedChoice<'a, T> { | |||
/// - the total weight is larger than a `usize` can contain. | |||
pub fn new(items: &'a mut [Weighted<T>]) -> WeightedChoice<'a, T> { | |||
// strictly speaking, this is subsumed by the total weight == 0 case | |||
assert!(!items.is_empty(), "WeightedChoice::new called with no items"); | |||
assert!(!items.is_empty(), |
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 getting split into two lines makes little sense @nrc.
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.
We split when the internals of a function call or function-like macro is more than a heuristic limit (I think 60 chars). Mostly this works well. Occasionally (like here) it seems a bit over the top. I expect its a heuristic we'll polish as time goes by.
@steveklabnik there is a typo that I fixed this morning. My apologies for that, I ran the tests on the wrong patch branch. Additionally, there is this:
@nrc should I add the feature attrubute or remove the skips? For the vectors refactored there rustfmt should not be executed, or one ends up with an immensely long unreadable file. |
I think we should just get rid of those rustfmt_skip, is there any other way we can tell rustfmt to skip the file? |
You need to add #![feature(custom_attribute)] and #![allow(unused_attributes)] to the crate root to pass tests. The skip attribute is the only way to get rustfmt to skip a file or item. |
Sorry, I messed up with this branch. I am closing the pull request - cleaning everything and resubmitting it properly. |
r? @nrc
I was wondering, what is the standard for pattern matching in presence of guards? I liked more the original alignment of
distributions/gamma.rs
line 91 than the new one.