mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
use sort_unstable to sort primitive types
It's not important to retain original order if we have &[1, 1, 2, 3] for example. clippy::stable_sort_primitive
This commit is contained in:
parent
d92155bf6a
commit
b4935e0726
@ -103,6 +103,7 @@ fn find_match_by_sorted_words<'a>(iter_names: Vec<&'a Symbol>, lookup: &str) ->
|
|||||||
|
|
||||||
fn sort_by_words(name: &str) -> String {
|
fn sort_by_words(name: &str) -> String {
|
||||||
let mut split_words: Vec<&str> = name.split('_').collect();
|
let mut split_words: Vec<&str> = name.split('_').collect();
|
||||||
split_words.sort();
|
// We are sorting primitive &strs and can use unstable sort here
|
||||||
|
split_words.sort_unstable();
|
||||||
split_words.join("_")
|
split_words.join("_")
|
||||||
}
|
}
|
||||||
|
@ -1121,7 +1121,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
// features. We check that at least one type is available for
|
// features. We check that at least one type is available for
|
||||||
// the current target.
|
// the current target.
|
||||||
let reg_class = reg.reg_class();
|
let reg_class = reg.reg_class();
|
||||||
let mut required_features = vec![];
|
let mut required_features: Vec<&str> = vec![];
|
||||||
for &(_, feature) in reg_class.supported_types(asm_arch) {
|
for &(_, feature) in reg_class.supported_types(asm_arch) {
|
||||||
if let Some(feature) = feature {
|
if let Some(feature) = feature {
|
||||||
if self.sess.target_features.contains(&Symbol::intern(feature)) {
|
if self.sess.target_features.contains(&Symbol::intern(feature)) {
|
||||||
@ -1135,7 +1135,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
required_features.sort();
|
// We are sorting primitive strs here and can use unstable sort here
|
||||||
|
required_features.sort_unstable();
|
||||||
required_features.dedup();
|
required_features.dedup();
|
||||||
match &required_features[..] {
|
match &required_features[..] {
|
||||||
[] => {}
|
[] => {}
|
||||||
|
@ -212,7 +212,8 @@ impl EarlyLintPass for NonAsciiIdents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ch_list.sort();
|
// We sort primitive chars here and can use unstable sort
|
||||||
|
ch_list.sort_unstable();
|
||||||
ch_list.dedup();
|
ch_list.dedup();
|
||||||
lint_reports.insert((sp, ch_list), augment_script_set);
|
lint_reports.insert((sp, ch_list), augment_script_set);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,9 @@ pub fn merge_codegen_units<'tcx>(
|
|||||||
|
|
||||||
// Sort the names, so things are deterministic and easy to
|
// Sort the names, so things are deterministic and easy to
|
||||||
// predict.
|
// predict.
|
||||||
cgu_contents.sort();
|
|
||||||
|
// We are sorting primitive &strs here so we can use unstable sort
|
||||||
|
cgu_contents.sort_unstable();
|
||||||
|
|
||||||
(current_cgu_name, cgu_contents.join("--"))
|
(current_cgu_name, cgu_contents.join("--"))
|
||||||
})
|
})
|
||||||
|
@ -230,8 +230,8 @@ fn get_arm_identity_info<'a, 'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// We sort primitive usize here so we can use unstable sort
|
||||||
nop_stmts.sort();
|
nop_stmts.sort_unstable();
|
||||||
|
|
||||||
// Use one of the statements we're going to discard between the point
|
// Use one of the statements we're going to discard between the point
|
||||||
// where the storage location for the variant field becomes live and
|
// where the storage location for the variant field becomes live and
|
||||||
|
@ -4266,11 +4266,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<usize>>();
|
||||||
|
|
||||||
// Both checked and coerced types could have matched, thus we need to remove
|
// Both checked and coerced types could have matched, thus we need to remove
|
||||||
// duplicates.
|
// duplicates.
|
||||||
referenced_in.sort();
|
|
||||||
|
// We sort primitive type usize here and can use unstable sort
|
||||||
|
referenced_in.sort_unstable();
|
||||||
referenced_in.dedup();
|
referenced_in.dedup();
|
||||||
|
|
||||||
if let (Some(ref_in), None) = (referenced_in.pop(), referenced_in.pop()) {
|
if let (Some(ref_in), None) = (referenced_in.pop(), referenced_in.pop()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user