about summary refs log tree commit diff
path: root/src/librustc_resolve
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-03-30 10:23:27 +0100
committervarkor <github@varkor.com>2018-04-09 16:43:48 +0100
commiteacfb330e65ad7f7a8b6bda4a0bafb09eb361396 (patch)
treebe2ed852a69d1aeb6cddfe01b4d6acd7c0bfbdbe /src/librustc_resolve
parent4b9b70c394e7f341b4016fce4cbf763d404b26f9 (diff)
downloadrust-eacfb330e65ad7f7a8b6bda4a0bafb09eb361396.tar.gz
rust-eacfb330e65ad7f7a8b6bda4a0bafb09eb361396.zip
Convert sort_by_key to sort_by_cached_key
Diffstat (limited to 'src/librustc_resolve')
-rw-r--r--src/librustc_resolve/lib.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 2bf17cd1317..c1a7f20feff 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -14,6 +14,7 @@
 #![deny(warnings)]
 
 #![feature(rustc_diagnostic_macros)]
+#![feature(slice_sort_by_cached_key)]
 
 #[macro_use]
 extern crate log;
@@ -3341,7 +3342,9 @@ impl<'a> Resolver<'a> {
                         let is_mod = |def| match def { Def::Mod(..) => true, _ => false };
                         let mut candidates =
                             self.lookup_import_candidates(name, TypeNS, is_mod);
-                        candidates.sort_by_key(|c| (c.path.segments.len(), c.path.to_string()));
+                        candidates.sort_by_cached_key(|c| {
+                            (c.path.segments.len(), c.path.to_string())
+                        });
                         if let Some(candidate) = candidates.get(0) {
                             format!("Did you mean `{}`?", candidate.path)
                         } else {
@@ -3579,7 +3582,7 @@ impl<'a> Resolver<'a> {
 
         let name = path[path.len() - 1].name;
         // Make sure error reporting is deterministic.
-        names.sort_by_key(|name| name.as_str());
+        names.sort_by_cached_key(|name| name.as_str());
         match find_best_match_for_name(names.iter(), &name.as_str(), None) {
             Some(found) if found != name => Some(found),
             _ => None,