-
Notifications
You must be signed in to change notification settings - Fork 14k
Apply clippy suggestions for rustc and core #89709
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ const BASE_64: &[u8; MAX_BASE as usize] = | |
|
|
||
| #[inline] | ||
| pub fn push_str(mut n: u128, base: usize, output: &mut String) { | ||
| debug_assert!(base >= 2 && base <= MAX_BASE); | ||
| debug_assert!((2..=MAX_BASE).contains(&base)); | ||
|
||
| let mut s = [0u8; 128]; | ||
| let mut index = 0; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -257,11 +257,7 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> { | |
| pub fn remove(&mut self, key: &K) -> Option<V> { | ||
| match self { | ||
| SsoHashMap::Array(array) => { | ||
| if let Some(index) = array.iter().position(|(k, _v)| k == key) { | ||
| Some(array.swap_remove(index).1) | ||
| } else { | ||
| None | ||
| } | ||
| array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index).1) | ||
|
Contributor
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. I know other data structures have some instances of open coding
Member
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. I would worry less about bloat and more about that instance of |
||
| } | ||
| SsoHashMap::Map(map) => map.remove(key), | ||
| } | ||
|
|
@@ -272,11 +268,7 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> { | |
| pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)> { | ||
| match self { | ||
| SsoHashMap::Array(array) => { | ||
| if let Some(index) = array.iter().position(|(k, _v)| k == key) { | ||
| Some(array.swap_remove(index)) | ||
| } else { | ||
| None | ||
| } | ||
| array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index)) | ||
| } | ||
| SsoHashMap::Map(map) => map.remove_entry(key), | ||
| } | ||
|
|
@@ -423,14 +415,14 @@ impl<K, V> IntoIterator for SsoHashMap<K, V> { | |
|
|
||
| /// adapts Item of array reference iterator to Item of hashmap reference iterator. | ||
| #[inline(always)] | ||
| fn adapt_array_ref_it<K, V>(pair: &'a (K, V)) -> (&'a K, &'a V) { | ||
| fn adapt_array_ref_it<K, V>(pair: &(K, V)) -> (&K, &V) { | ||
| let (a, b) = pair; | ||
| (a, b) | ||
| } | ||
|
|
||
| /// adapts Item of array mut reference iterator to Item of hashmap mut reference iterator. | ||
| #[inline(always)] | ||
| fn adapt_array_mut_it<K, V>(pair: &'a mut (K, V)) -> (&'a K, &'a mut V) { | ||
| fn adapt_array_mut_it<K, V>(pair: &mut (K, V)) -> (&K, &mut V) { | ||
| let (a, b) = pair; | ||
| (a, b) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -349,14 +349,14 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> { | |
| ) -> Result<proc_macro2::TokenStream, SessionDiagnosticDeriveError> { | ||
| let field_binding = &info.binding.binding; | ||
|
|
||
| let option_ty = option_inner_ty(&info.ty); | ||
| let option_ty = option_inner_ty(info.ty); | ||
|
|
||
| let generated_code = self.generate_non_option_field_code( | ||
| attr, | ||
| FieldInfo { | ||
| vis: info.vis, | ||
| binding: info.binding, | ||
| ty: option_ty.unwrap_or(&info.ty), | ||
| ty: option_ty.unwrap_or(info.ty), | ||
| span: info.span, | ||
| }, | ||
| )?; | ||
|
|
@@ -388,7 +388,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> { | |
| let formatted_str = self.build_format(&s.value(), attr.span()); | ||
| match name { | ||
| "message" => { | ||
| if type_matches_path(&info.ty, &["rustc_span", "Span"]) { | ||
| if type_matches_path(info.ty, &["rustc_span", "Span"]) { | ||
|
||
| quote! { | ||
| #diag.set_span(*#field_binding); | ||
| #diag.set_primary_message(#formatted_str); | ||
|
|
@@ -401,7 +401,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> { | |
| } | ||
| } | ||
| "label" => { | ||
| if type_matches_path(&info.ty, &["rustc_span", "Span"]) { | ||
| if type_matches_path(info.ty, &["rustc_span", "Span"]) { | ||
| quote! { | ||
| #diag.span_label(*#field_binding, #formatted_str); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.