Move ExprConstant::kind to StringConstant::unicode (#7180)

This commit is contained in:
Dhruv Manilawala 2023-09-06 13:09:25 +05:30 committed by GitHub
parent 31990b8d3f
commit 04f2842e4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
119 changed files with 130 additions and 504 deletions

View file

@ -334,7 +334,7 @@ impl<'a> From<&'a ast::Decorator> for ComparableDecorator<'a> {
pub enum ComparableConstant<'a> {
None,
Bool(&'a bool),
Str(&'a str),
Str { value: &'a str, unicode: bool },
Bytes(&'a [u8]),
Int(&'a BigInt),
Tuple(Vec<ComparableConstant<'a>>),
@ -353,7 +353,11 @@ impl<'a> From<&'a ast::Constant> for ComparableConstant<'a> {
// Compare strings based on resolved value, not representation (i.e., ignore whether
// the string was implicitly concatenated).
implicit_concatenated: _,
}) => Self::Str(value),
unicode,
}) => Self::Str {
value,
unicode: *unicode,
},
ast::Constant::Bytes(ast::BytesConstant {
value,
// Compare bytes based on resolved value, not representation (i.e., ignore whether
@ -655,7 +659,6 @@ pub struct ExprFString<'a> {
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct ExprConstant<'a> {
value: ComparableConstant<'a>,
kind: Option<&'a str>,
}
#[derive(Debug, PartialEq, Eq, Hash)]
@ -904,14 +907,11 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> {
}) => Self::FString(ExprFString {
values: values.iter().map(Into::into).collect(),
}),
ast::Expr::Constant(ast::ExprConstant {
value,
kind,
range: _,
}) => Self::Constant(ExprConstant {
value: value.into(),
kind: kind.as_ref().map(String::as_str),
}),
ast::Expr::Constant(ast::ExprConstant { value, range: _ }) => {
Self::Constant(ExprConstant {
value: value.into(),
})
}
ast::Expr::Attribute(ast::ExprAttribute {
value,
attr,