Skip to content

Commit

Permalink
Merge pull request rust-lang#1083 from alexheretic/update-hover-docs
Browse files Browse the repository at this point in the history
Fix std::sync hover doc expectation
  • Loading branch information
nrc authored Oct 9, 2018
2 parents db88ef2 + 29eb624 commit 377081d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
20 changes: 19 additions & 1 deletion src/actions/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,24 @@ pub mod test {
fs::write(path.clone(), data)
.map_err(|e| format!("failed to save hover test result: {:?} ({:?})", path, e))
}

/// Returns true if data is equal to `other` relaxed so that
/// `MarkedString::String` in `other` need only start with self's.
fn has_same_data_start(&self, other: &Self) -> bool {
match (&self.data, &other.data) {
(Ok(data), Ok(them)) if data.len() == them.len() => data
.iter()
.zip(them.iter())
.map(|(us, them)| match (us, them) {
(MarkedString::String(us), MarkedString::String(them)) => {
them.starts_with(us)
}
_ => us == them,
})
.all(|r| r),
_ => false,
}
}
}

impl Test {
Expand Down Expand Up @@ -1193,7 +1211,7 @@ pub mod test {
if actual_result.test != expect_result.test {
let e = format!("Mismatched test: {:?}", expect_result.test);
Some((Err(e), actual_result))
} else if actual_result == expect_result {
} else if expect_result.has_same_data_start(&actual_result) {
None
} else {
Some((Ok(expect_result), actual_result))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
"col": 12
},
"data": {
"Ok": [
{
"Ok": [{
"language": "rust",
"value": "libstd/sync/mod.rs"
},
"Useful synchronization primitives.\n\nThis module contains useful safe and unsafe synchronization primitives.\nMost of the primitives in this module do not provide any sort of locking\nand/or blocking at all, but rather provide the necessary tools to build\nother types of concurrent primitives."
"Useful synchronization primitives.\n\n## The need for synchronization\n\nConceptually, a Rust program is a series of operations which will\nbe executed on a computer. The timeline of events happening in the\nprogram is consistent with the order of the operations in the code."
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
"col": 12
},
"data": {
"Ok": [
{
"Ok": [{
"language": "rust",
"value": "libstd/sync/mod.rs"
},
"Useful synchronization primitives.\n\nThis module contains useful safe and unsafe synchronization primitives.\nMost of the primitives in this module do not provide any sort of locking\nand/or blocking at all, but rather provide the necessary tools to build\nother types of concurrent primitives."
"Useful synchronization primitives.\n\n## The need for synchronization\n\nConceptually, a Rust program is a series of operations which will\nbe executed on a computer. The timeline of events happening in the\nprogram is consistent with the order of the operations in the code."
]
}
}
}

0 comments on commit 377081d

Please sign in to comment.