-
Notifications
You must be signed in to change notification settings - Fork 346
Fix up some issues flagged by clippy #294
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
let tmp = pieces[piece_pointer]; | ||
pieces[piece_pointer] = pieces[compress_pointer + swaps - 1]; | ||
pieces[compress_pointer + swaps - 1] = tmp; | ||
pieces.swap(piece_pointer, compress_pointer + swaps - 1); |
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.
Possibly out of scope of this PR, but I think both parameters would benefit from some bound checking to ensure no index underflow/overflow will induce a panic here at runtime.
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.
Could you make a separate issue for this? Thanks!
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.
Moved to #334.
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.
Unfortunately this still appears as part of the clippy related changes.
Can you move this into a new branch?
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 is a clippy related change. Bounds checking is a separate issue being tracked in #334.
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.
Cool! Then this PR looks OK to merge to me 👍
What is the minimum Rust version that should be supported by rust-url? |
tests/data.rs
Outdated
@@ -26,7 +26,7 @@ fn check_invariants(url: &Url) { | |||
} | |||
|
|||
|
|||
fn run_parsing(input: String, base: String, expected: Result<ExpectedAttributes, ()>) { | |||
fn run_parsing(input: &String, base: &String, expected: Result<ExpectedAttributes, ()>) { |
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.
Why not use &str
instead of &String
?
@@ -1031,7 +1031,7 @@ impl<'a> Parser<'a> { | |||
} | |||
} | |||
None => return Ok((None, None)), | |||
_ => panic!("Programming error. parse_query_and_fragment() called without ? or # {:?}") |
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 is strange. Why was the {:?}
there?
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.
I thought this would give a compiler error. Weird.
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.
Indeed. Me too.
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 compiles because the panic!
macro has a special case for use with a single "argument" that by-passes the string formatting system entirely:
https://github.com/rust-lang/rust/blob/a0da1e0653/src/libstd/macros.rs#L43-L49
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.
LGTM overall. I think @vks's comment about &str
should be considered though.
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.
Ditto @vks, those &String
should be &str
instead. LGTM otherwise.
@vks + @Hoverbear + @dtolnay: I've switched it from &String to &str. Good to go? |
Great, looks good to me! |
Looks good 😄 These changes make the code nicer. Except that one change in src/host.rs that is more than pure style cleanup. Not sure if maintainers want that in a new branch or if it is OK as is. Thanks Daniel |
We have multiple good reviews so lets merge! |
☔ The latest upstream changes (presumably #342) made this pull request unmergeable. Please resolve the merge conflicts. |
@vks I’m not really keeping track of a minimum version. We’ll figure it out when/if someone complains :) This looks very nice. Thank you all! @bors-servo r+ |
📌 Commit 78b4f57 has been approved by |
Fix up some issues flagged by clippy <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/294) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
This change is