Fix a bug in search_same + add a test case.
This commit is contained in:
@@ -74,9 +74,8 @@ impl PartialEq for Constant {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
(&Constant::Bool(l), &Constant::Bool(r)) => l == r,
|
(&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::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?
|
_ => false, // TODO: Are there inter-type equalities?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,10 +325,13 @@ where
|
|||||||
|
|
||||||
for expr in exprs {
|
for expr in exprs {
|
||||||
match map.entry(hash(expr)) {
|
match map.entry(hash(expr)) {
|
||||||
Entry::Occupied(o) => for o in o.get() {
|
Entry::Occupied(mut o) => {
|
||||||
if eq(o, expr) {
|
for o in o.get() {
|
||||||
return Some((o, expr));
|
if eq(o, expr) {
|
||||||
|
return Some((o, expr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
o.get_mut().push(expr);
|
||||||
},
|
},
|
||||||
Entry::Vacant(v) => {
|
Entry::Vacant(v) => {
|
||||||
v.insert(vec![expr]);
|
v.insert(vec![expr]);
|
||||||
|
|||||||
@@ -206,8 +206,7 @@ fn check_doc<'a, Events: Iterator<Item = (usize, pulldown_cmark::Event<'a>)>>(
|
|||||||
End(Link(_, _)) => in_link = None,
|
End(Link(_, _)) => in_link = None,
|
||||||
Start(_tag) | End(_tag) => (), // We don't care about other tags
|
Start(_tag) | End(_tag) => (), // We don't care about other tags
|
||||||
Html(_html) | InlineHtml(_html) => (), // HTML is weird, just ignore it
|
Html(_html) | InlineHtml(_html) => (), // HTML is weird, just ignore it
|
||||||
SoftBreak => (),
|
SoftBreak | HardBreak => (),
|
||||||
HardBreak => (),
|
|
||||||
FootnoteReference(text) | Text(text) => {
|
FootnoteReference(text) | Text(text) => {
|
||||||
if Some(&text) == in_link.as_ref() {
|
if Some(&text) == in_link.as_ref() {
|
||||||
// Probably a link of the form `<http://example.com>`
|
// Probably a link of the form `<http://example.com>`
|
||||||
|
|||||||
@@ -305,6 +305,14 @@ fn match_wild_err_arm() {
|
|||||||
(Ok(_), Some(x)) => println!("ok {}", x),
|
(Ok(_), Some(x)) => println!("ok {}", x),
|
||||||
_ => println!("err")
|
_ => 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() {
|
fn main() {
|
||||||
|
|||||||
@@ -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)
|
= 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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user