Fix a bug in search_same + add a test case.

This commit is contained in:
laurent 2017-11-29 21:42:58 +00:00
parent 3eb642bcdd
commit c3ae2ddeb3
5 changed files with 34 additions and 7 deletions

View File

@ -74,9 +74,8 @@ impl PartialEq for Constant {
}
},
(&Constant::Bool(l), &Constant::Bool(r)) => l == r,
(&Constant::Vec(ref l), &Constant::Vec(ref r)) => l == r,
(&Constant::Vec(ref l), &Constant::Vec(ref r)) | (&Constant::Tuple(ref l), &Constant::Tuple(ref r)) => l == r,
(&Constant::Repeat(ref lv, ref ls), &Constant::Repeat(ref rv, ref rs)) => ls == rs && lv == rv,
(&Constant::Tuple(ref l), &Constant::Tuple(ref r)) => l == r,
_ => false, // TODO: Are there inter-type equalities?
}
}

View File

@ -325,10 +325,13 @@ where
for expr in exprs {
match map.entry(hash(expr)) {
Entry::Occupied(o) => for o in o.get() {
if eq(o, expr) {
return Some((o, expr));
Entry::Occupied(mut o) => {
for o in o.get() {
if eq(o, expr) {
return Some((o, expr));
}
}
o.get_mut().push(expr);
},
Entry::Vacant(v) => {
v.insert(vec![expr]);

View File

@ -206,8 +206,7 @@ fn check_doc<'a, Events: Iterator<Item = (usize, pulldown_cmark::Event<'a>)>>(
End(Link(_, _)) => in_link = None,
Start(_tag) | End(_tag) => (), // We don't care about other tags
Html(_html) | InlineHtml(_html) => (), // HTML is weird, just ignore it
SoftBreak => (),
HardBreak => (),
SoftBreak | HardBreak => (),
FootnoteReference(text) | Text(text) => {
if Some(&text) == in_link.as_ref() {
// Probably a link of the form `<http://example.com>`

View File

@ -305,6 +305,14 @@ fn match_wild_err_arm() {
(Ok(_), Some(x)) => println!("ok {}", x),
_ => println!("err")
}
// because of a bug, no warning was generated for this case before #2251
match x {
Ok(_tmp) => println!("ok"),
Ok(3) => println!("ok"),
Ok(_) => println!("ok"),
Err(_) => {unreachable!();}
}
}
fn main() {

View File

@ -426,3 +426,21 @@ note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))`
| ^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: this `match` has identical arm bodies
--> $DIR/matches.rs:313:18
|
313 | Ok(_) => println!("ok"),
| ^^^^^^^^^^^^^^
|
note: same as this
--> $DIR/matches.rs:312:18
|
312 | Ok(3) => println!("ok"),
| ^^^^^^^^^^^^^^
note: consider refactoring into `Ok(3) | Ok(_)`
--> $DIR/matches.rs:312:18
|
312 | Ok(3) => println!("ok"),
| ^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)