Skip to content

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

Merged
merged 7 commits into from
May 20, 2017
Merged

Fix up some issues flagged by clippy #294

merged 7 commits into from
May 20, 2017

Conversation

daniellockyer
Copy link

@daniellockyer daniellockyer commented Apr 19, 2017

This change is Reviewable

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);
Copy link

@lucab lucab May 9, 2017

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.

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!

Copy link

Choose a reason for hiding this comment

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

Moved to #334.

Copy link

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?

Copy link
Contributor

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.

Copy link

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 👍

@vks
Copy link

vks commented May 9, 2017

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, ()>) {
Copy link

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 # {:?}")

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?

Copy link

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.

Choose a reason for hiding this comment

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

Indeed. Me too.

Copy link
Member

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

Copy link

@Hoverbear Hoverbear left a 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.

Copy link
Contributor

@dtolnay dtolnay left a 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.

@daniellockyer
Copy link
Author

daniellockyer commented May 12, 2017

@vks + @Hoverbear + @dtolnay: I've switched it from &String to &str. Good to go?

@vks
Copy link

vks commented May 12, 2017

Great, looks good to me!

@luisbg
Copy link

luisbg commented May 16, 2017

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

@Hoverbear
Copy link

Hoverbear commented May 17, 2017

We have multiple good reviews so lets merge!

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #342) made this pull request unmergeable. Please resolve the merge conflicts.

@SimonSapin
Copy link
Member

@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+

@bors-servo
Copy link
Contributor

📌 Commit 78b4f57 has been approved by SimonSapin

@bors-servo
Copy link
Contributor

⌛ Testing commit 78b4f57 with merge e461e34...

bors-servo pushed a commit that referenced this pull request May 20, 2017
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 -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis
Approved by: SimonSapin
Pushing e461e34 to master...

@bors-servo bors-servo merged commit 78b4f57 into servo:master May 20, 2017
@daniellockyer daniellockyer deleted the clippy-fixes branch May 20, 2017 20:20
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.

8 participants