Skip to content

Commit

Permalink
fix(expr)!: revert recursive Cow<[Expression]> back to Vec
Browse files Browse the repository at this point in the history
This fails to build on 1.65:

```
error[E0277]: the trait bound `[SetItem]: ToOwned` is not satisfied in `Expression`
   --> src/stmt.rs:245:14
    |
245 |     pub dev: Option<Expression>,
    |              ^^^^^^^^^^^^^^^^^^ within `Expression`, the trait `ToOwned` is not implemented for `[SetItem]`, which is required by `Expression: Sized`
    |
    = help: the trait `ToOwned` is implemented for `[T]`
note: required because it appears within the type `Expression`
   --> src/expr.rs:10:10
    |
10  | pub enum Expression {
    |          ^^^^^^^^^^
note: required by an implicit `Sized` bound in `std::option::Option`
   --> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:572:1

...and many, many similar errors
```

It compiles successfully on Rust >=1.79, so this commit can be reverted once our MSRV reaches it.
  • Loading branch information
hack3ric committed Nov 24, 2024
1 parent ec094c7 commit a1c6392
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum Expression {
Number(u32),
Boolean(bool),
/// List expressions are constructed by plain arrays containing of an arbitrary number of expressions.
List(Cow<'static, [Expression]>),
List(Vec<Expression>),
BinaryOperation(Box<BinaryOperation>),
Range(Box<Range>),

Expand All @@ -26,10 +26,10 @@ pub enum Expression {
/// Wrapper for non-immediate `Expression`s.
pub enum NamedExpression {
/// Concatenate several expressions.
Concat(Cow<'static, [Expression]>),
Concat(Vec<Expression>),
/// This object constructs an anonymous set.
/// For mappings, an array of arrays with exactly two elements is expected.
Set(Cow<'static, [SetItem]>),
Set(Vec<SetItem>),
Map(Box<Map>),
Prefix(Prefix),

Expand Down
8 changes: 4 additions & 4 deletions tests/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::borrow::Cow;
#[test]
fn test_serialize() {
let _a: Nftables = Nftables {
objects: Cow::Borrowed(&[
objects: Cow::Owned(vec![
NfObject::CmdObject(NfCmd::Add(NfListObject::Table(Table {
family: NfFamily::INet,
name: Cow::Borrowed("namib"),
Expand All @@ -26,12 +26,12 @@ fn test_serialize() {
family: NfFamily::INet,
table: Cow::Borrowed("namib"),
chain: Cow::Borrowed("one_chain"),
expr: Cow::Borrowed(&[
expr: Cow::Owned(vec![
Statement::Match(Match {
left: Expression::List(Cow::Borrowed(&[
left: Expression::List(vec![
Expression::Number(123),
Expression::String(Cow::Borrowed("asd")),
])),
]),
right: Expression::Named(NamedExpression::CT(CT {
key: Cow::Borrowed("state"),
family: None,
Expand Down

0 comments on commit a1c6392

Please sign in to comment.