mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
Improve some jsondocck errors
This commit is contained in:
parent
9925ecb392
commit
5f24798b9e
@ -205,7 +205,21 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> {
|
|||||||
let val = cache.get_value(&command.args[0])?;
|
let val = cache.get_value(&command.args[0])?;
|
||||||
let results = select(&val, &command.args[1]).unwrap();
|
let results = select(&val, &command.args[1]).unwrap();
|
||||||
let pat = string_to_value(&command.args[2], cache);
|
let pat = string_to_value(&command.args[2], cache);
|
||||||
results.contains(&pat.as_ref())
|
let has = results.contains(&pat.as_ref());
|
||||||
|
// Give better error for when @has check fails
|
||||||
|
if !command.negated && !has {
|
||||||
|
return Err(CkError::FailedCheck(
|
||||||
|
format!(
|
||||||
|
"{} matched to {:?} but didn't have {:?}",
|
||||||
|
&command.args[1],
|
||||||
|
results,
|
||||||
|
pat.as_ref()
|
||||||
|
),
|
||||||
|
command,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
has
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
@ -233,7 +247,13 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> {
|
|||||||
assert_eq!(command.args[1], "=", "Expected an `=`");
|
assert_eq!(command.args[1], "=", "Expected an `=`");
|
||||||
let val = cache.get_value(&command.args[2])?;
|
let val = cache.get_value(&command.args[2])?;
|
||||||
let results = select(&val, &command.args[3]).unwrap();
|
let results = select(&val, &command.args[3]).unwrap();
|
||||||
assert_eq!(results.len(), 1);
|
assert_eq!(
|
||||||
|
results.len(),
|
||||||
|
1,
|
||||||
|
"Didn't get 1 result for `{}`: got {:?}",
|
||||||
|
command.args[3],
|
||||||
|
results
|
||||||
|
);
|
||||||
match results.len() {
|
match results.len() {
|
||||||
0 => false,
|
0 => false,
|
||||||
1 => {
|
1 => {
|
||||||
|
Loading…
Reference in New Issue
Block a user