Datatype Copy Rust's Structure #195
clippy
27 warnings
Details
Results
Message level | Amount |
---|---|
Internal compiler error | 0 |
Error | 0 |
Warning | 27 |
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 352 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:315:17
|
315 | / EnumType {
316 | | name: "Number".into(),
317 | | repr: EnumRepr::Untagged,
318 | | variants: vec![
... |
351 | | }
352 | | .into(),
| |_______________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
help: consider removing `.into()`
|
315 ~ EnumType {
316 + name: "Number".into(),
317 + repr: EnumRepr::Untagged,
318 + variants: vec![
319 + (
320 + "f64".into(),
321 + EnumVariant::Unnamed(UnnamedFields {
322 + fields: vec![Field {
323 + optional: false,
324 + flatten: false,
325 + ty: DataType::Primitive(PrimitiveType::f64),
326 + }],
327 + }),
328 + ),
329 + (
330 + "i64".into(),
331 + EnumVariant::Unnamed(UnnamedFields {
332 + fields: vec![Field {
333 + optional: false,
334 + flatten: false,
335 + ty: DataType::Primitive(PrimitiveType::i64),
336 + }],
337 + }),
338 + ),
339 + (
340 + "u64".into(),
341 + EnumVariant::Unnamed(UnnamedFields {
342 + fields: vec![Field {
343 + optional: false,
344 + flatten: false,
345 + ty: DataType::Primitive(PrimitiveType::u64),
346 + }],
347 + }),
348 + ),
349 + ],
350 + generics: vec![],
351 ~ },
|
Check warning on line 286 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:249:17
|
249 | / EnumType {
250 | | name: "Number".into(),
251 | | repr: EnumRepr::Untagged,
252 | | variants: vec![
... |
285 | | }
286 | | .into(),
| |_______________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
help: consider removing `.into()`
|
249 ~ EnumType {
250 + name: "Number".into(),
251 + repr: EnumRepr::Untagged,
252 + variants: vec![
253 + (
254 + "f64".into(),
255 + EnumVariant::Unnamed(UnnamedFields {
256 + fields: vec![Field {
257 + optional: false,
258 + flatten: false,
259 + ty: DataType::Primitive(PrimitiveType::f64),
260 + }],
261 + }),
262 + ),
263 + (
264 + "i64".into(),
265 + EnumVariant::Unnamed(UnnamedFields {
266 + fields: vec![Field {
267 + optional: false,
268 + flatten: false,
269 + ty: DataType::Primitive(PrimitiveType::i64),
270 + }],
271 + }),
272 + ),
273 + (
274 + "u64".into(),
275 + EnumVariant::Unnamed(UnnamedFields {
276 + fields: vec![Field {
277 + optional: false,
278 + flatten: false,
279 + ty: DataType::Primitive(PrimitiveType::u64),
280 + }],
281 + }),
282 + ),
283 + ],
284 + generics: vec![],
285 ~ },
|
Check warning on line 516 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:516:40
|
516 | 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 512 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:512:10
|
512 | 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 477 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:477:33
|
477 | ... &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 463 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:463:33
|
463 | ... &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 446 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:446:45
|
446 | ... &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 392 in src/lang/ts/mod.rs
github-actions / clippy
length comparison to zero
warning: length comparison to zero
--> src/lang/ts/mod.rs:392:8
|
392 | 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 384 in src/lang/ts/mod.rs
github-actions / clippy
useless use of `format!`
warning: useless use of `format!`
--> src/lang/ts/mod.rs:384:28
|
384 | [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 362 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:362:29
|
362 | ... &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 350 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:350:51
|
350 | 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 342 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:342:11
|
342 | 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 322 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:322:80
|
322 | 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 298 in src/lang/ts/mod.rs
github-actions / clippy
length comparison to zero
warning: length comparison to zero
--> src/lang/ts/mod.rs:298:16
|
298 | 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 290 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:290:10
|
290 | 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 295 in src/lang/ts/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> src/lang/ts/mod.rs:295:31
|
295 | 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`
|
295 | StructFields::Unit => Ok("null".into()),
| ~~~~~~~~~~~~~~~~~
Check warning on line 285 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:273:5
|
273 | / match tuple {
274 | | TupleType { fields, .. } => match &fields[..] {
275 | | [] => Ok(empty_tuple_fallback.to_string()),
276 | | [ty] => datatype_inner(ctx, ty, type_map, "null"),
... |
284 | | },
285 | | }
| |_____^
|
= 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
|
273 ~ let TupleType { fields, .. } = tuple;
274 + match &fields[..] {
275 + [] => Ok(empty_tuple_fallback.to_string()),
276 + [ty] => datatype_inner(ctx, ty, type_map, "null"),
277 + tys => Ok(format!(
278 + "[{}]",
279 + tys.iter()
280 + .map(|v| datatype_inner(ctx.clone(), v, type_map, "null"))
281 + .collect::<Result<Vec<_>>>()?
282 + .join(", ")
283 + )),
284 + }
|
Check warning on line 249 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:249:13
|
249 | 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)]`
Check warning on line 178 in src/lang/ts/mod.rs
github-actions / clippy
`panic` should not be present in production code
warning: `panic` should not be present in production code
--> src/lang/ts/mod.rs:178:44
|
178 | .unwrap_or_else(|| panic!("Type {} has no value!", r.name()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#panic
Check warning on line 176 in src/lang/ts/mod.rs
github-actions / clippy
`panic` should not be present in production code
warning: `panic` should not be present in production code
--> src/lang/ts/mod.rs:176:44
|
176 | .unwrap_or_else(|| panic!("Type {} not found!", r.name()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#panic
note: the lint level is defined here
--> src/lib.rs:58:43
|
58 | #![warn(clippy::all, clippy::unwrap_used, clippy::panic)] // TODO: missing_docs
| ^^^^^^^^^^^^^
Check warning on line 20 in src/export/ts.rs
github-actions / clippy
useless conversion to the same type: `export::export::TypesIter`
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
Check warning on line 38 in src/export/export.rs
github-actions / clippy
useless conversion to the same type: `r#type::ExportError`
warning: useless conversion to the same type: `r#type::ExportError`
--> src/export/export.rs:38:20
|
38 | return Err(err.clone().into());
| ^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `err.clone()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
Check warning on line 1 in src/export/mod.rs
github-actions / clippy
module has the same name as its containing module
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)]`
Check warning on line 158 in src/datatype/mod.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/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 ~ },
|
Check warning on line 66 in src/lang/ts/reserved_terms.rs
github-actions / clippy
constant `RESERVED_IDENTS` is never used
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