diff options
| author | bors <bors@rust-lang.org> | 2018-07-14 16:22:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-07-14 16:22:19 +0000 |
| commit | 0db03e635a5e38ebc7635637b870b8fbcc8a7e46 (patch) | |
| tree | 44b2d1b1a644231eefcff62a9eb9018ab4d7d1c5 /src/libsyntax_ext | |
| parent | 1731f0af22af16c461b2b7abe58988b8549b2de6 (diff) | |
| parent | 7d142c1e53165fea78314117f59e13257d7bf85d (diff) | |
| download | rust-0db03e635a5e38ebc7635637b870b8fbcc8a7e46.tar.gz rust-0db03e635a5e38ebc7635637b870b8fbcc8a7e46.zip | |
Auto merge of #51829 - petrochenkov:noideq, r=eddyb
Remove most of `PartialEq` and `Hash` impls from AST and HIR structures Continuation of https://github.com/rust-lang/rust/pull/49326, prerequisite for removing `PartialEq` for `Ident`.
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/mod.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/ty.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax_ext/format_foreign.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax_ext/proc_macro_registrar.rs | 13 |
4 files changed, 16 insertions, 22 deletions
diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index aad69c109f9..a9f60fd053c 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -188,7 +188,6 @@ pub use self::StaticFields::*; pub use self::SubstructureFields::*; use std::cell::RefCell; -use std::collections::HashSet; use std::vec; use rustc_target::spec::abi::Abi; @@ -617,7 +616,6 @@ impl<'a> TraitDef<'a> { .map(|ty_param| ty_param.ident.name) .collect(); - let mut processed_field_types = HashSet::new(); for field_ty in field_tys { let tys = find_type_parameters(&field_ty, &ty_param_names, self.span, cx); @@ -625,11 +623,9 @@ impl<'a> TraitDef<'a> { // if we have already handled this type, skip it if let ast::TyKind::Path(_, ref p) = ty.node { if p.segments.len() == 1 && - ty_param_names.contains(&p.segments[0].ident.name) || - processed_field_types.contains(&p.segments) { + ty_param_names.contains(&p.segments[0].ident.name) { continue; }; - processed_field_types.insert(p.segments.clone()); } let mut bounds: Vec<_> = self.additional_bounds .iter() @@ -913,7 +909,7 @@ impl<'a> MethodDef<'a> { Self_ if nonstatic => { self_args.push(arg_expr); } - Ptr(ref ty, _) if **ty == Self_ && nonstatic => { + Ptr(ref ty, _) if (if let Self_ = **ty { true } else { false }) && nonstatic => { self_args.push(cx.expr_deref(trait_.span, arg_expr)) } _ => { diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 0b809ab585c..dcccb187bef 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -24,8 +24,7 @@ use syntax_pos::Span; use syntax_pos::symbol::keywords; /// The types of pointers -#[derive(Clone, Eq, PartialEq)] -#[allow(dead_code)] +#[derive(Clone)] pub enum PtrTy<'a> { /// &'lifetime mut Borrowed(Option<&'a str>, ast::Mutability), @@ -35,7 +34,7 @@ pub enum PtrTy<'a> { /// A path, e.g. `::std::option::Option::<i32>` (global). Has support /// for type parameters and a lifetime. -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone)] pub struct Path<'a> { path: Vec<&'a str>, lifetime: Option<&'a str>, @@ -43,7 +42,7 @@ pub struct Path<'a> { kind: PathKind, } -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone)] pub enum PathKind { Local, Global, @@ -107,7 +106,7 @@ impl<'a> Path<'a> { } /// A type. Supports pointers, Self, and literals -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone)] pub enum Ty<'a> { Self_, /// &/Box/ Ty diff --git a/src/libsyntax_ext/format_foreign.rs b/src/libsyntax_ext/format_foreign.rs index 2393af76c34..ff9663cdd3c 100644 --- a/src/libsyntax_ext/format_foreign.rs +++ b/src/libsyntax_ext/format_foreign.rs @@ -12,7 +12,7 @@ pub mod printf { use super::strcursor::StrCursor as Cur; /// Represents a single `printf`-style substitution. - #[derive(Clone, Eq, PartialEq, Debug)] + #[derive(Clone, PartialEq, Debug)] pub enum Substitution<'a> { /// A formatted output substitution. Format(Format<'a>), @@ -40,7 +40,7 @@ pub mod printf { } } - #[derive(Clone, Eq, PartialEq, Debug)] + #[derive(Clone, PartialEq, Debug)] /// A single `printf`-style formatting directive. pub struct Format<'a> { /// The entire original formatting directive. @@ -213,7 +213,7 @@ pub mod printf { } /// A general number used in a `printf` formatting directive. - #[derive(Copy, Clone, Eq, PartialEq, Debug)] + #[derive(Copy, Clone, PartialEq, Debug)] pub enum Num { // The range of these values is technically bounded by `NL_ARGMAX`... but, at least for GNU // libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it @@ -739,7 +739,7 @@ pub mod printf { pub mod shell { use super::strcursor::StrCursor as Cur; - #[derive(Clone, Eq, PartialEq, Debug)] + #[derive(Clone, PartialEq, Debug)] pub enum Substitution<'a> { Ordinal(u8), Name(&'a str), diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index ab2bb446631..2522fa769c5 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -101,9 +101,7 @@ fn is_proc_macro_attr(attr: &ast::Attribute) -> bool { impl<'a> CollectProcMacros<'a> { fn check_not_pub_in_root(&self, vis: &ast::Visibility, sp: Span) { - if self.is_proc_macro_crate && - self.in_root && - vis.node == ast::VisibilityKind::Public { + if self.is_proc_macro_crate && self.in_root && vis.node.is_pub() { self.handler.span_err(sp, "`proc-macro` crate types cannot \ export any items other than functions \ @@ -181,7 +179,7 @@ impl<'a> CollectProcMacros<'a> { Vec::new() }; - if self.in_root && item.vis.node == ast::VisibilityKind::Public { + if self.in_root && item.vis.node.is_pub() { self.derives.push(ProcMacroDerive { span: item.span, trait_name, @@ -206,7 +204,7 @@ impl<'a> CollectProcMacros<'a> { return; } - if self.in_root && item.vis.node == ast::VisibilityKind::Public { + if self.in_root && item.vis.node.is_pub() { self.attr_macros.push(ProcMacroDef { span: item.span, function_name: item.ident, @@ -229,7 +227,7 @@ impl<'a> CollectProcMacros<'a> { return; } - if self.in_root && item.vis.node == ast::VisibilityKind::Public { + if self.in_root && item.vis.node.is_pub() { self.bang_macros.push(ProcMacroDef { span: item.span, function_name: item.ident, @@ -271,7 +269,8 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { for attr in &item.attrs { if is_proc_macro_attr(&attr) { if let Some(prev_attr) = found_attr { - let msg = if attr.path == prev_attr.path { + let msg = if attr.path.segments[0].ident.name == + prev_attr.path.segments[0].ident.name { format!("Only one `#[{}]` attribute is allowed on any given function", attr.path) } else { |
