mirror of https://github.com/kdl-org/kdl-rs.git
Silence `unused_mut` when only `span` is mutated with `span` feature
This commit is contained in:
parent
c7f60b4c56
commit
dc2839f850
41
src/entry.rs
41
src/entry.rs
|
|
@ -579,27 +579,30 @@ mod test {
|
|||
);
|
||||
|
||||
let entry: KdlEntry = " \\\n (\"m\\\"eh\")0xDEADbeef\t\\\n".parse()?;
|
||||
let mut ty: KdlIdentifier = "\"m\\\"eh\"".parse()?;
|
||||
#[cfg(feature = "span")]
|
||||
#[cfg_attr(not(feature = "span"), allow(unused_mut))]
|
||||
{
|
||||
ty.span = (5..12).into();
|
||||
}
|
||||
assert_eq!(
|
||||
entry,
|
||||
KdlEntry {
|
||||
ty: Some(ty),
|
||||
value: KdlValue::Integer(0xdeadbeef),
|
||||
name: None,
|
||||
format: Some(KdlEntryFormat {
|
||||
leading: " \\\n ".into(),
|
||||
trailing: "\t\\\n".into(),
|
||||
value_repr: "0xDEADbeef".into(),
|
||||
..Default::default()
|
||||
}),
|
||||
#[cfg(feature = "span")]
|
||||
span: SourceSpan::from(0..26),
|
||||
let mut ty: KdlIdentifier = "\"m\\\"eh\"".parse()?;
|
||||
#[cfg(feature = "span")]
|
||||
{
|
||||
ty.span = (5..12).into();
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
entry,
|
||||
KdlEntry {
|
||||
ty: Some(ty),
|
||||
value: KdlValue::Integer(0xdeadbeef),
|
||||
name: None,
|
||||
format: Some(KdlEntryFormat {
|
||||
leading: " \\\n ".into(),
|
||||
trailing: "\t\\\n".into(),
|
||||
value_repr: "0xDEADbeef".into(),
|
||||
..Default::default()
|
||||
}),
|
||||
#[cfg(feature = "span")]
|
||||
span: SourceSpan::from(0..26),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
let entry: KdlEntry = " \\\n \"foo\"=(\"m\\\"eh\")0xDEADbeef\t\\\n".parse()?;
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -759,6 +759,7 @@ fn node_children(input: &mut Input<'_>) -> PResult<KdlDocument> {
|
|||
.map(|_| KdlDocument::new())
|
||||
.or_else(|mut e: ErrMode<KdlParseError>| {
|
||||
e = match e {
|
||||
#[cfg_attr(not(feature = "span"), allow(unused_mut))]
|
||||
ErrMode::Cut(mut pe) => {
|
||||
#[cfg(feature = "span")]
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue