Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/filepatterns.rs @ 50003:e98fd81bb151
rust-clippy: fix most warnings in `hg-core`
All of these are simple changes that for the most part are clear improvements
and the rest are at most equivalent.
The remaining warnings have to be fixed either with a bigger refactor like for
the nested "revlog" module, or in the dependency `bytes-cast`, which we own.
This will be done sometime in the future.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 09 Jan 2023 19:18:43 +0100 |
parents | ccb6cfb0f2c0 |
children | 1c31b343e514 |
line wrap: on
line diff
--- a/rust/hg-core/src/filepatterns.rs Mon Jan 09 19:14:14 2023 +0100 +++ b/rust/hg-core/src/filepatterns.rs Mon Jan 09 19:18:43 2023 +0100 @@ -313,7 +313,7 @@ PatternSyntax::RootGlob | PatternSyntax::Path | PatternSyntax::RelGlob - | PatternSyntax::RootFiles => normalize_path_bytes(&pattern), + | PatternSyntax::RootFiles => normalize_path_bytes(pattern), PatternSyntax::Include | PatternSyntax::SubInclude => { return Err(PatternError::NonRegexPattern(entry.clone())) } @@ -368,7 +368,7 @@ let mut warnings: Vec<PatternFileWarning> = vec![]; let mut current_syntax = - default_syntax_override.unwrap_or(b"relre:".as_ref()); + default_syntax_override.unwrap_or_else(|| b"relre:".as_ref()); for (line_number, mut line) in lines.split(|c| *c == b'\n').enumerate() { let line_number = line_number + 1; @@ -402,7 +402,7 @@ continue; } - let mut line_syntax: &[u8] = ¤t_syntax; + let mut line_syntax: &[u8] = current_syntax; for (s, rels) in SYNTAXES.iter() { if let Some(rest) = line.drop_prefix(rels) { @@ -418,7 +418,7 @@ } inputs.push(IgnorePattern::new( - parse_pattern_syntax(&line_syntax).map_err(|e| match e { + parse_pattern_syntax(line_syntax).map_err(|e| match e { PatternError::UnsupportedSyntax(syntax) => { PatternError::UnsupportedSyntaxInFile( syntax, @@ -428,7 +428,7 @@ } _ => e, })?, - &line, + line, file_path, )); } @@ -502,7 +502,7 @@ } PatternSyntax::SubInclude => { let mut sub_include = SubInclude::new( - &root_dir, + root_dir, &entry.pattern, &entry.source, )?; @@ -564,11 +564,11 @@ let prefix = canonical_path(root_dir, root_dir, new_root)?; Ok(Self { - prefix: path_to_hg_path_buf(prefix).and_then(|mut p| { + prefix: path_to_hg_path_buf(prefix).map(|mut p| { if !p.is_empty() { p.push_byte(b'/'); } - Ok(p) + p })?, path: path.to_owned(), root: new_root.to_owned(),