Skip to content

Datatype Copy Rust's Structure #199

Datatype Copy Rust's Structure

Datatype Copy Rust's Structure #199

Triggered via pull request September 4, 2023 07:36
Status Failure
Total duration 5m 11s
Artifacts

ci.yml

on: pull_request
Matrix: build
Fit to window
Zoom out
Zoom in

Annotations

5 errors and 30 warnings
build (macos-latest)
Process completed with exit code 101.
build (windows-latest)
The job was canceled because "macos-latest" failed.
build (windows-latest)
The operation was canceled.
build (ubuntu-latest)
The job was canceled because "macos-latest" failed.
build (ubuntu-latest)
The operation was canceled.
useless conversion to the same type: `datatype::r#enum::EnumType`: src/type/impls.rs#L316
warning: useless conversion to the same type: `datatype::r#enum::EnumType` --> src/type/impls.rs:316:17 | 316 | / EnumType { 317 | | name: "Number".into(), 318 | | repr: EnumRepr::Untagged, 319 | | variants: vec![ ... | 352 | | } 353 | | .into(), | |_______________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion help: consider removing `.into()` | 316 ~ EnumType { 317 + name: "Number".into(), 318 + repr: EnumRepr::Untagged, 319 + variants: vec![ 320 + ( 321 + "f64".into(), 322 + EnumVariant::Unnamed(UnnamedFields { 323 + fields: vec![Field { 324 + optional: false, 325 + flatten: false, 326 + ty: DataType::Primitive(PrimitiveType::f64), 327 + }], 328 + }), 329 + ), 330 + ( 331 + "i64".into(), 332 + EnumVariant::Unnamed(UnnamedFields { 333 + fields: vec![Field { 334 + optional: false, 335 + flatten: false, 336 + ty: DataType::Primitive(PrimitiveType::i64), 337 + }], 338 + }), 339 + ), 340 + ( 341 + "u64".into(), 342 + EnumVariant::Unnamed(UnnamedFields { 343 + fields: vec![Field { 344 + optional: false, 345 + flatten: false, 346 + ty: DataType::Primitive(PrimitiveType::u64), 347 + }], 348 + }), 349 + ), 350 + ], 351 + generics: vec![], 352 ~ }, |
useless conversion to the same type: `datatype::r#enum::EnumType`: src/type/impls.rs#L250
warning: useless conversion to the same type: `datatype::r#enum::EnumType` --> src/type/impls.rs:250:17 | 250 | / EnumType { 251 | | name: "Number".into(), 252 | | repr: EnumRepr::Untagged, 253 | | variants: vec![ ... | 286 | | } 287 | | .into(), | |_______________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion help: consider removing `.into()` | 250 ~ EnumType { 251 + name: "Number".into(), 252 + repr: EnumRepr::Untagged, 253 + variants: vec![ 254 + ( 255 + "f64".into(), 256 + EnumVariant::Unnamed(UnnamedFields { 257 + fields: vec![Field { 258 + optional: false, 259 + flatten: false, 260 + ty: DataType::Primitive(PrimitiveType::f64), 261 + }], 262 + }), 263 + ), 264 + ( 265 + "i64".into(), 266 + EnumVariant::Unnamed(UnnamedFields { 267 + fields: vec![Field { 268 + optional: false, 269 + flatten: false, 270 + ty: DataType::Primitive(PrimitiveType::i64), 271 + }], 272 + }), 273 + ), 274 + ( 275 + "u64".into(), 276 + EnumVariant::Unnamed(UnnamedFields { 277 + fields: vec![Field { 278 + optional: false, 279 + flatten: false, 280 + ty: DataType::Primitive(PrimitiveType::u64), 281 + }], 282 + }), 283 + ), 284 + ], 285 + generics: vec![], 286 ~ }, |
length comparison to zero: src/serde.rs#L212
warning: length comparison to zero --> src/serde.rs:212:32 | 212 | DataType::Tuple(ty) if ty.fields.len() == 0 => {} | ^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `ty.fields.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`: src/serde.rs#L160
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> src/serde.rs:160:5 | 160 | / match &e.repr { 161 | | // Only internally tagged enums can be invalid. 162 | | EnumRepr::Internal { .. } => validate_internally_tag_enum(e, type_map)?, 163 | | _ => {} 164 | | } | |_____^ help: try this: `if let EnumRepr::Internal { .. } = &e.repr { validate_internally_tag_enum(e, type_map)? }` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match = note: `#[warn(clippy::single_match)]` implied by `#[warn(clippy::all)]`
this expression creates a reference which is immediately dereferenced by the compiler: src/serde.rs#L70
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/serde.rs:70:29 | 70 | is_valid_ty(&generic, type_map)?; | ^^^^^^^^ help: change this to: `generic` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/serde.rs#L61
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/serde.rs:61:29 | 61 | is_valid_ty(&field, type_map)?; | ^^^^^^ help: change this to: `field` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/serde.rs#L41
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/serde.rs:41:27 | 41 | validate_enum(&ty, type_map)?; | ^^^ help: change this to: `ty` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/serde.rs#L22
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/serde.rs:22:47 | 22 | DataType::Nullable(ty) => is_valid_ty(&ty, type_map)?, | ^^^ help: change this to: `ty` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L502
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:502:40 | 502 | let field_name_safe = sanitise_key(&key, false); | ^^^^ help: change this to: `key` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
using a reference to `Cow` is not recommended: src/lang/ts/mod.rs#L498
warning: using a reference to `Cow` is not recommended --> src/lang/ts/mod.rs:498:10 | 498 | key: &Cow<'static, str>, | ^^^^^^^^^^^^^^^^^^ help: change this to: `&str` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L462
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:462:33 | 462 | ... &v, | ^^ help: change this to: `v` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L448
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:448:33 | 448 | ... &v, | ^^ help: change this to: `v` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L431
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:431:45 | 431 | ... &name, | ^^^^^ help: change this to: `name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
length comparison to zero: src/lang/ts/mod.rs#L377
warning: length comparison to zero --> src/lang/ts/mod.rs:377:8 | 377 | if e.variants().len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `e.variants().is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
useless use of `format!`: src/lang/ts/mod.rs#L369
warning: useless use of `format!` --> src/lang/ts/mod.rs:369:28 | 369 | [field] => format!("{}", field), | ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `field.to_string()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format = note: `#[warn(clippy::useless_format)]` implied by `#[warn(clippy::all)]`
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L347
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:347:29 | 347 | ... &name, | ^^^^^ help: change this to: `name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L335
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:335:51 | 335 | let sanitised_name = sanitise_key(&name, true); | ^^^^^ help: change this to: `name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
using a reference to `Cow` is not recommended: src/lang/ts/mod.rs#L327
warning: using a reference to `Cow` is not recommended --> src/lang/ts/mod.rs:327:11 | 327 | name: &Cow<'static, str>, | ^^^^^^^^^^^^^^^^^^ help: change this to: `&str` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
this expression creates a reference which is immediately dereferenced by the compiler: src/lang/ts/mod.rs#L307
warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/lang/ts/mod.rs:307:80 | 307 | object_field_to_ts(ctx.with(PathItem::Field(key.clone())), &key, f, type_map) | ^^^^ help: change this to: `key` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` implied by `#[warn(clippy::all)]`
length comparison to zero: src/lang/ts/mod.rs#L283
warning: length comparison to zero --> src/lang/ts/mod.rs:283:16 | 283 | if s.fields.len() == 0 { | ^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.fields.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero = note: `#[warn(clippy::len_zero)]` implied by `#[warn(clippy::all)]`
using a reference to `Cow` is not recommended: src/lang/ts/mod.rs#L275
warning: using a reference to `Cow` is not recommended --> src/lang/ts/mod.rs:275:10 | 275 | key: &Cow<'static, str>, | ^^^^^^^^^^^^^^^^^^ help: change this to: `&str` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
unneeded `return` statement: src/lang/ts/mod.rs#L280
warning: unneeded `return` statement --> src/lang/ts/mod.rs:280:31 | 280 | StructFields::Unit => return Ok("null".into()), | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` implied by `#[warn(clippy::all)]` help: remove `return` | 280 | StructFields::Unit => Ok("null".into()), | ~~~~~~~~~~~~~~~~~
this match could be written as a `let` statement: src/lang/ts/mod.rs#L258
warning: this match could be written as a `let` statement --> src/lang/ts/mod.rs:258:5 | 258 | / match tuple { 259 | | TupleType { fields, .. } => match &fields[..] { 260 | | [] => Ok(empty_tuple_fallback.to_string()), 261 | | [ty] => datatype_inner(ctx, ty, type_map, "null"), ... | 269 | | }, 270 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding = note: `#[warn(clippy::match_single_binding)]` implied by `#[warn(clippy::all)]` help: consider using a `let` statement | 258 ~ let TupleType { fields, .. } = tuple; 259 + match &fields[..] { 260 + [] => Ok(empty_tuple_fallback.to_string()), 261 + [ty] => datatype_inner(ctx, ty, type_map, "null"), 262 + tys => Ok(format!( 263 + "[{}]", 264 + tys.iter() 265 + .map(|v| datatype_inner(ctx.clone(), v, type_map, "null")) 266 + .collect::<Result<Vec<_>>>()? 267 + .join(", ") 268 + )), 269 + } |
writing `&Vec` instead of `&[_]` involves a new object where a slice will do: src/lang/ts/mod.rs#L234
warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do --> src/lang/ts/mod.rs:234:13 | 234 | fields: &Vec<Field>, | ^^^^^^^^^^^ help: change this to: `&[Field]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: `#[warn(clippy::ptr_arg)]` implied by `#[warn(clippy::all)]`
useless conversion to the same type: `export::export::TypesIter`: src/export/ts.rs#L19
warning: useless conversion to the same type: `export::export::TypesIter` --> src/export/ts.rs:19:17 | 19 | let types = get_types() | _________________^ 20 | | .into_iter() | |____________________^ help: consider removing `.into_iter()`: `get_types()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
module has the same name as its containing module: src/export/mod.rs#L1
warning: module has the same name as its containing module --> src/export/mod.rs:1:1 | 1 | mod export; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception = note: `#[warn(clippy::module_inception)]` implied by `#[warn(clippy::all)]`
useless conversion to the same type: `datatype::r#enum::EnumType`: src/datatype/mod.rs#L131
warning: useless conversion to the same type: `datatype::r#enum::EnumType` --> src/datatype/mod.rs:131:13 | 131 | / EnumType { 132 | | name: "Vec".into(), 133 | | repr: EnumRepr::Untagged, 134 | | variants: t ... | 156 | | } 157 | | .into(), | |___________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` implied by `#[warn(clippy::all)]` help: consider removing `.into()` | 131 ~ EnumType { 132 + name: "Vec".into(), 133 + repr: EnumRepr::Untagged, 134 + variants: t 135 + .into_iter() 136 + .map(|t| { 137 + let ty: DataType = t.into(); 138 + ( 139 + match &ty { 140 + DataType::Struct(s) => s.name.clone(), 141 + DataType::Enum(e) => e.name().clone(), 142 + // TODO: This is probs gonna cause problems so we should try and remove the need for this entire impl block if we can. 143 + _ => "".into(), 144 + }, 145 + EnumVariant::Unnamed(UnnamedFields { 146 + fields: vec![Field { 147 + optional: false, 148 + flatten: false, 149 + ty, 150 + }], 151 + }), 152 + ) 153 + }) 154 + .collect(), 155 + generics: vec![], 156 ~ }, |
constant `RESERVED_IDENTS` is never used: src/lang/ts/reserved_terms.rs#L66
warning: constant `RESERVED_IDENTS` is never used --> src/lang/ts/reserved_terms.rs:66:18 | 66 | pub(super) const RESERVED_IDENTS: &[&str] = &[ | ^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
unneeded unit return type: src/export/export.rs#L40
warning: unneeded unit return type --> src/export/export.rs:40:30 | 40 | pub fn register_ty<T: Type>() -> () { | ^^^^^^ help: remove the `-> ()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit note: the lint level is defined here --> src/lib.rs:58:9 | 58 | #![warn(clippy::all, clippy::unwrap_used, clippy::panic)] // TODO: missing_docs | ^^^^^^^^^^^ = note: `#[warn(clippy::unused_unit)]` implied by `#[warn(clippy::all)]`
clippy
The following actions uses node12 which is deprecated and will be forced to run on node16: actions-rs/clippy-check@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/