mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Fix a bug in search_same + add a test case.
This commit is contained in:
parent
3eb642bcdd
commit
c3ae2ddeb3
@ -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?
|
||||
}
|
||||
}
|
||||
|
@ -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]);
|
||||
|
@ -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>`
|
||||
|
@ -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() {
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user