Skip to content

Commit 63c4d1e

Browse files
committed
remove PartialOrd and Ord impls, and sort by the candidate name str
1 parent 9e75730 commit 63c4d1e

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

compiler/rustc_hir/src/def.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::array::IntoIter;
1111
use std::fmt::Debug;
1212

1313
/// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct.
14-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)]
14+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
1515
#[derive(HashStable_Generic)]
1616
pub enum CtorOf {
1717
/// This `DefKind::Ctor` is a synthesized constructor of a tuple or unit struct.
@@ -21,7 +21,7 @@ pub enum CtorOf {
2121
}
2222

2323
/// What kind of constructor something is.
24-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)]
24+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
2525
#[derive(HashStable_Generic)]
2626
pub enum CtorKind {
2727
/// Constructor function automatically created by a tuple struct/variant.
@@ -33,7 +33,7 @@ pub enum CtorKind {
3333
}
3434

3535
/// An attribute that is not a macro; e.g., `#[inline]` or `#[rustfmt::skip]`.
36-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)]
36+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
3737
#[derive(HashStable_Generic)]
3838
pub enum NonMacroAttrKind {
3939
/// Single-segment attribute defined by the language (`#[inline]`)
@@ -50,7 +50,7 @@ pub enum NonMacroAttrKind {
5050
}
5151

5252
/// What kind of definition something is; e.g., `mod` vs `struct`.
53-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)]
53+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
5454
#[derive(HashStable_Generic)]
5555
pub enum DefKind {
5656
// Type namespace
@@ -297,7 +297,7 @@ impl DefKind {
297297
/// - the call to `str_to_string` will resolve to [`Res::Def`], with the [`DefId`]
298298
/// pointing to the definition of `str_to_string` in the current crate.
299299
//
300-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)]
300+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
301301
#[derive(HashStable_Generic)]
302302
pub enum Res<Id = hir::HirId> {
303303
/// Definition having a unique ID (`DefId`), corresponds to something defined in user code.

compiler/rustc_resolve/src/diagnostics.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_ast::ptr::P;
44
use rustc_ast::visit::{self, Visitor};
55
use rustc_ast::{self as ast, Crate, ItemKind, ModKind, NodeId, Path, CRATE_NODE_ID};
66
use rustc_ast_pretty::pprust;
7-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
7+
use rustc_data_structures::fx::FxHashSet;
88
use rustc_errors::struct_span_err;
99
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
1010
use rustc_feature::BUILTIN_ATTRIBUTES;
@@ -1886,20 +1886,15 @@ impl<'a> Resolver<'a> {
18861886
}))
18871887
}
18881888

1889-
// We sort names here to ensure that the suggestion is deterministic.
1890-
// (Notice that there may be a pair of TypoSuggestions whose Symbols
1891-
// are same but Res are different.)
1892-
names.sort_by_key(|name| (name.candidate, name.res));
1893-
names.dedup();
1889+
// Make sure the suggestion is deterministic.
1890+
names.sort_by(|a, b| a.candidate.as_str().partial_cmp(b.candidate.as_str()).unwrap());
18941891
let symbols = names.iter().map(|sugg| sugg.candidate).collect::<Vec<Symbol>>();
1895-
let typo_suggestions: FxHashMap<Symbol, TypoSuggestion> =
1896-
names.into_iter().map(|typo_sugg| (typo_sugg.candidate, typo_sugg)).collect();
18971892

18981893
match find_best_match_for_name(&symbols, ident, None) {
18991894
Some(sugg) if sugg == ident => None,
19001895
sugg => sugg,
19011896
}
1902-
.map(|sugg| typo_suggestions.get(&sugg).unwrap().clone())
1897+
.and_then(|sugg| names.into_iter().find(|name| name.candidate == sugg))
19031898
}
19041899

19051900
pub(crate) fn report_path_resolution_error(

compiler/rustc_span/src/hygiene.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ impl ExpnKind {
10731073
}
10741074

10751075
/// The kind of macro invocation or definition.
1076-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)]
1076+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
10771077
#[derive(HashStable_Generic)]
10781078
pub enum MacroKind {
10791079
/// A bang macro `foo!()`.

src/test/ui/pattern/pattern-error-continue.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | E::V => {}
55
| ^
66
| |
77
| use of undeclared type `E`
8-
| help: there is a trait with a similar name: `Eq`
8+
| help: there is an enum with a similar name: `A`
99

1010
error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D`
1111
--> $DIR/pattern-error-continue.rs:18:9

0 commit comments

Comments
 (0)