Skip to content

Commit f0648cb

Browse files
committed
De-implement several traits for LocalInternedString.
`Clone` and `Copy` haven't been needed for some time. `Eq`, `PartialOrd`, `Ord` are no longer necessary now that `Symbol` is ordered by chars rather than index.
1 parent 35d0bea commit f0648cb

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

src/librustc/middle/lib_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl LibFeatures {
3232
let mut all_features: Vec<_> = self.stable.iter().map(|(f, s)| (*f, Some(*s)))
3333
.chain(self.unstable.iter().map(|f| (*f, None)))
3434
.collect();
35-
all_features.sort_unstable_by_key(|f| f.0.as_str());
35+
all_features.sort_unstable_by_key(|f| f.0);
3636
all_features
3737
}
3838
}

src/librustc_resolve/diagnostics.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::cmp::Reverse;
2-
31
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
42
use log::debug;
53
use rustc::bug;
@@ -496,7 +494,7 @@ impl<'a> Resolver<'a> {
496494
});
497495

498496
// Make sure error reporting is deterministic.
499-
suggestions.sort_by_cached_key(|suggestion| suggestion.candidate.as_str());
497+
suggestions.sort_by_key(|suggestion| suggestion.candidate);
500498

501499
match find_best_match_for_name(
502500
suggestions.iter().map(|suggestion| &suggestion.candidate),
@@ -798,7 +796,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
798796
// 2) `std` suggestions before `core` suggestions.
799797
let mut extern_crate_names =
800798
self.r.extern_prelude.iter().map(|(ident, _)| ident.name).collect::<Vec<_>>();
801-
extern_crate_names.sort_by_key(|name| Reverse(name.as_str()));
799+
extern_crate_names.sort();
800+
extern_crate_names.reverse();
802801

803802
for name in extern_crate_names.into_iter() {
804803
// Replace first ident with a crate name and check if that is valid.

src/librustc_resolve/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ impl<'a> LateResolutionVisitor<'a, '_> {
618618

619619
let name = path[path.len() - 1].ident.name;
620620
// Make sure error reporting is deterministic.
621-
names.sort_by_cached_key(|suggestion| suggestion.candidate.as_str());
621+
names.sort_by_key(|suggestion| suggestion.candidate);
622622

623623
match find_best_match_for_name(
624624
names.iter().map(|suggestion| &suggestion.candidate),

src/librustc_typeck/check/expr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1182,9 +1182,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11821182

11831183
let mut displayable_field_names = remaining_fields
11841184
.keys()
1185-
.map(|ident| ident.as_str())
1185+
.map(|ident| ident.name)
11861186
.collect::<Vec<_>>();
1187-
11881187
displayable_field_names.sort();
11891188

11901189
let truncated_fields_error = if len <= 3 {

src/librustc_typeck/check/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
958958
.collect();
959959

960960
// Sort them by the name so we have a stable result.
961-
names.sort_by_cached_key(|n| n.as_str());
961+
names.sort_by_key(|n| n.name);
962962
names
963963
}
964964

src/libsyntax_pos/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,6 @@ fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
11281128
// FIXME: ensure that the interner outlives any thread which uses
11291129
// `LocalInternedString`, by creating a new thread right after constructing the
11301130
// interner.
1131-
#[derive(Clone, Copy, Eq, PartialOrd, Ord)]
11321131
pub struct LocalInternedString {
11331132
string: &'static str,
11341133
}

0 commit comments

Comments
 (0)