mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
refactor(frontmatter): Re-structure errors for easier span capturing
This commit is contained in:
parent
f55f79021b
commit
e49cd3dd35
@ -59,6 +59,9 @@ impl<'s> ScriptSource<'s> {
|
|||||||
.char_indices()
|
.char_indices()
|
||||||
.find_map(|(i, c)| (c != FENCE_CHAR).then_some(i))
|
.find_map(|(i, c)| (c != FENCE_CHAR).then_some(i))
|
||||||
.unwrap_or_else(|| input.eof_offset());
|
.unwrap_or_else(|| input.eof_offset());
|
||||||
|
let open_start = input.current_token_start();
|
||||||
|
let fence_pattern = input.next_slice(fence_length);
|
||||||
|
let open_end = input.current_token_start();
|
||||||
match fence_length {
|
match fence_length {
|
||||||
0 => {
|
0 => {
|
||||||
return Ok(source);
|
return Ok(source);
|
||||||
@ -71,9 +74,6 @@ impl<'s> ScriptSource<'s> {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
let open_start = input.current_token_start();
|
|
||||||
let fence_pattern = input.next_slice(fence_length);
|
|
||||||
let open_end = input.current_token_start();
|
|
||||||
source.open = Some(open_start..open_end);
|
source.open = Some(open_start..open_end);
|
||||||
let Some(info_nl) = input.find_slice("\n") else {
|
let Some(info_nl) = input.find_slice("\n") else {
|
||||||
return Err(FrontmatterError::new(format!(
|
return Err(FrontmatterError::new(format!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user