SpanlessEq::new(self.cx).eq_expr(self.key, ¶ms[1])
], {
span_lint_and_then(self.cx, MAP_ENTRY, self.span,
- &format!("usage of `contains_key` followed by `insert` on `{}`", self.ty), |db| {
+ &format!("usage of `contains_key` followed by `insert` on a `{}`", self.ty), |db| {
if self.sole_expr {
let help = format!("{}.entry({}).or_insert({})",
snippet(self.cx, self.map.span, "map"),
snippet(self.cx, params[1].span, ".."),
snippet(self.cx, params[2].span, ".."));
- db.span_suggestion(self.span, "Consider using", help);
+ db.span_suggestion(self.span, "consider using", help);
}
else {
- let help = format!("Consider using `{}.entry({})`",
+ let help = format!("{}.entry({})",
snippet(self.cx, self.map.span, "map"),
snippet(self.cx, params[1].span, ".."));
- db.span_note(self.span, &help);
+ db.span_suggestion(self.span, "consider using", help);
}
});
}}
fn insert_if_absent0<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
if !m.contains_key(&k) { m.insert(k, v); }
- //~^ ERROR usage of `contains_key` followed by `insert` on `HashMap`
- //~| HELP Consider
+ //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
+ //~| HELP consider
//~| SUGGESTION m.entry(k).or_insert(v)
}
fn insert_if_absent1<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
if !m.contains_key(&k) { foo(); m.insert(k, v); }
- //~^ ERROR usage of `contains_key` followed by `insert` on `HashMap`
- //~| NOTE Consider using `m.entry(k)`
+ //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
+ //~| HELP consider
+ //~| SUGGESTION m.entry(k)
}
fn insert_if_absent2<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
if !m.contains_key(&k) { m.insert(k, v) } else { None };
- //~^ ERROR usage of `contains_key` followed by `insert` on `HashMap`
- //~| NOTE Consider using `m.entry(k)`
+ //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
+ //~| HELP consider
+ //~| SUGGESTION m.entry(k)
}
fn insert_if_present2<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
if m.contains_key(&k) { None } else { m.insert(k, v) };
- //~^ ERROR usage of `contains_key` followed by `insert` on `HashMap`
- //~| NOTE Consider using `m.entry(k)`
+ //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
+ //~| HELP consider
+ //~| SUGGESTION m.entry(k)
}
fn insert_if_absent3<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None };
- //~^ ERROR usage of `contains_key` followed by `insert` on `HashMap`
- //~| NOTE Consider using `m.entry(k)`
+ //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
+ //~| HELP consider
+ //~| SUGGESTION m.entry(k)
}
fn insert_if_present3<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
if m.contains_key(&k) { None } else { foo(); m.insert(k, v) };
- //~^ ERROR usage of `contains_key` followed by `insert` on `HashMap`
- //~| NOTE Consider using `m.entry(k)`
+ //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
+ //~| HELP consider
+ //~| SUGGESTION m.entry(k)
}
fn insert_in_btreemap<K: Ord, V>(m: &mut BTreeMap<K, V>, k: K, v: V) {
if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None };
- //~^ ERROR usage of `contains_key` followed by `insert` on `BTreeMap`
- //~| NOTE Consider using `m.entry(k)`
+ //~^ ERROR usage of `contains_key` followed by `insert` on a `BTreeMap`
+ //~| HELP consider
+ //~| SUGGESTION m.entry(k)
}
fn insert_other_if_absent<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, o: K, v: V) {