Implement template strings (#17851)
This PR implements template strings (t-strings) in the parser and formatter for Ruff. Minimal changes necessary to compile were made in other parts of the code (e.g. ty, the linter, etc.). These will be covered properly in follow-up PRs.
This commit is contained in:
64
crates/ruff_python_formatter/src/generated.rs
generated
64
crates/ruff_python_formatter/src/generated.rs
generated
@@ -1562,6 +1562,42 @@ impl<'ast> IntoFormat<PyFormatContext<'ast>> for ast::ExprFString {
|
||||
}
|
||||
}
|
||||
|
||||
impl FormatRule<ast::ExprTString, PyFormatContext<'_>>
|
||||
for crate::expression::expr_t_string::FormatExprTString
|
||||
{
|
||||
#[inline]
|
||||
fn fmt(&self, node: &ast::ExprTString, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
FormatNodeRule::<ast::ExprTString>::fmt(self, node, f)
|
||||
}
|
||||
}
|
||||
impl<'ast> AsFormat<PyFormatContext<'ast>> for ast::ExprTString {
|
||||
type Format<'a> = FormatRefWithRule<
|
||||
'a,
|
||||
ast::ExprTString,
|
||||
crate::expression::expr_t_string::FormatExprTString,
|
||||
PyFormatContext<'ast>,
|
||||
>;
|
||||
fn format(&self) -> Self::Format<'_> {
|
||||
FormatRefWithRule::new(
|
||||
self,
|
||||
crate::expression::expr_t_string::FormatExprTString::default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
impl<'ast> IntoFormat<PyFormatContext<'ast>> for ast::ExprTString {
|
||||
type Format = FormatOwnedWithRule<
|
||||
ast::ExprTString,
|
||||
crate::expression::expr_t_string::FormatExprTString,
|
||||
PyFormatContext<'ast>,
|
||||
>;
|
||||
fn into_format(self) -> Self::Format {
|
||||
FormatOwnedWithRule::new(
|
||||
self,
|
||||
crate::expression::expr_t_string::FormatExprTString::default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl FormatRule<ast::ExprStringLiteral, PyFormatContext<'_>>
|
||||
for crate::expression::expr_string_literal::FormatExprStringLiteral
|
||||
{
|
||||
@@ -2963,6 +2999,34 @@ impl<'ast> IntoFormat<PyFormatContext<'ast>> for ast::FString {
|
||||
}
|
||||
}
|
||||
|
||||
impl FormatRule<ast::TString, PyFormatContext<'_>> for crate::other::t_string::FormatTString {
|
||||
#[inline]
|
||||
fn fmt(&self, node: &ast::TString, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
FormatNodeRule::<ast::TString>::fmt(self, node, f)
|
||||
}
|
||||
}
|
||||
impl<'ast> AsFormat<PyFormatContext<'ast>> for ast::TString {
|
||||
type Format<'a> = FormatRefWithRule<
|
||||
'a,
|
||||
ast::TString,
|
||||
crate::other::t_string::FormatTString,
|
||||
PyFormatContext<'ast>,
|
||||
>;
|
||||
fn format(&self) -> Self::Format<'_> {
|
||||
FormatRefWithRule::new(self, crate::other::t_string::FormatTString::default())
|
||||
}
|
||||
}
|
||||
impl<'ast> IntoFormat<PyFormatContext<'ast>> for ast::TString {
|
||||
type Format = FormatOwnedWithRule<
|
||||
ast::TString,
|
||||
crate::other::t_string::FormatTString,
|
||||
PyFormatContext<'ast>,
|
||||
>;
|
||||
fn into_format(self) -> Self::Format {
|
||||
FormatOwnedWithRule::new(self, crate::other::t_string::FormatTString::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl FormatRule<ast::StringLiteral, PyFormatContext<'_>>
|
||||
for crate::other::string_literal::FormatStringLiteral
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user