From b32b24d13a8cbf5db44ac73b44ae48ad639a47c7 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 20 Nov 2014 20:25:27 -0500 Subject: [PATCH] Replace `equiv` method calls with `==` operator sugar --- src/librustc/lint/builtin.rs | 2 +- src/librustc/metadata/creader.rs | 18 +++++++++--------- src/librustc/session/config.rs | 2 +- src/librustc_trans/driver/driver.rs | 10 +++++----- src/libsyntax/attr.rs | 6 +++--- src/libsyntax/ext/asm.rs | 8 ++++---- src/libsyntax/feature_gate.rs | 6 +++--- src/libsyntax/parse/obsolete.rs | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index aa99fe996f0..9a214d531d1 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -1377,7 +1377,7 @@ impl MissingDoc { let has_doc = attrs.iter().any(|a| { match a.node.value.node { - ast::MetaNameValue(ref name, _) if name.equiv(&("doc")) => true, + ast::MetaNameValue(ref name, _) if *name == "doc" => true, _ => false } }); diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 7f0941db6b2..5a8d60fbecd 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -105,7 +105,7 @@ fn warn_if_multiple_versions(diag: &SpanHandler, cstore: &CStore) { } fn visit_crate(e: &Env, c: &ast::Crate) { - for a in c.attrs.iter().filter(|m| m.name().equiv(&("link_args"))) { + for a in c.attrs.iter().filter(|m| m.name() == "link_args") { match a.value_str() { Some(ref linkarg) => e.sess.cstore.add_used_link_args(linkarg.get()), None => { /* fallthrough */ } @@ -205,7 +205,7 @@ fn visit_item(e: &Env, i: &ast::Item) { // First, add all of the custom link_args attributes let link_args = i.attrs.iter() - .filter_map(|at| if at.name().equiv(&("link_args")) { + .filter_map(|at| if at.name() == "link_args" { Some(at) } else { None @@ -220,7 +220,7 @@ fn visit_item(e: &Env, i: &ast::Item) { // Next, process all of the #[link(..)]-style arguments let link_args = i.attrs.iter() - .filter_map(|at| if at.name().equiv(&("link")) { + .filter_map(|at| if at.name() == "link" { Some(at) } else { None @@ -230,18 +230,18 @@ fn visit_item(e: &Env, i: &ast::Item) { match m.meta_item_list() { Some(items) => { let kind = items.iter().find(|k| { - k.name().equiv(&("kind")) + k.name() == "kind" }).and_then(|a| a.value_str()); let kind = match kind { Some(k) => { - if k.equiv(&("static")) { + if k == "static" { cstore::NativeStatic } else if e.sess.target.target.options.is_like_osx - && k.equiv(&("framework")) { + && k == "framework" { cstore::NativeFramework - } else if k.equiv(&("framework")) { + } else if k == "framework" { cstore::NativeFramework - } else if k.equiv(&("dylib")) { + } else if k == "dylib" { cstore::NativeUnknown } else { e.sess.span_err(m.span, @@ -253,7 +253,7 @@ fn visit_item(e: &Env, i: &ast::Item) { None => cstore::NativeUnknown }; let n = items.iter().find(|n| { - n.name().equiv(&("name")) + n.name() == "name" }).and_then(|a| a.value_str()); let n = match n { Some(n) => n, diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 3c2dbae665f..33de2c9abe9 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -944,7 +944,7 @@ mod test { let sessopts = build_session_options(matches); let sess = build_session(sessopts, None, registry); let cfg = build_configuration(&sess); - let mut test_items = cfg.iter().filter(|m| m.name().equiv(&("test"))); + let mut test_items = cfg.iter().filter(|m| m.name() == "test"); assert!(test_items.next().is_some()); assert!(test_items.next().is_none()); } diff --git a/src/librustc_trans/driver/driver.rs b/src/librustc_trans/driver/driver.rs index aeef16276e5..d3281ae1c19 100644 --- a/src/librustc_trans/driver/driver.rs +++ b/src/librustc_trans/driver/driver.rs @@ -679,19 +679,19 @@ pub fn collect_crate_types(session: &Session, let attr_types: Vec = attrs.iter().filter_map(|a| { if a.check_name("crate_type") { match a.value_str() { - Some(ref n) if n.equiv(&("rlib")) => { + Some(ref n) if *n == "rlib" => { Some(config::CrateTypeRlib) } - Some(ref n) if n.equiv(&("dylib")) => { + Some(ref n) if *n == "dylib" => { Some(config::CrateTypeDylib) } - Some(ref n) if n.equiv(&("lib")) => { + Some(ref n) if *n == "lib" => { Some(config::default_lib_output()) } - Some(ref n) if n.equiv(&("staticlib")) => { + Some(ref n) if *n == "staticlib" => { Some(config::CrateTypeStaticlib) } - Some(ref n) if n.equiv(&("bin")) => Some(config::CrateTypeExecutable), + Some(ref n) if *n == "bin" => Some(config::CrateTypeExecutable), Some(_) => { session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPES, ast::CRATE_NODE_ID, diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index fdfa275549a..a2811681efd 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -287,11 +287,11 @@ pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr { // FIXME (#2809)---validate the usage of #[inline] and #[inline] attrs.iter().fold(InlineNone, |ia,attr| { match attr.node.value.node { - MetaWord(ref n) if n.equiv(&("inline")) => { + MetaWord(ref n) if *n == "inline" => { mark_used(attr); InlineHint } - MetaList(ref n, ref items) if n.equiv(&("inline")) => { + MetaList(ref n, ref items) if *n == "inline" => { mark_used(attr); if contains_name(items.as_slice(), "always") { InlineAlways @@ -409,7 +409,7 @@ pub fn require_unique_names(diagnostic: &SpanHandler, metas: &[P]) { pub fn find_repr_attrs(diagnostic: &SpanHandler, attr: &Attribute) -> Vec { let mut acc = Vec::new(); match attr.node.value.node { - ast::MetaList(ref s, ref items) if s.equiv(&("repr")) => { + ast::MetaList(ref s, ref items) if *s == "repr" => { mark_used(attr); for item in items.iter() { match item.node { diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index a0999d9eee9..b138811187b 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -148,7 +148,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) let (s, _str_style) = p.parse_str(); - if OPTIONS.iter().any(|opt| s.equiv(opt)) { + if OPTIONS.iter().any(|&opt| s == opt) { cx.span_warn(p.last_span, "expected a clobber, found an option"); } clobs.push(s); @@ -157,13 +157,13 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) Options => { let (option, _str_style) = p.parse_str(); - if option.equiv(&("volatile")) { + if option == "volatile" { // Indicates that the inline assembly has side effects // and must not be optimized out along with its outputs. volatile = true; - } else if option.equiv(&("alignstack")) { + } else if option == "alignstack" { alignstack = true; - } else if option.equiv(&("intel")) { + } else if option == "intel" { dialect = ast::AsmIntel; } else { cx.span_warn(p.last_span, "unrecognized option"); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 7453da6374e..c7aef0020b2 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -172,12 +172,12 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { fn visit_item(&mut self, i: &ast::Item) { for attr in i.attrs.iter() { - if attr.name().equiv(&("thread_local")) { + if attr.name() == "thread_local" { self.gate_feature("thread_local", i.span, "`#[thread_local]` is an experimental feature, and does not \ currently handle destructors. There is no corresponding \ `#[task_local]` mapping to the task model"); - } else if attr.name().equiv(&("linkage")) { + } else if attr.name() == "linkage" { self.gate_feature("linkage", i.span, "the `linkage` attribute is experimental \ and not portable across platforms") @@ -429,7 +429,7 @@ pub fn check_crate(span_handler: &SpanHandler, krate: &ast::Crate) -> (Features, } }; match KNOWN_FEATURES.iter() - .find(|& &(n, _)| name.equiv(&n)) { + .find(|& &(n, _)| name == n) { Some(&(name, Active)) => { cx.features.push(name); } Some(&(_, Removed)) => { span_handler.span_err(mi.span, "feature has been removed"); diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 86a96fc5216..650f8295d01 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -117,7 +117,7 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { fn is_obsolete_ident(&mut self, ident: &str) -> bool { match self.token { token::Ident(sid, _) => { - token::get_ident(sid).equiv(&ident) + token::get_ident(sid) == ident } _ => false }