Skip to content

Commit b32b24d

Browse files
author
Jorge Aparicio
committed
Replace equiv method calls with == operator sugar
1 parent 2840d58 commit b32b24d

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

src/librustc/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ impl MissingDoc {
13771377

13781378
let has_doc = attrs.iter().any(|a| {
13791379
match a.node.value.node {
1380-
ast::MetaNameValue(ref name, _) if name.equiv(&("doc")) => true,
1380+
ast::MetaNameValue(ref name, _) if *name == "doc" => true,
13811381
_ => false
13821382
}
13831383
});

src/librustc/metadata/creader.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn warn_if_multiple_versions(diag: &SpanHandler, cstore: &CStore) {
105105
}
106106

107107
fn visit_crate(e: &Env, c: &ast::Crate) {
108-
for a in c.attrs.iter().filter(|m| m.name().equiv(&("link_args"))) {
108+
for a in c.attrs.iter().filter(|m| m.name() == "link_args") {
109109
match a.value_str() {
110110
Some(ref linkarg) => e.sess.cstore.add_used_link_args(linkarg.get()),
111111
None => { /* fallthrough */ }
@@ -205,7 +205,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
205205

206206
// First, add all of the custom link_args attributes
207207
let link_args = i.attrs.iter()
208-
.filter_map(|at| if at.name().equiv(&("link_args")) {
208+
.filter_map(|at| if at.name() == "link_args" {
209209
Some(at)
210210
} else {
211211
None
@@ -220,7 +220,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
220220

221221
// Next, process all of the #[link(..)]-style arguments
222222
let link_args = i.attrs.iter()
223-
.filter_map(|at| if at.name().equiv(&("link")) {
223+
.filter_map(|at| if at.name() == "link" {
224224
Some(at)
225225
} else {
226226
None
@@ -230,18 +230,18 @@ fn visit_item(e: &Env, i: &ast::Item) {
230230
match m.meta_item_list() {
231231
Some(items) => {
232232
let kind = items.iter().find(|k| {
233-
k.name().equiv(&("kind"))
233+
k.name() == "kind"
234234
}).and_then(|a| a.value_str());
235235
let kind = match kind {
236236
Some(k) => {
237-
if k.equiv(&("static")) {
237+
if k == "static" {
238238
cstore::NativeStatic
239239
} else if e.sess.target.target.options.is_like_osx
240-
&& k.equiv(&("framework")) {
240+
&& k == "framework" {
241241
cstore::NativeFramework
242-
} else if k.equiv(&("framework")) {
242+
} else if k == "framework" {
243243
cstore::NativeFramework
244-
} else if k.equiv(&("dylib")) {
244+
} else if k == "dylib" {
245245
cstore::NativeUnknown
246246
} else {
247247
e.sess.span_err(m.span,
@@ -253,7 +253,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
253253
None => cstore::NativeUnknown
254254
};
255255
let n = items.iter().find(|n| {
256-
n.name().equiv(&("name"))
256+
n.name() == "name"
257257
}).and_then(|a| a.value_str());
258258
let n = match n {
259259
Some(n) => n,

src/librustc/session/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ mod test {
944944
let sessopts = build_session_options(matches);
945945
let sess = build_session(sessopts, None, registry);
946946
let cfg = build_configuration(&sess);
947-
let mut test_items = cfg.iter().filter(|m| m.name().equiv(&("test")));
947+
let mut test_items = cfg.iter().filter(|m| m.name() == "test");
948948
assert!(test_items.next().is_some());
949949
assert!(test_items.next().is_none());
950950
}

src/librustc_trans/driver/driver.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -679,19 +679,19 @@ pub fn collect_crate_types(session: &Session,
679679
let attr_types: Vec<config::CrateType> = attrs.iter().filter_map(|a| {
680680
if a.check_name("crate_type") {
681681
match a.value_str() {
682-
Some(ref n) if n.equiv(&("rlib")) => {
682+
Some(ref n) if *n == "rlib" => {
683683
Some(config::CrateTypeRlib)
684684
}
685-
Some(ref n) if n.equiv(&("dylib")) => {
685+
Some(ref n) if *n == "dylib" => {
686686
Some(config::CrateTypeDylib)
687687
}
688-
Some(ref n) if n.equiv(&("lib")) => {
688+
Some(ref n) if *n == "lib" => {
689689
Some(config::default_lib_output())
690690
}
691-
Some(ref n) if n.equiv(&("staticlib")) => {
691+
Some(ref n) if *n == "staticlib" => {
692692
Some(config::CrateTypeStaticlib)
693693
}
694-
Some(ref n) if n.equiv(&("bin")) => Some(config::CrateTypeExecutable),
694+
Some(ref n) if *n == "bin" => Some(config::CrateTypeExecutable),
695695
Some(_) => {
696696
session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPES,
697697
ast::CRATE_NODE_ID,

src/libsyntax/attr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,11 @@ pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr {
287287
// FIXME (#2809)---validate the usage of #[inline] and #[inline]
288288
attrs.iter().fold(InlineNone, |ia,attr| {
289289
match attr.node.value.node {
290-
MetaWord(ref n) if n.equiv(&("inline")) => {
290+
MetaWord(ref n) if *n == "inline" => {
291291
mark_used(attr);
292292
InlineHint
293293
}
294-
MetaList(ref n, ref items) if n.equiv(&("inline")) => {
294+
MetaList(ref n, ref items) if *n == "inline" => {
295295
mark_used(attr);
296296
if contains_name(items.as_slice(), "always") {
297297
InlineAlways
@@ -409,7 +409,7 @@ pub fn require_unique_names(diagnostic: &SpanHandler, metas: &[P<MetaItem>]) {
409409
pub fn find_repr_attrs(diagnostic: &SpanHandler, attr: &Attribute) -> Vec<ReprAttr> {
410410
let mut acc = Vec::new();
411411
match attr.node.value.node {
412-
ast::MetaList(ref s, ref items) if s.equiv(&("repr")) => {
412+
ast::MetaList(ref s, ref items) if *s == "repr" => {
413413
mark_used(attr);
414414
for item in items.iter() {
415415
match item.node {

src/libsyntax/ext/asm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
148148

149149
let (s, _str_style) = p.parse_str();
150150

151-
if OPTIONS.iter().any(|opt| s.equiv(opt)) {
151+
if OPTIONS.iter().any(|&opt| s == opt) {
152152
cx.span_warn(p.last_span, "expected a clobber, found an option");
153153
}
154154
clobs.push(s);
@@ -157,13 +157,13 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
157157
Options => {
158158
let (option, _str_style) = p.parse_str();
159159

160-
if option.equiv(&("volatile")) {
160+
if option == "volatile" {
161161
// Indicates that the inline assembly has side effects
162162
// and must not be optimized out along with its outputs.
163163
volatile = true;
164-
} else if option.equiv(&("alignstack")) {
164+
} else if option == "alignstack" {
165165
alignstack = true;
166-
} else if option.equiv(&("intel")) {
166+
} else if option == "intel" {
167167
dialect = ast::AsmIntel;
168168
} else {
169169
cx.span_warn(p.last_span, "unrecognized option");

src/libsyntax/feature_gate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
172172

173173
fn visit_item(&mut self, i: &ast::Item) {
174174
for attr in i.attrs.iter() {
175-
if attr.name().equiv(&("thread_local")) {
175+
if attr.name() == "thread_local" {
176176
self.gate_feature("thread_local", i.span,
177177
"`#[thread_local]` is an experimental feature, and does not \
178178
currently handle destructors. There is no corresponding \
179179
`#[task_local]` mapping to the task model");
180-
} else if attr.name().equiv(&("linkage")) {
180+
} else if attr.name() == "linkage" {
181181
self.gate_feature("linkage", i.span,
182182
"the `linkage` attribute is experimental \
183183
and not portable across platforms")
@@ -429,7 +429,7 @@ pub fn check_crate(span_handler: &SpanHandler, krate: &ast::Crate) -> (Features,
429429
}
430430
};
431431
match KNOWN_FEATURES.iter()
432-
.find(|& &(n, _)| name.equiv(&n)) {
432+
.find(|& &(n, _)| name == n) {
433433
Some(&(name, Active)) => { cx.features.push(name); }
434434
Some(&(_, Removed)) => {
435435
span_handler.span_err(mi.span, "feature has been removed");

src/libsyntax/parse/obsolete.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
117117
fn is_obsolete_ident(&mut self, ident: &str) -> bool {
118118
match self.token {
119119
token::Ident(sid, _) => {
120-
token::get_ident(sid).equiv(&ident)
120+
token::get_ident(sid) == ident
121121
}
122122
_ => false
123123
}

0 commit comments

Comments
 (0)