Datatype Copy Rust's Structure #196
Annotations
27 warnings
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 ~ },
|
|
this expression creates a reference which is immediately dereferenced by the compiler:
src/serde.rs#L64
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/serde.rs:64:29
|
64 | 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#L55
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/serde.rs:55:29
|
55 | 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#L18
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/serde.rs:18:47
|
18 | 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#L501
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:501:40
|
501 | 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#L497
warning: using a reference to `Cow` is not recommended
--> src/lang/ts/mod.rs:497:10
|
497 | 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#L461
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:461:33
|
461 | ... &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#L447
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:447:33
|
447 | ... &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#L430
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:430:45
|
430 | ... &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#L376
warning: length comparison to zero
--> src/lang/ts/mod.rs:376:8
|
376 | 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#L368
warning: useless use of `format!`
--> src/lang/ts/mod.rs:368:28
|
368 | [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#L346
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:346:29
|
346 | ... &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#L334
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:334:51
|
334 | 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#L326
warning: using a reference to `Cow` is not recommended
--> src/lang/ts/mod.rs:326:11
|
326 | 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#L306
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/lang/ts/mod.rs:306:80
|
306 | 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#L282
warning: length comparison to zero
--> src/lang/ts/mod.rs:282:16
|
282 | 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#L274
warning: using a reference to `Cow` is not recommended
--> src/lang/ts/mod.rs:274:10
|
274 | 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#L279
warning: unneeded `return` statement
--> src/lang/ts/mod.rs:279:31
|
279 | 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`
|
279 | StructFields::Unit => Ok("null".into()),
| ~~~~~~~~~~~~~~~~~
|
this match could be written as a `let` statement:
src/lang/ts/mod.rs#L257
warning: this match could be written as a `let` statement
--> src/lang/ts/mod.rs:257:5
|
257 | / match tuple {
258 | | TupleType { fields, .. } => match &fields[..] {
259 | | [] => Ok(empty_tuple_fallback.to_string()),
260 | | [ty] => datatype_inner(ctx, ty, type_map, "null"),
... |
268 | | },
269 | | }
| |_____^
|
= 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
|
257 ~ let TupleType { fields, .. } = tuple;
258 + match &fields[..] {
259 + [] => Ok(empty_tuple_fallback.to_string()),
260 + [ty] => datatype_inner(ctx, ty, type_map, "null"),
261 + tys => Ok(format!(
262 + "[{}]",
263 + tys.iter()
264 + .map(|v| datatype_inner(ctx.clone(), v, type_map, "null"))
265 + .collect::<Result<Vec<_>>>()?
266 + .join(", ")
267 + )),
268 + }
|
|
writing `&Vec` instead of `&[_]` involves a new object where a slice will do:
src/lang/ts/mod.rs#L233
warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
--> src/lang/ts/mod.rs:233:13
|
233 | 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#L132
warning: useless conversion to the same type: `datatype::r#enum::EnumType`
--> src/datatype/mod.rs:132:13
|
132 | / EnumType {
133 | | name: "Vec".into(),
134 | | repr: EnumRepr::Untagged,
135 | | variants: t
... |
157 | | }
158 | | .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()`
|
132 ~ EnumType {
133 + name: "Vec".into(),
134 + repr: EnumRepr::Untagged,
135 + variants: t
136 + .into_iter()
137 + .map(|t| {
138 + let ty: DataType = t.into();
139 + (
140 + match &ty {
141 + DataType::Struct(s) => s.name.clone(),
142 + DataType::Enum(e) => e.name().clone(),
143 + // TODO: This is probs gonna cause problems so we should try and remove the need for this entire impl block if we can.
144 + _ => "".into(),
145 + },
146 + EnumVariant::Unnamed(UnnamedFields {
147 + fields: vec![Field {
148 + optional: false,
149 + flatten: false,
150 + ty,
151 + }],
152 + }),
153 + )
154 + })
155 + .collect(),
156 + generics: vec![],
157 ~ },
|
|
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/
|