Convert sort_by to sort_by_cached_key
This commit is contained in:
parent
5cd0504d10
commit
57eedbaaf8
3 changed files with 5 additions and 9 deletions
|
@ -23,6 +23,7 @@
|
|||
#![cfg_attr(unix, feature(libc))]
|
||||
#![feature(quote)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(slice_sort_by_cached_key)]
|
||||
#![feature(set_stdio)]
|
||||
#![feature(rustc_stack_internals)]
|
||||
|
||||
|
@ -83,7 +84,6 @@ use rustc_trans_utils::trans_crate::TransCrate;
|
|||
use serialize::json::ToJson;
|
||||
|
||||
use std::any::Any;
|
||||
use std::cmp::Ordering::Equal;
|
||||
use std::cmp::max;
|
||||
use std::default::Default;
|
||||
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
|
||||
|
@ -1177,13 +1177,8 @@ Available lint options:
|
|||
|
||||
fn sort_lints(sess: &Session, lints: Vec<(&'static Lint, bool)>) -> Vec<&'static Lint> {
|
||||
let mut lints: Vec<_> = lints.into_iter().map(|(x, _)| x).collect();
|
||||
lints.sort_by(|x: &&Lint, y: &&Lint| {
|
||||
match x.default_level(sess).cmp(&y.default_level(sess)) {
|
||||
// The sort doesn't case-fold but it's doubtful we care.
|
||||
Equal => x.name.cmp(y.name),
|
||||
r => r,
|
||||
}
|
||||
});
|
||||
lints.sort_by_cached_key(|x: &&Lint| (x.default_level(sess), x.name));
|
||||
lints
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#![feature(unicode)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(slice_sort_by_cached_key)]
|
||||
#![feature(non_exhaustive)]
|
||||
#![feature(const_atomic_usize_new)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
|
|
@ -689,7 +689,7 @@ impl<'a> Parser<'a> {
|
|||
.chain(inedible.iter().map(|x| TokenType::Token(x.clone())))
|
||||
.chain(self.expected_tokens.iter().cloned())
|
||||
.collect::<Vec<_>>();
|
||||
expected.sort_by(|a, b| a.to_string().cmp(&b.to_string()));
|
||||
expected.sort_by_cached_key(|x| x.to_string());
|
||||
expected.dedup();
|
||||
let expect = tokens_to_string(&expected[..]);
|
||||
let actual = self.this_token_to_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue