Skip to content

Commit a9f5190

Browse files
committed
remove StructuralEq trait
1 parent 27b4eb9 commit a9f5190

File tree

71 files changed

+192
-583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+192
-583
lines changed

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@ pub fn expand_deriving_eq(
1919
) {
2020
let span = cx.with_def_site_ctxt(span);
2121

22-
let structural_trait_def = TraitDef {
23-
span,
24-
path: path_std!(marker::StructuralEq),
25-
skip_path_as_bound: true, // crucial!
26-
needs_copy_as_bound_if_packed: false,
27-
additional_bounds: Vec::new(),
28-
supports_unions: true,
29-
methods: Vec::new(),
30-
associated_types: Vec::new(),
31-
is_const: false,
32-
};
33-
structural_trait_def.expand(cx, mitem, item, push);
34-
3522
let trait_def = TraitDef {
3623
span,
3724
path: path_std!(cmp::Eq),

compiler/rustc_codegen_cranelift/example/mini_core.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
104104
#[lang = "structural_peq"]
105105
pub trait StructuralPartialEq {}
106106

107-
#[lang = "structural_teq"]
108-
pub trait StructuralEq {}
109-
110107
#[lang = "not"]
111108
pub trait Not {
112109
type Output;

compiler/rustc_codegen_gcc/example/mini_core.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
100100
#[lang = "structural_peq"]
101101
pub trait StructuralPartialEq {}
102102

103-
#[lang = "structural_teq"]
104-
pub trait StructuralEq {}
105-
106103
#[lang = "not"]
107104
pub trait Not {
108105
type Output;

compiler/rustc_codegen_gcc/tests/run/static.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ mod libc {
6060
#[lang = "structural_peq"]
6161
pub trait StructuralPartialEq {}
6262

63-
#[lang = "structural_teq"]
64-
pub trait StructuralEq {}
65-
6663
#[lang = "drop_in_place"]
6764
#[allow(unconditional_recursion)]
6865
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
117117
}
118118
// Trait objects are not allowed in type level constants, as we have no concept for
119119
// resolving their backing type, even if we can do that at const eval time. We may
120-
// hypothetically be able to allow `dyn StructuralEq` trait objects in the future,
120+
// hypothetically be able to allow `dyn StructuralPartialEq` trait objects in the future,
121121
// but it is unclear if this is useful.
122122
ty::Dynamic(..) => Err(ValTreeCreationError::NonSupportedType),
123123

compiler/rustc_hir/src/lang_items.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ language_item_table! {
143143
Unsize, sym::unsize, unsize_trait, Target::Trait, GenericRequirement::Minimum(1);
144144
/// Trait injected by `#[derive(PartialEq)]`, (i.e. "Partial EQ").
145145
StructuralPeq, sym::structural_peq, structural_peq_trait, Target::Trait, GenericRequirement::None;
146-
/// Trait injected by `#[derive(Eq)]`, (i.e. "Total EQ"; no, I will not apologize).
147-
StructuralTeq, sym::structural_teq, structural_teq_trait, Target::Trait, GenericRequirement::None;
148146
Copy, sym::copy, copy_trait, Target::Trait, GenericRequirement::Exact(0);
149147
Clone, sym::clone, clone_trait, Target::Trait, GenericRequirement::None;
150148
Sync, sym::sync, sync_trait, Target::Trait, GenericRequirement::Exact(0);

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,9 +1359,9 @@ rustc_queries! {
13591359
///
13601360
/// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
13611361
/// correctly.
1362-
query has_structural_eq_impls(ty: Ty<'tcx>) -> bool {
1362+
query has_structural_eq_impl(ty: Ty<'tcx>) -> bool {
13631363
desc {
1364-
"computing whether `{}` implements `PartialStructuralEq` and `StructuralEq`",
1364+
"computing whether `{}` implements `PartialStructuralEq`",
13651365
ty
13661366
}
13671367
}

compiler/rustc_middle/src/ty/util.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,19 +1150,18 @@ impl<'tcx> Ty<'tcx> {
11501150
/// Primitive types (`u32`, `str`) have structural equality by definition. For composite data
11511151
/// types, equality for the type as a whole is structural when it is the same as equality
11521152
/// between all components (fields, array elements, etc.) of that type. For ADTs, structural
1153-
/// equality is indicated by an implementation of `PartialStructuralEq` and `StructuralEq` for
1154-
/// that type.
1153+
/// equality is indicated by an implementation of `PartialStructuralEq` for that type.
11551154
///
11561155
/// This function is "shallow" because it may return `true` for a composite type whose fields
1157-
/// are not `StructuralEq`. For example, `[T; 4]` has structural equality regardless of `T`
1156+
/// are not `StructuralPartialEq`. For example, `[T; 4]` has structural equality regardless of `T`
11581157
/// because equality for arrays is determined by the equality of each array element. If you
11591158
/// want to know whether a given call to `PartialEq::eq` will proceed structurally all the way
11601159
/// down, you will need to use a type visitor.
11611160
#[inline]
11621161
pub fn is_structural_eq_shallow(self, tcx: TyCtxt<'tcx>) -> bool {
11631162
match self.kind() {
1164-
// Look for an impl of both `PartialStructuralEq` and `StructuralEq`.
1165-
ty::Adt(..) => tcx.has_structural_eq_impls(self),
1163+
// Look for an impl of `PartialStructuralEq`.
1164+
ty::Adt(..) => tcx.has_structural_eq_impl(self),
11661165

11671166
// Primitive types that satisfy `Eq`.
11681167
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Str | ty::Never => true,

compiler/rustc_mir_build/messages.ftl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ mir_build_extern_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed =
9090
mir_build_float_pattern = floating-point types cannot be used in patterns
9191
9292
mir_build_indirect_structural_match =
93-
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq, Eq)]`
93+
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]`
9494
9595
mir_build_inform_irrefutable = `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
9696
@@ -230,7 +230,7 @@ mir_build_non_exhaustive_patterns_type_not_empty = non-exhaustive patterns: type
230230
.help = ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
231231
232232
mir_build_nontrivial_structural_match =
233-
to use a constant of type `{$non_sm_ty}` in a pattern, the constant's initializer must be trivial or `{$non_sm_ty}` must be annotated with `#[derive(PartialEq, Eq)]`
233+
to use a constant of type `{$non_sm_ty}` in a pattern, the constant's initializer must be trivial or `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]`
234234
235235
mir_build_overlapping_range_endpoints = multiple patterns overlap on their endpoints
236236
.range = ... with this range
@@ -277,9 +277,9 @@ mir_build_trailing_irrefutable_let_patterns = trailing irrefutable {$count ->
277277
} into the body
278278
279279
mir_build_type_not_structural =
280-
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq, Eq)]`
280+
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]`
281281
282-
mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
282+
mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
283283
284284
mir_build_type_not_structural_tip = the traits must be derived, manual `impl`s are not sufficient
285285

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ symbols! {
286286
SliceIndex,
287287
Some,
288288
String,
289-
StructuralEq,
290289
StructuralPartialEq,
291290
SubdiagnosticMessage,
292291
Sync,
@@ -1523,7 +1522,6 @@ symbols! {
15231522
struct_variant,
15241523
structural_match,
15251524
structural_peq,
1526-
structural_teq,
15271525
sty,
15281526
sub,
15291527
sub_assign,

0 commit comments

Comments
 (0)