Make Buffer::write_element non-failable (#6613)
This commit is contained in:
@@ -268,7 +268,8 @@ impl<'ast> Format<PyFormatContext<'ast>> for InParenthesesOnlyLineBreak {
|
||||
f.write_element(FormatElement::Line(match self {
|
||||
InParenthesesOnlyLineBreak::SoftLineBreak => LineMode::Soft,
|
||||
InParenthesesOnlyLineBreak::SoftLineBreakOrSpace => LineMode::SoftOrSpace,
|
||||
}))
|
||||
}));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,11 +184,11 @@ impl Format<PyFormatContext<'_>> for NotYetImplementedCustomText<'_> {
|
||||
tag::VerbatimKind::Verbatim {
|
||||
length: self.text.text_len(),
|
||||
},
|
||||
)))?;
|
||||
)));
|
||||
|
||||
text(self.text).fmt(f)?;
|
||||
|
||||
f.write_element(FormatElement::Tag(Tag::EndVerbatim))?;
|
||||
f.write_element(FormatElement::Tag(Tag::EndVerbatim));
|
||||
|
||||
f.context()
|
||||
.comments()
|
||||
|
||||
@@ -855,7 +855,7 @@ impl Format<PyFormatContext<'_>> for VerbatimText {
|
||||
tag::VerbatimKind::Verbatim {
|
||||
length: self.verbatim_range.len(),
|
||||
},
|
||||
)))?;
|
||||
)));
|
||||
|
||||
match normalize_newlines(f.context().locator().slice(self.verbatim_range), ['\r']) {
|
||||
Cow::Borrowed(_) => {
|
||||
@@ -878,6 +878,7 @@ impl Format<PyFormatContext<'_>> for VerbatimText {
|
||||
}
|
||||
}
|
||||
|
||||
f.write_element(FormatElement::Tag(Tag::EndVerbatim))
|
||||
f.write_element(FormatElement::Tag(Tag::EndVerbatim));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user