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
Fix ignored clippy lints #12160
Merged
Merged
Fix ignored clippy lints #12160
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ extern crate doc_comment; | |
doctest!("../README.md"); | ||
|
||
use std::cmp; | ||
use std::cmp::Ordering; | ||
use std::error::Error; | ||
use std::fmt; | ||
use std::fs; | ||
|
@@ -346,7 +347,6 @@ impl Error for GlobError { | |
self.error.description() | ||
} | ||
|
||
#[allow(unknown_lints, bare_trait_objects)] | ||
fn cause(&self) -> Option<&dyn Error> { | ||
Some(&self.error) | ||
} | ||
|
@@ -505,7 +505,6 @@ impl Iterator for Paths { | |
|
||
/// A pattern parsing error. | ||
#[derive(Debug)] | ||
#[allow(missing_copy_implementations)] | ||
pub struct PatternError { | ||
/// The approximate character index of where the error occurred. | ||
pub pos: usize, | ||
|
@@ -630,53 +629,58 @@ impl Pattern { | |
|
||
let count = i - old; | ||
|
||
#[allow(clippy::comparison_chain)] | ||
if count > 2 { | ||
return Err(PatternError { | ||
pos: old + 2, | ||
msg: ERROR_WILDCARDS, | ||
}); | ||
} else if count == 2 { | ||
// ** can only be an entire path component | ||
// i.e. a/**/b is valid, but a**/b or a/**b is not | ||
// invalid matches are treated literally | ||
let is_valid = if i == 2 || path::is_separator(chars[i - count - 1]) { | ||
// it ends in a '/' | ||
if i < chars.len() && path::is_separator(chars[i]) { | ||
i += 1; | ||
true | ||
// or the pattern ends here | ||
// this enables the existing globbing mechanism | ||
} else if i == chars.len() { | ||
true | ||
// `**` ends in non-separator | ||
match count.cmp(&2) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not quite sure if this monster gets much more readable. maybe worth pullilng the |
||
Ordering::Greater => { | ||
return Err(PatternError { | ||
pos: old + 2, | ||
msg: ERROR_WILDCARDS, | ||
}); | ||
} | ||
Ordering::Equal => { | ||
// ** can only be an entire path component | ||
// i.e. a/**/b is valid, but a**/b or a/**b is not | ||
// invalid matches are treated literally | ||
let is_valid = if i == 2 || path::is_separator(chars[i - count - 1]) { | ||
// it ends in a '/' | ||
if i < chars.len() && path::is_separator(chars[i]) { | ||
i += 1; | ||
true | ||
// or the pattern ends here | ||
// this enables the existing globbing mechanism | ||
} else if i == chars.len() { | ||
true | ||
// `**` ends in non-separator | ||
} else { | ||
return Err(PatternError { | ||
pos: i, | ||
msg: ERROR_RECURSIVE_WILDCARDS, | ||
}); | ||
} | ||
// `**` begins with non-separator | ||
} else { | ||
return Err(PatternError { | ||
pos: i, | ||
pos: old - 1, | ||
msg: ERROR_RECURSIVE_WILDCARDS, | ||
}); | ||
} | ||
// `**` begins with non-separator | ||
} else { | ||
return Err(PatternError { | ||
pos: old - 1, | ||
msg: ERROR_RECURSIVE_WILDCARDS, | ||
}); | ||
}; | ||
}; | ||
|
||
if is_valid { | ||
// collapse consecutive AnyRecursiveSequence to a | ||
// single one | ||
if is_valid { | ||
// collapse consecutive AnyRecursiveSequence to a | ||
// single one | ||
|
||
let tokens_len = tokens.len(); | ||
let tokens_len = tokens.len(); | ||
|
||
if !(tokens_len > 1 && tokens[tokens_len - 1] == AnyRecursiveSequence) { | ||
is_recursive = true; | ||
tokens.push(AnyRecursiveSequence); | ||
if !(tokens_len > 1 | ||
&& tokens[tokens_len - 1] == AnyRecursiveSequence) | ||
{ | ||
is_recursive = true; | ||
tokens.push(AnyRecursiveSequence); | ||
} | ||
} | ||
} | ||
} else { | ||
tokens.push(AnySequence); | ||
Ordering::Less => { | ||
tokens.push(AnySequence); | ||
} | ||
} | ||
} | ||
'[' => { | ||
|
@@ -1051,7 +1055,6 @@ fn chars_eq(a: char, b: char, case_sensitive: bool) -> bool { | |
} | ||
|
||
/// Configuration options to modify the behaviour of `Pattern::matches_with(..)`. | ||
#[allow(missing_copy_implementations)] | ||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct MatchOptions { | ||
/// Whether or not patterns should be matched in a case-sensitive manner. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ah they made that generally allow again. I think this is only an undefined resolution for float. So the code below could be a safe
clamp
, right?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.
Ah the
.max
/.min
solution never panics.