Replace equiv
method calls with ==
operator sugar
This commit is contained in:
parent
2840d58dab
commit
b32b24d13a
@ -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
|
||||
}
|
||||
});
|
||||
|
@ -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,
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -679,19 +679,19 @@ pub fn collect_crate_types(session: &Session,
|
||||
let attr_types: Vec<config::CrateType> = 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,
|
||||
|
@ -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<MetaItem>]) {
|
||||
pub fn find_repr_attrs(diagnostic: &SpanHandler, attr: &Attribute) -> Vec<ReprAttr> {
|
||||
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 {
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user