Datatype Copy Rust's Structure #200
clippy
30 warnings
Details
Results
Message level | Amount |
---|---|
Internal compiler error | 0 |
Error | 0 |
Warning | 30 |
Note | 0 |
Help | 0 |
Versions
- rustc 1.72.0 (5680fa18f 2023-08-23)
- cargo 1.72.0 (103a7ff2e 2023-08-15)
- clippy 0.1.72 (5680fa1 2023-08-23)
Annotations
Check warning on line 353 in src/type/impls.rs
github-actions / clippy
useless conversion to the same type: `datatype::r#enum::EnumType`
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 ~ },
|
Check warning on line 287 in src/type/impls.rs
github-actions / clippy
useless conversion to the same type: `datatype::r#enum::EnumType`
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 ~ },
|
Check warning on line 212 in src/serde.rs
github-actions / clippy
length comparison to zero
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
Check warning on line 164 in src/serde.rs
github-actions / clippy
you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
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)]`
Check warning on line 70 in src/serde.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
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
Check warning on line 61 in src/serde.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
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
Check warning on line 41 in src/serde.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
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
Check warning on line 22 in src/serde.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
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
Check warning on line 513 in src/lang/ts/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:513:40
|
513 | 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
Check warning on line 509 in src/lang/ts/mod.rs
github-actions / clippy
using a reference to `Cow` is not recommended
warning: using a reference to `Cow` is not recommended
--> src/lang/ts/mod.rs:509:10
|
509 | 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
Check warning on line 473 in src/lang/ts/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:473:33
|
473 | ... &v,
| ^^ help: change this to: `v`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 459 in src/lang/ts/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:459:33
|
459 | ... &v,
| ^^ help: change this to: `v`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 442 in src/lang/ts/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:442:45
|
442 | ... &name,
| ^^^^^ help: change this to: `name`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 427 in src/lang/ts/mod.rs
github-actions / clippy
single-character string constant used as pattern
warning: single-character string constant used as pattern
--> src/lang/ts/mod.rs:427:49
|
427 | ... if typ.contains("|") {
| ^^^ help: try using a `char` instead: `'|'`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern
= note: `#[warn(clippy::single_char_pattern)]` implied by `#[warn(clippy::all)]`
Check warning on line 377 in src/lang/ts/mod.rs
github-actions / clippy
length comparison to zero
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
Check warning on line 369 in src/lang/ts/mod.rs
github-actions / clippy
useless use of `format!`
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)]`
Check warning on line 347 in src/lang/ts/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
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
Check warning on line 335 in src/lang/ts/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
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
Check warning on line 327 in src/lang/ts/mod.rs
github-actions / clippy
using a reference to `Cow` is not recommended
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
Check warning on line 307 in src/lang/ts/mod.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
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)]`
Check warning on line 283 in src/lang/ts/mod.rs
github-actions / clippy
length comparison to zero
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)]`
Check warning on line 275 in src/lang/ts/mod.rs
github-actions / clippy
using a reference to `Cow` is not recommended
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
Check warning on line 280 in src/lang/ts/mod.rs
github-actions / clippy
unneeded `return` statement
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()),
| ~~~~~~~~~~~~~~~~~
Check warning on line 270 in src/lang/ts/mod.rs
github-actions / clippy
this match could be written as a `let` statement
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 + }
|
Check warning on line 234 in src/lang/ts/mod.rs
github-actions / clippy
writing `&Vec` instead of `&[_]` involves a new object where a slice will do
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)]`