Skip to content

Commit 7d7fbcb

Browse files
committed
Remove PartialEq and Eq from the SpecialDerives.
1 parent d1fff4a commit 7d7fbcb

File tree

5 files changed

+1
-18
lines changed

5 files changed

+1
-18
lines changed

src/librustc/hir/lowering/item.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use smallvec::SmallVec;
1818
use syntax::attr;
1919
use syntax::ast::*;
2020
use syntax::visit::{self, Visitor};
21-
use syntax::expand::SpecialDerives;
2221
use syntax::source_map::{respan, DesugaringKind, Spanned};
2322
use syntax::symbol::{kw, sym};
2423
use syntax_pos::Span;
@@ -227,13 +226,7 @@ impl LoweringContext<'_> {
227226
pub fn lower_item(&mut self, i: &Item) -> Option<hir::Item> {
228227
let mut ident = i.ident;
229228
let mut vis = self.lower_visibility(&i.vis, None);
230-
let mut attrs = self.lower_attrs_extendable(&i.attrs);
231-
if self.resolver.has_derives(i.id, SpecialDerives::PARTIAL_EQ | SpecialDerives::EQ) {
232-
// Add `#[structural_match]` if the item derived both `PartialEq` and `Eq`.
233-
let ident = Ident::new(sym::structural_match, i.span);
234-
attrs.push(attr::mk_attr_outer(attr::mk_word_item(ident)));
235-
}
236-
let attrs = attrs.into();
229+
let attrs = self.lower_attrs(&i.attrs);
237230

238231
if let ItemKind::MacroDef(ref def) = i.kind {
239232
if !def.legacy || attr::contains_name(&i.attrs, sym::macro_export) {

src/librustc_resolve/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,6 @@ pub struct Resolver<'a> {
937937
/// Some built-in derives mark items they are applied to so they are treated specially later.
938938
/// Derive macros cannot modify the item themselves and have to store the markers in the global
939939
/// context, so they attach the markers to derive container IDs using this resolver table.
940-
/// FIXME: Find a way for `PartialEq` and `Eq` to emulate `#[structural_match]`
941-
/// by marking the produced impls rather than the original items.
942940
special_derives: FxHashMap<ExpnId, SpecialDerives>,
943941
/// Parent scopes in which the macros were invoked.
944942
/// FIXME: `derives` are missing in these parent scopes and need to be taken from elsewhere.

src/libsyntax/expand/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ bitflags::bitflags! {
99
/// Built-in derives that need some extra tracking beyond the usual macro functionality.
1010
#[derive(Default)]
1111
pub struct SpecialDerives: u8 {
12-
const PARTIAL_EQ = 1 << 0;
13-
const EQ = 1 << 1;
1412
const COPY = 1 << 2;
1513
}
1614
}

src/libsyntax_ext/deriving/cmp/eq.rs

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::deriving::generic::*;
33
use crate::deriving::generic::ty::*;
44

55
use syntax::ast::{self, Ident, Expr, MetaItem, GenericArg};
6-
use syntax::expand::SpecialDerives;
76
use syntax::ptr::P;
87
use syntax::symbol::{sym, Symbol};
98
use syntax_expand::base::{Annotatable, ExtCtxt};
@@ -14,8 +13,6 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>,
1413
mitem: &MetaItem,
1514
item: &Annotatable,
1615
push: &mut dyn FnMut(Annotatable)) {
17-
cx.resolver.add_derives(cx.current_expansion.id.expn_data().parent, SpecialDerives::EQ);
18-
1916
let inline = cx.meta_word(span, sym::inline);
2017
let hidden = syntax::attr::mk_nested_word_item(Ident::new(sym::hidden, span));
2118
let doc = syntax::attr::mk_list_item(Ident::new(sym::doc, span), vec![hidden]);

src/libsyntax_ext/deriving/cmp/partial_eq.rs

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::deriving::generic::*;
33
use crate::deriving::generic::ty::*;
44

55
use syntax::ast::{BinOpKind, Expr, MetaItem};
6-
use syntax::expand::SpecialDerives;
76
use syntax::ptr::P;
87
use syntax::symbol::sym;
98
use syntax_expand::base::{Annotatable, ExtCtxt};
@@ -14,8 +13,6 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt<'_>,
1413
mitem: &MetaItem,
1514
item: &Annotatable,
1615
push: &mut dyn FnMut(Annotatable)) {
17-
cx.resolver.add_derives(cx.current_expansion.id.expn_data().parent, SpecialDerives::PARTIAL_EQ);
18-
1916
// structures are equal if all fields are equal, and non equal, if
2017
// any fields are not equal or if the enum variants are different
2118
fn cs_op(cx: &mut ExtCtxt<'_>,

0 commit comments

Comments
 (0)