1
Fork 0

clippy::perf fixes

single_char_pattern and to_string_in_format_args
This commit is contained in:
Matthias Krüger 2022-02-03 21:44:47 +01:00
parent 4e8fb743cc
commit de2abc29e9
4 changed files with 9 additions and 9 deletions

View file

@ -219,7 +219,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
match result { match result {
Err(e) => { Err(e) => {
self.config.sess.fatal(&format!("Error calling dlltool: {}", e.to_string())); self.config.sess.fatal(&format!("Error calling dlltool: {}", e));
} }
Ok(output) if !output.status.success() => self.config.sess.fatal(&format!( Ok(output) if !output.status.success() => self.config.sess.fatal(&format!(
"Dlltool could not create import library: {}\n{}", "Dlltool could not create import library: {}\n{}",

View file

@ -126,7 +126,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
// If the user tried to use a key="value" flag, but is missing the quotes, provide // If the user tried to use a key="value" flag, but is missing the quotes, provide
// a hint about how to resolve this. // a hint about how to resolve this.
if s.contains("=") && !s.contains("=\"") && !s.ends_with("\"") { if s.contains('=') && !s.contains("=\"") && !s.ends_with('"') {
error!(concat!( error!(concat!(
r#"expected `key` or `key="value"`, ensure escaping is appropriate"#, r#"expected `key` or `key="value"`, ensure escaping is appropriate"#,
r#" for your shell, try 'key="value"' or key=\"value\""# r#" for your shell, try 'key="value"' or key=\"value\""#

View file

@ -1702,11 +1702,11 @@ impl<'a> Parser<'a> {
// Try to lowercase the prefix if it's a valid base prefix. // Try to lowercase the prefix if it's a valid base prefix.
fn fix_base_capitalisation(s: &str) -> Option<String> { fn fix_base_capitalisation(s: &str) -> Option<String> {
if let Some(stripped) = s.strip_prefix("B") { if let Some(stripped) = s.strip_prefix('B') {
Some(format!("0b{stripped}")) Some(format!("0b{stripped}"))
} else if let Some(stripped) = s.strip_prefix("O") { } else if let Some(stripped) = s.strip_prefix('O') {
Some(format!("0o{stripped}")) Some(format!("0o{stripped}"))
} else if let Some(stripped) = s.strip_prefix("X") { } else if let Some(stripped) = s.strip_prefix('X') {
Some(format!("0x{stripped}")) Some(format!("0x{stripped}"))
} else { } else {
None None

View file

@ -1587,10 +1587,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) { ) {
let len = remaining_fields.len(); let len = remaining_fields.len();
let mut displayable_field_names = let mut displayable_field_names: Vec<&str> =
remaining_fields.keys().map(|ident| ident.as_str()).collect::<Vec<_>>(); remaining_fields.keys().map(|ident| ident.as_str()).collect();
// sorting &str primitives here, sort_unstable is ok
displayable_field_names.sort(); displayable_field_names.sort_unstable();
let mut truncated_fields_error = String::new(); let mut truncated_fields_error = String::new();
let remaining_fields_names = match &displayable_field_names[..] { let remaining_fields_names = match &displayable_field_names[..] {