Skip to content

Commit 0df7810

Browse files
committed
remove StructuralEq trait
1 parent a58ec8f commit 0df7810

File tree

76 files changed

+266
-529
lines changed

Some content is hidden

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

76 files changed

+266
-529
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
@@ -61,9 +61,6 @@ mod libc {
6161
#[lang = "structural_peq"]
6262
pub trait StructuralPartialEq {}
6363

64-
#[lang = "structural_teq"]
65-
pub trait StructuralEq {}
66-
6764
#[lang = "drop_in_place"]
6865
#[allow(unconditional_recursion)]
6966
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
@@ -138,7 +138,7 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
138138
}
139139
// Trait objects are not allowed in type level constants, as we have no concept for
140140
// resolving their backing type, even if we can do that at const eval time. We may
141-
// hypothetically be able to allow `dyn StructuralEq` trait objects in the future,
141+
// hypothetically be able to allow `dyn StructuralPartialEq` trait objects in the future,
142142
// but it is unclear if this is useful.
143143
ty::Dynamic(..) => Err(ValTreeCreationError::NonSupportedType),
144144

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
@@ -1347,9 +1347,9 @@ rustc_queries! {
13471347
///
13481348
/// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
13491349
/// correctly.
1350-
query has_structural_eq_impls(ty: Ty<'tcx>) -> bool {
1350+
query has_structural_eq_impl(ty: Ty<'tcx>) -> bool {
13511351
desc {
1352-
"computing whether `{}` implements `PartialStructuralEq` and `StructuralEq`",
1352+
"computing whether `{}` implements `StructuralPartialEq`",
13531353
ty
13541354
}
13551355
}

compiler/rustc_middle/src/ty/util.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,19 +1249,18 @@ impl<'tcx> Ty<'tcx> {
12491249
/// Primitive types (`u32`, `str`) have structural equality by definition. For composite data
12501250
/// types, equality for the type as a whole is structural when it is the same as equality
12511251
/// between all components (fields, array elements, etc.) of that type. For ADTs, structural
1252-
/// equality is indicated by an implementation of `PartialStructuralEq` and `StructuralEq` for
1253-
/// that type.
1252+
/// equality is indicated by an implementation of `StructuralPartialEq` for that type.
12541253
///
12551254
/// This function is "shallow" because it may return `true` for a composite type whose fields
1256-
/// are not `StructuralEq`. For example, `[T; 4]` has structural equality regardless of `T`
1255+
/// are not `StructuralPartialEq`. For example, `[T; 4]` has structural equality regardless of `T`
12571256
/// because equality for arrays is determined by the equality of each array element. If you
12581257
/// want to know whether a given call to `PartialEq::eq` will proceed structurally all the way
12591258
/// down, you will need to use a type visitor.
12601259
#[inline]
12611260
pub fn is_structural_eq_shallow(self, tcx: TyCtxt<'tcx>) -> bool {
12621261
match self.kind() {
1263-
// Look for an impl of both `PartialStructuralEq` and `StructuralEq`.
1264-
ty::Adt(..) => tcx.has_structural_eq_impls(self),
1262+
// Look for an impl of `StructuralPartialEq`.
1263+
ty::Adt(..) => tcx.has_structural_eq_impl(self),
12651264

12661265
// Primitive types that satisfy `Eq`.
12671266
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
@@ -110,7 +110,7 @@ mir_build_extern_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed =
110110
mir_build_float_pattern = floating-point types cannot be used in patterns
111111
112112
mir_build_indirect_structural_match =
113-
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq, Eq)]`
113+
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]`
114114
115115
mir_build_inform_irrefutable = `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
116116
@@ -254,7 +254,7 @@ mir_build_non_partial_eq_match =
254254
to use a constant of type `{$non_peq_ty}` in a pattern, the type must implement `PartialEq`
255255
256256
mir_build_nontrivial_structural_match =
257-
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)]`
257+
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)]`
258258
259259
mir_build_pattern_not_covered = refutable pattern in {$origin}
260260
.pattern_ty = the matched value is of type `{$pattern_ty}`
@@ -297,9 +297,9 @@ mir_build_trailing_irrefutable_let_patterns = trailing irrefutable {$count ->
297297
} into the body
298298
299299
mir_build_type_not_structural =
300-
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq, Eq)]`
300+
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]`
301301
302-
mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
302+
mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
303303
304304
mir_build_type_not_structural_tip = the traits must be derived, manual `impl`s are not sufficient
305305

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ symbols! {
310310
Some,
311311
SpanCtxt,
312312
String,
313-
StructuralEq,
314313
StructuralPartialEq,
315314
SubdiagnosticMessage,
316315
Sync,
@@ -1616,7 +1615,6 @@ symbols! {
16161615
struct_variant,
16171616
structural_match,
16181617
structural_peq,
1619-
structural_teq,
16201618
sub,
16211619
sub_assign,
16221620
sub_with_overflow,

0 commit comments

Comments
 (0)