Impl Default for (String|Bytes|Boolean|None|Ellipsis)Literal (#8341)

## Summary

This PR adds `Default` for the following literal nodes:
* `StringLiteral`
* `BytesLiteral`
* `BooleanLiteral`
* `NoneLiteral`
* `EllipsisLiteral`

The implementation creates the zero value of the respective literal
nodes in terms of the Python language.

## Test Plan

`cargo test`
This commit is contained in:
Dhruv Manilawala 2023-10-30 14:17:44 +05:30 committed by GitHub
parent b5a4a9a356
commit b0dc5a86a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 44 deletions

View file

@ -987,7 +987,7 @@ impl From<ExprFString> for Expr {
}
}
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ExprStringLiteral {
pub range: TextRange,
pub value: String,
@ -1015,7 +1015,7 @@ impl Deref for ExprStringLiteral {
}
}
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ExprBytesLiteral {
pub range: TextRange,
pub value: Vec<u8>,
@ -1059,7 +1059,7 @@ pub enum Number {
Complex { real: f64, imag: f64 },
}
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ExprBooleanLiteral {
pub range: TextRange,
pub value: bool,
@ -1077,7 +1077,7 @@ impl Ranged for ExprBooleanLiteral {
}
}
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ExprNoneLiteral {
pub range: TextRange,
}
@ -1094,7 +1094,7 @@ impl Ranged for ExprNoneLiteral {
}
}
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ExprEllipsisLiteral {
pub range: TextRange,
}