Skip to content

Restructure

Restructure #392

Triggered via pull request June 17, 2024 04:09
Status Failure
Total duration 1m 12s
Artifacts

ci.yml

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

Annotations

10 errors and 74 warnings
field `name` of struct `specta::NamedDataType` is private: specta-util/src/export/ts.rs#L36
error[E0616]: field `name` of struct `specta::NamedDataType` is private --> specta-util/src/export/ts.rs:36:28 | 36 | dt.name.clone(), | ^^^^ private field | help: a method `name` also exists, call it with parentheses | 36 | dt.name().clone(), | ++
field `name` of struct `specta::NamedDataType` is private: specta-util/src/export/ts.rs#L32
error[E0616]: field `name` of struct `specta::NamedDataType` is private --> specta-util/src/export/ts.rs:32:31 | 32 | map.insert(dt.name.clone(), (sid, ext.impl_location)) | ^^^^ private field | help: a method `name` also exists, call it with parentheses | 32 | map.insert(dt.name().clone(), (sid, ext.impl_location)) | ++
field `ext` of struct `specta::NamedDataType` is private: specta-util/src/export/ts.rs#L30
error[E0616]: field `ext` of struct `specta::NamedDataType` is private --> specta-util/src/export/ts.rs:30:32 | 30 | if let Some(ext) = &dt.ext { | ^^^ private field | help: a method `ext` also exists, call it with parentheses | 30 | if let Some(ext) = &dt.ext() { | ++
field `map` of struct `specta::TypeMap` is private: specta-util/src/export/export.rs#L21
error[E0616]: field `map` of struct `specta::TypeMap` is private --> specta-util/src/export/export.rs:21:32 | 21 | let (k, v) = self.lock.map.iter().nth(self.index)?; | ^^^ private field
clippy
Clippy had exited with the 101 exit code
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.
this expression always evaluates to true: specta-zod/src/lib.rs#L112
warning: this expression always evaluates to true --> specta-zod/src/lib.rs:112:47 | 112 | let prefix = match start_with_newline && !comments.is_empty() { | ^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#const_is_empty = note: `#[warn(clippy::const_is_empty)]` on by default
field `0` is never read: specta-zod/src/context.rs#L8
warning: field `0` is never read --> specta-zod/src/context.rs:8:18 | 8 | TypeExtended(Cow<'static, str>, ImplLocation), | ------------ ^^^^^^^^^^^^^^^^^ | | | field in this variant | = note: `#[warn(dead_code)]` on by default help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 8 | TypeExtended((), ImplLocation), | ~~
this expression creates a reference which is immediately dereferenced by the compiler: specta/src/type_collection.rs#L36
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta/src/type_collection.rs:36:29 | 36 | let dt = export(&mut type_map); | ^^^^^^^^^^^^^ help: change this to: `type_map` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
this `impl` can be derived: specta/src/type_collection.rs#L11
warning: this `impl` can be derived --> specta/src/type_collection.rs:11:1 | 11 | / impl Default for TypeCollection { 12 | | fn default() -> Self { 13 | | Self { 14 | | types: HashMap::new(), 15 | | } 16 | | } 17 | | } | |_^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls = note: `#[warn(clippy::derivable_impls)]` implied by `#[warn(clippy::all)]` = help: remove the manual implementation... help: ...and instead derive it | 7 + #[derive(Default)] 8 | pub struct TypeCollection { |
accessing first element with `generics.get(0)`: specta/src/type/impls.rs#L165
warning: accessing first element with `generics.get(0)` --> specta/src/type/impls.rs:165:17 | 165 | / generics 166 | | .get(0) | |___________________________^ help: try: `generics.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
accessing first element with `generics.get(0)`: specta/src/type/impls.rs#L153
warning: accessing first element with `generics.get(0)` --> specta/src/type/impls.rs:153:18 | 153 | ty = generics.get(0).cloned() | ^^^^^^^^^^^^^^^ help: try: `generics.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first = note: `#[warn(clippy::get_first)]` implied by `#[warn(clippy::all)]`
passing a unit value to a function: specta/src/lang/ts/mod.rs#L621
warning: passing a unit value to a function --> specta/src/lang/ts/mod.rs:621:5 | 621 | / Ok(match &e.repr { 622 | | EnumRepr::Untagged => { 623 | | let mut variants = e 624 | | .variants ... | 760 | | } 761 | | }) | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg help: move the expression in front of the call and replace it with the unit literal `()` | 621 ~ match &e.repr { 622 + EnumRepr::Untagged => { 623 + let mut variants = e 624 + .variants 625 + .iter() 626 + .filter(|(_, variant)| !variant.skip) 627 + .map(|(name, variant)| { 628 + Ok(match variant.inner { 629 + EnumVariants::Unit => NULL.to_string(), 630 + _ => inner_comments( 631 + ctx.clone(), 632 + variant.deprecated(), 633 + variant.docs(), 634 + enum_variant_datatype( 635 + ctx.with(PathItem::Variant(name.clone())), 636 + type_map, 637 + name.clone(), 638 + variant, 639 + )? 640 + .expect("Invalid Serde type"), 641 + true, 642 + ), 643 + }) 644 + }) 645 + .collect::<Result<Vec<_>>>()?; 646 + variants.dedup(); 647 + s.push_str(&variants.join(" | ")); 648 + } 649 + repr => { 650 + let mut variants = e 651 + .variants 652 + .iter() 653 + .filter(|(_, variant)| !variant.skip) 654 + .map(|(variant_name, variant)| { 655 + let sanitised_name = sanitise_key(variant_name.clone(), true); 656 + 657 + Ok(inner_comments( 658 + ctx.clone(), 659 + variant.deprecated(), 660 + variant.docs(), 661 + match (repr, &variant.inner) { 662 + (EnumRepr::Untagged, _) => unreachable!(), 663 + (EnumRepr::Internal { tag }, EnumVariants::Unit) => { 664 + format!("{{ {tag}: {sanitised_name} }}") 665 + } 666 + (EnumRepr::Internal { tag }, EnumVariants::Unnamed(tuple)) => { 667 + let fields = skip_fields(tuple.fields()).collect::<Vec<_>>(); 668 + 669 + // This field is only required for `{ty}` not `[...]` so we only need to check when there one field 670 + let dont_join_ty = if tuple.fields().len() == 1 { 671 + let (_, ty) = fields.first().expect("checked length above"); 672 + validate_type_for_tagged_intersection( 673 + ctx.clone(), 674 + (**ty).clone(), 675 + type_map, 676 + )? 677 + } else { 678 + false 679 + }; 680 + 681 + let mut typ = String::new(); 682 + 683 + unnamed_fields_datatype(ctx.clone(), &fields, type_map, &mut typ)?; 684 + 685 + if dont_join_ty { 686 + format!("({{ {tag}: {sanitised_name} }})") 687 + } else { 688 + // We wanna be sure `... & ... | ...` becomes `... & (... | ...)` 689 + if typ.contains('|') { 690 + typ = format!("({typ})"); 691 + } 692 + format!("({{ {tag}: {sanitised_name} }} & {typ})") 693 + } 694 + } 695 + (EnumRepr::Internal { tag }, EnumVariants::Named(obj)) => { 696 + let mut fields = vec![format!("{tag}: {sanitised_name}")]; 697 + 698 + for (name, field) in skip_fields_named(obj.fields()) { 699 + let mut other = String::new(); 700 + object_field_to_ts( 701 + ctx.with(PathItem::Field(name.clone())), 702 + name.clone(), 703 + field, 704 + type_map, 705 + &mut other, 706 + )?; 707 + fields.push(other); 708 + } 709 + 710 + format!("{{ {} }}", fields.join("; ")) 711 + } 712 + (EnumRepr::External, EnumVariants::Unit) => sanitised_name.to_string(), 713 + (EnumRepr::External, _) => { 714 + let ts_values = enum_variant_datatype( 715 + ctx.with(PathItem::Variant(variant_name.clone())), 716 + type_map, 717 + variant_name.clone(), 718 + variant, 719 + )?; 720 + let sanitised_name = sanitise_key(variant_name.clone(), false); 721 + 722 + match ts_values { 723 + Some(ts_values) => { 724 + format!("{{ {sanitised_name}: {ts_values} }}") 725 + } 726 + None => format!(r#""{sanitised_name}""#), 727 + } 728 + } 729 + (EnumRepr::Adjacent { tag, .. }, EnumVariants::Unit) => { 730 + format!("{{ {tag}: {sanitised_name} }}") 731 + } 732 + (EnumRepr::Adjacent { tag, content }, _) => { 733 + let ts_value = enum_variant_datatype( 734 + ctx.with(PathItem::Variant(variant_name.clone())), 735 + type_map, 736 + variant_name.clone(), 737 + variant, 738 + )?; 739 + 740 + let mut s = String::new(); 741 + 742 + s.push_str("{ "); 743 + 744 + write!(s, "{tag}: {sanitised_name}")?; 745 + if let Some(ts_value) = ts_value { 746 + write!(s, "; {content}: {ts_value}")?; 747 + } 748 + 749 + s.push_str(" }"); 750 + 751 + s 752 + } 753 + }, 754 + true, 755 + )) 756 + }) 757 + .collect::<Result<Vec<_>>>()?; 758 + variants.dedup(); 759 + s.push_str(&variants.join(" | ")); 760 + } 761 + }; 762 + Ok(()) |
passing a unit value to a function: specta/src/lang/ts/mod.rs#L475
warning: passing a unit value to a function --> specta/src/lang/ts/mod.rs:475:24 | 475 | return Ok(match named.tag().as_ref() { | ________________________^ 476 | | Some(tag) => write!(s, r#"{{ "{tag}": "{key}" }}"#)?, 477 | | None => write!(s, "Record<{STRING}, {NEVER}>")?, 478 | | }); | |__________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg help: move the expression in front of the call and replace it with the unit literal `()` | 475 ~ return { 476 + match named.tag().as_ref() { 477 + Some(tag) => write!(s, r#"{{ "{tag}": "{key}" }}"#)?, 478 + None => write!(s, "Record<{STRING}, {NEVER}>")?, 479 + }; 480 + Ok(()) 481 ~ }; |
passing a unit value to a function: specta/src/lang/ts/mod.rs#L463
warning: passing a unit value to a function --> specta/src/lang/ts/mod.rs:463:5 | 463 | / Ok(match &strct.fields { 464 | | StructFields::Unit => s.push_str(NULL), 465 | | StructFields::Unnamed(unnamed) => unnamed_fields_datatype( 466 | | ctx, ... | 534 | | } 535 | | }) | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg help: move the expression in front of the call and replace it with the unit literal `()` | 463 ~ match &strct.fields { 464 + StructFields::Unit => s.push_str(NULL), 465 + StructFields::Unnamed(unnamed) => unnamed_fields_datatype( 466 + ctx, 467 + &skip_fields(unnamed.fields()).collect::<Vec<_>>(), 468 + type_map, 469 + s, 470 + )?, 471 + StructFields::Named(named) => { 472 + let fields = skip_fields_named(named.fields()).collect::<Vec<_>>(); 473 + 474 + if fields.is_empty() { 475 + return Ok(match named.tag().as_ref() { 476 + Some(tag) => write!(s, r#"{{ "{tag}": "{key}" }}"#)?, 477 + None => write!(s, "Record<{STRING}, {NEVER}>")?, 478 + }); 479 + } 480 + 481 + let (flattened, non_flattened): (Vec<_>, Vec<_>) = 482 + fields.iter().partition(|(_, (f, _))| f.flatten); 483 + 484 + let mut field_sections = flattened 485 + .into_iter() 486 + .map(|(key, (field, ty))| { 487 + let mut s = String::new(); 488 + datatype_inner(ctx.with(PathItem::Field(key.clone())), ty, type_map, &mut s) 489 + .map(|_| { 490 + inner_comments( 491 + ctx.clone(), 492 + field.deprecated(), 493 + field.docs(), 494 + format!("({s})"), 495 + true, 496 + ) 497 + }) 498 + }) 499 + .collect::<Result<Vec<_>>>()?; 500 + 501 + let mut unflattened_fields = non_flattened 502 + .into_iter() 503 + .map(|(key, field_ref)| { 504 + let (field, _) = field_ref; 505 + 506 + let mut other = String::new(); 507 + object_field_to_ts( 508 + ctx.with(PathItem::Field(key.clone())), 509 + key.clone(), 510 + field_ref, 511 + type_map, 512 + &mut other, 513 + )?; 514 + 515 + Ok(inner_comments( 516 + ctx.clone(), 517 + field.deprecated(), 518 + field.docs(), 519 + other, 520 + true, 521 + )) 522 + }) 523 + .collect::<Result<Vec<_>>>()?; 524 + 525 + if let Some(tag) = &named.tag { 526 + unflattened_fields.push(format!("{tag}: \"{key}\"")); 527 + } 528 + 529 + if !unflattened_fields.is_empty() { 530 + field_sections.push(format!("{{ {} }}", unflattened_fields.join("; "))); 531 + } 532 + 533 + s.push_str(&field_sections.join(" & ")); 534 + } 535 + }; 536 + Ok(()) |
passing a unit value to a function: specta/src/lang/ts/mod.rs#L404
warning: passing a unit value to a function --> specta/src/lang/ts/mod.rs:404:5 | 404 | / Ok(match fields { 405 | | [(field, ty)] => { 406 | | let mut v = String::new(); 407 | | datatype_inner(ctx.clone(), ty, type_map, &mut v)?; ... | 436 | | } 437 | | }) | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg help: move the expression in front of the call and replace it with the unit literal `()` | 404 ~ match fields { 405 + [(field, ty)] => { 406 + let mut v = String::new(); 407 + datatype_inner(ctx.clone(), ty, type_map, &mut v)?; 408 + s.push_str(&inner_comments( 409 + ctx, 410 + field.deprecated(), 411 + field.docs(), 412 + v, 413 + true, 414 + )); 415 + } 416 + fields => { 417 + s.push('['); 418 + 419 + for (i, (field, ty)) in fields.iter().enumerate() { 420 + if i != 0 { 421 + s.push_str(", "); 422 + } 423 + 424 + let mut v = String::new(); 425 + datatype_inner(ctx.clone(), ty, type_map, &mut v)?; 426 + s.push_str(&inner_comments( 427 + ctx.clone(), 428 + field.deprecated(), 429 + field.docs(), 430 + v, 431 + true, 432 + )); 433 + } 434 + 435 + s.push(']'); 436 + } 437 + }; 438 + Ok(()) |
this expression creates a reference which is immediately dereferenced by the compiler: specta/src/lang/ts/mod.rs#L393
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta/src/lang/ts/mod.rs:393:61 | 393 | DataType::Generic(GenericType(ident)) => s.push_str(&ident), | ^^^^^^ help: change this to: `ident` | = 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: specta/src/lang/ts/mod.rs#L379
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta/src/lang/ts/mod.rs:379:28 | 379 | s.push_str(&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: specta/src/lang/ts/mod.rs#L377
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta/src/lang/ts/mod.rs:377:30 | 377 | [] => s.push_str(&name), | ^^^^^ help: change this to: `name` | = 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)]`
passing a unit value to a function: specta/src/lang/ts/mod.rs#L260
warning: passing a unit value to a function --> specta/src/lang/ts/mod.rs:260:5 | 260 | / Ok(match &typ { 261 | | DataType::Any => s.push_str(ANY), 262 | | DataType::Unknown => s.push_str(UNKNOWN), 263 | | DataType::Primitive(p) => { ... | 393 | | DataType::Generic(GenericType(ident)) => s.push_str(&ident), 394 | | }) | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg = note: `#[warn(clippy::unit_arg)]` implied by `#[warn(clippy::all)]` help: move the expression in front of the call and replace it with the unit literal `()` | 260 ~ match &typ { 261 + DataType::Any => s.push_str(ANY), 262 + DataType::Unknown => s.push_str(UNKNOWN), 263 + DataType::Primitive(p) => { 264 + let ctx = ctx.with(PathItem::Type(p.to_rust_str().into())); 265 + let str = match p { 266 + primitive_def!(i8 i16 i32 u8 u16 u32 f32 f64) => NUMBER, 267 + primitive_def!(usize isize i64 u64 i128 u128) => match ctx.cfg.bigint { 268 + BigIntExportBehavior::String => STRING, 269 + BigIntExportBehavior::Number => NUMBER, 270 + BigIntExportBehavior::BigInt => BIGINT, 271 + BigIntExportBehavior::Fail => { 272 + return Err(ExportError::BigIntForbidden(ctx.export_path())); 273 + } 274 + BigIntExportBehavior::FailWithReason(reason) => { 275 + return Err(ExportError::Other(ctx.export_path(), reason.to_owned())) 276 + } 277 + }, 278 + primitive_def!(String char) => STRING, 279 + primitive_def!(bool) => BOOLEAN, 280 + }; 281 + 282 + s.push_str(str); 283 + } 284 + DataType::Literal(literal) => write!(s, "{literal}")?, 285 + DataType::Nullable(def) => { 286 + datatype_inner(ctx, def, type_map, s)?; 287 + 288 + let or_null = format!(" | {NULL}"); 289 + if !s.ends_with(&or_null) { 290 + s.push_str(&or_null); 291 + } 292 + } 293 + DataType::Map(def) => { 294 + // We use this instead of `Record<K, V>` to avoid issues with circular references. 295 + s.push_str("{ [key in "); 296 + datatype_inner(ctx.clone(), def.key_ty(), type_map, s)?; 297 + s.push_str("]: "); 298 + datatype_inner(ctx.clone(), def.value_ty(), type_map, s)?; 299 + s.push_str(" }"); 300 + } 301 + // We use `T[]` instead of `Array<T>` to avoid issues with circular references. 302 + DataType::List(def) => { 303 + let mut dt = String::new(); 304 + datatype_inner(ctx, &def.ty, type_map, &mut dt)?; 305 + 306 + let dt = if (dt.contains(' ') && !dt.ends_with('}')) 307 + // This is to do with maintaining order of operations. 308 + // Eg `{} | {}` must be wrapped in parens like `({} | {})[]` but `{}` doesn't cause `{}[]` is valid 309 + || (dt.contains(' ') && (dt.contains('&') || dt.contains('|'))) 310 + { 311 + format!("({dt})") 312 + } else { 313 + dt 314 + }; 315 + 316 + if let Some(length) = def.length { 317 + s.push('['); 318 + 319 + for n in 0..length { 320 + if n != 0 { 321 + s.push_str(", "); 322 + } 323 + 324 + s.push_str(&dt); 325 + } 326 + 327 + s.push(']'); 328 + } else { 329 + write!(s, "{dt}[]")?; 330 + } 331 + } 332 + DataType::Struct(item) => struct_datatype( 333 + ctx.with( 334 + item.sid 335 + .and_then(|sid| type_map.get(sid)) 336 + .and_then(|v| v.ext()) 337 + .map(|v| PathItem::TypeExtended(item.name().clone(), v.impl_location)) 338 + .unwrap_or_else(|| PathItem::Type(item.name().clone())), 339 + ), 340 + item.name(), 341 + item, 342 + type_map, 343 + s, 344 + )?, 345 + DataType::Enum(item) => { 346 + let mut ctx = ctx.clone(); 347 + let cfg = ctx.cfg.clone().bigint(BigIntExportBehavior::Number); 348 + if item.skip_bigint_checks { 349 + ctx.cfg = &cfg; 350 + } 351 + 352 + enum_datatype( 353 + ctx.with(PathItem::Variant(item.name.clone())), 354 + item, 355 + type_map, 356 + s, 357 + )? 358 + } 359 + DataType::Tuple(tuple) => s.push_str(&tuple_datatype(ctx, tuple, type_map)?), 360 + DataType::Result(result) => { 361 + let mut variants = vec![ 362 + { 363 + let mut v = String::new(); 364 + datatype_inner(ctx.clone(), &result.0, type_map, &mut v)?; 365 + v 366 + }, 367 + { 368 + let mut v = String::new(); 369 + datatype_inner(ctx, &result.1, type_map, &mut v)?; 370 + v 371 + }, 372 + ]; 373 + variants.dedup(); 374 + s.push_str(&variants.join(" | ")); 375 + } 376 + DataType::Reference(DataTypeReference { name, generics, .. }) => match &generics[..] { 377 + [] => s.push_str(&name), 378 + generics => { 379 + s.push_str(&name); 380 + s.push('<'); 381 + 382 + for (i, (_, v)) in generics.iter().enumerate() { 383 + if i != 0 { 384 + s.push_str(", "); 385 + } 386 + 387 + datatype_inner(ctx.with(PathItem::Type(name.clone())), v, type_map, s)?; 388 + } 389 + 390 + s.push('>'); 391 + } 392 + }, 393 + DataType::Generic(GenericType(ident)) => s.push_str(&ident), 394 + }; 395 + Ok(()) |
calling `push_str()` using a single-character string literal: specta/src/lang/ts/mod.rs#L167
warning: calling `push_str()` using a single-character string literal --> specta/src/lang/ts/mod.rs:167:5 | 167 | s.push_str(";"); | ^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `s.push(';')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
calling `push_str()` using a single-character string literal: specta/src/lang/ts/mod.rs#L160
warning: calling `push_str()` using a single-character string literal --> specta/src/lang/ts/mod.rs:160:5 | 160 | s.push_str(")"); | ^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `s.push(')')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
calling `push_str()` using a single-character string literal: specta/src/lang/ts/mod.rs#L150
warning: calling `push_str()` using a single-character string literal --> specta/src/lang/ts/mod.rs:150:5 | 150 | s.push_str("("); | ^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `s.push('(')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str = note: `#[warn(clippy::single_char_add_str)]` implied by `#[warn(clippy::all)]`
unnecessary use of `get(&sid).is_none()`: specta/src/datatype/reference.rs#L22
warning: unnecessary use of `get(&sid).is_none()` --> specta/src/datatype/reference.rs:22:21 | 22 | if type_map.map.get(&sid).is_none() { | -------------^^^^^^^^^^^^^^^^^^^ | | | help: replace it with: `!type_map.map.contains_key(&sid)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check = note: `#[warn(clippy::unnecessary_get_then_check)]` implied by `#[warn(clippy::all)]`
this function has too many arguments (8/7): specta/src/internal.rs#L232
warning: this function has too many arguments (8/7) --> specta/src/internal.rs:232:5 | 232 | / pub fn get_fn_datatype<TMarker, T: Function<TMarker>>( 233 | | _: T, 234 | | asyncness: bool, 235 | | name: Cow<'static, str>, ... | 240 | | no_return_type: bool, 241 | | ) -> FunctionDataType { | |_________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments = note: `#[warn(clippy::too_many_arguments)]` implied by `#[warn(clippy::all)]`
`panic` should not be present in production code: specta/src/internal/interop.rs#L344
warning: `panic` should not be present in production code --> specta/src/internal/interop.rs:344:32 | 344 | DataType::Result(_) => panic!("Specta v1 does not support Result types"), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#panic
`panic` should not be present in production code: specta/src/internal/interop.rs#L44
warning: `panic` should not be present in production code --> specta/src/internal/interop.rs:44:37 | 44 | LiteralType::char(_) => panic!("Specta v1 does not support char literals"), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#panic
`panic` should not be present in production code: specta/src/internal/interop.rs#L13
warning: `panic` should not be present in production code --> specta/src/internal/interop.rs:13:30 | 13 | DataType::Unknown => panic!("Specta v1 does not support unknown types"), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#panic note: the lint level is defined here --> specta/src/lib.rs:3:43 | 3 | #![warn(clippy::all, clippy::unwrap_used, clippy::panic)] // TODO: missing_docs | ^^^^^^^^^^^^^
needless `fn main` in doctest: specta/src/./docs.md#L22
warning: needless `fn main` in doctest --> specta/src/./docs.md:22:1 | 22 | / use specta::{*, ts::*}; 23 | | 24 | | #[derive(Type)] 25 | | pub struct MyCustomType { ... | 33 | | ); 34 | | } | |_^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_doctest_main note: the lint level is defined here --> specta/src/lib.rs:3:9 | 3 | #![warn(clippy::all, clippy::unwrap_used, clippy::panic)] // TODO: missing_docs | ^^^^^^^^^^^ = note: `#[warn(clippy::needless_doctest_main)]` implied by `#[warn(clippy::all)]`
constant `RESERVED_IDENTS` is never used: specta/src/lang/ts/reserved_terms.rs#L66
warning: constant `RESERVED_IDENTS` is never used --> specta/src/lang/ts/reserved_terms.rs:66:18 | 66 | pub(crate) const RESERVED_IDENTS: &[&str] = &[ | ^^^^^^^^^^^^^^^
field `0` is never read: specta/src/lang/ts/context.rs#L10
warning: field `0` is never read --> specta/src/lang/ts/context.rs:10:18 | 10 | TypeExtended(Cow<'static, str>, ImplLocation), | ------------ ^^^^^^^^^^^^^^^^^ | | | field in this variant | = note: `#[warn(dead_code)]` on by default help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 10 | TypeExtended((), ImplLocation), | ~~
unused variable: `name`: specta/src/internal/interop.rs#L112
warning: unused variable: `name` --> specta/src/internal/interop.rs:112:32 | 112 | .map(|(name, v)| match v.inner() { | ^^^^ help: if this is intentional, prefix it with an underscore: `_name` | = note: `#[warn(unused_variables)]` on by default
unused import: `fmt::Display`: specta/src/lang/ts/mod.rs#L2
warning: unused import: `fmt::Display` --> specta/src/lang/ts/mod.rs:2:24 | 2 | use std::{borrow::Cow, fmt::Display}; | ^^^^^^^^^^^^
this expression creates a reference which is immediately dereferenced by the compiler: specta-macros/src/type/generics.rs#L241
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:241:29 | 241 | let generics = generics(&crate_ref, quote!(&[#(#generic_var_idents),*])); | ^^^^^^^^^^ help: change this to: `crate_ref` | = 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: specta-macros/src/type/generics.rs#L192
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:192:17 | 192 | &crate_ref, | ^^^^^^^^^^ help: change this to: `crate_ref` | = 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: specta-macros/src/type/generics.rs#L169
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:169:37 | 169 | let generics = generics(&crate_ref, quote!(&[])); | ^^^^^^^^^^ help: change this to: `crate_ref` | = 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: specta-macros/src/type/generics.rs#L151
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:151:37 | 151 | let generics = generics(&crate_ref, quote!(&[#elem_var_ident])); | ^^^^^^^^^^ help: change this to: `crate_ref` | = 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: specta-macros/src/type/generics.rs#L131
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:131:37 | 131 | let generics = generics(&crate_ref, quote!(&[#(#generic_var_idents),*])); | ^^^^^^^^^^ help: change this to: `crate_ref` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
unused import: `selection::*`: specta/src/lib.rs#L33
warning: unused import: `selection::*` --> specta/src/lib.rs:33:9 | 33 | pub use selection::*; | ^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
field assignment outside of initializer for an instance created with Default::default(): specta-macros/src/type/attr/variant.rs#L32
warning: field assignment outside of initializer for an instance created with Default::default() --> specta-macros/src/type/attr/variant.rs:32:9 | 32 | result.common = CommonAttr::from_attrs(attrs)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `r#type::attr::variant::VariantAttr { common: CommonAttr::from_attrs(attrs)?, ..Default::default() }` and removing relevant reassignments --> specta-macros/src/type/attr/variant.rs:31:9 | 31 | let mut result = Self::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/type/attr/variant.rs:18:1 | 18 | / impl_parse! { 19 | | VariantAttr(attr, out) { 20 | | "rename_all" => out.rename_all = out.rename_all.take().or(Some(attr.parse_inflection()?)), 21 | | "rename" => out.rename = out.rename.take().or(Some(attr.parse_string()?.to_token_stream())), ... | 26 | | } 27 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
field assignment outside of initializer for an instance created with Default::default(): specta-macros/src/type/attr/field.rs#L54
warning: field assignment outside of initializer for an instance created with Default::default() --> specta-macros/src/type/attr/field.rs:54:9 | 54 | result.common = CommonAttr::from_attrs(attrs)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `r#type::attr::field::FieldAttr { common: CommonAttr::from_attrs(attrs)?, ..Default::default() }` and removing relevant reassignments --> specta-macros/src/type/attr/field.rs:53:9 | 53 | let mut result = Self::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/type/attr/field.rs:20:1 | 20 | / impl_parse! { 21 | | FieldAttr(attr, out) { 22 | | "rename" => { 23 | | let attr = attr.parse_string()?; ... | 48 | | } 49 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/type/attr/enum.rs:25:1 | 25 | / impl_parse! { 26 | | EnumAttr(attr, out) { 27 | | // "tag" was already passed in the container so we don't need to do anything here 28 | | "content" => out.content = out.content.take().or(Some(attr.parse_string()?)), ... | 31 | | } 32 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
field assignment outside of initializer for an instance created with Default::default(): specta-macros/src/type/attr/container.rs#L54
warning: field assignment outside of initializer for an instance created with Default::default() --> specta-macros/src/type/attr/container.rs:54:9 | 54 | result.common = CommonAttr::from_attrs(attrs)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `r#type::attr::container::ContainerAttr { common: CommonAttr::from_attrs(attrs)?, ..Default::default() }` and removing relevant reassignments --> specta-macros/src/type/attr/container.rs:53:9 | 53 | let mut result = Self::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default = note: `#[warn(clippy::field_reassign_with_default)]` on by default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/type/attr/container.rs:24:1 | 24 | / impl_parse! { 25 | | ContainerAttr(attr, out) { 26 | | "rename_all" => out.rename_all = out.rename_all.take().or(Some(attr.parse_inflection()?)), 27 | | "rename" => { ... | 48 | | } 49 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead: specta-macros/src/type/attr/common.rs#L75
warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead --> specta-macros/src/type/attr/common.rs:75:32 | 75 | let note = attr | ________________________________^ 76 | | .iter() 77 | | .filter(|attr| attr.key == "note") 78 | | .next() | |_______________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#filter_next help: try | 75 ~ let note = attr 76 + .iter().find(|attr| attr.key == "note") |
called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead: specta-macros/src/type/attr/common.rs#L61
warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead --> specta-macros/src/type/attr/common.rs:61:33 | 61 | let since = attr | _________________________________^ 62 | | .iter() 63 | | .filter(|attr| attr.key == "since") 64 | | .next() | |_______________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#filter_next help: try | 61 ~ let since = attr 62 + .iter().find(|attr| attr.key == "since") |
called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead: specta-macros/src/type/attr/common.rs#L46
warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead --> specta-macros/src/type/attr/common.rs:46:35 | 46 | if let Some(attr_value) = attrs.iter().filter(|attr| attr.key == "deprecated").next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `attrs.iter().find(|attr| attr.key == "deprecated")` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#filter_next = note: `#[warn(clippy::filter_next)]` on by default
calling `push_str()` using a single-character string literal: specta-macros/src/type/attr/common.rs#L38
warning: calling `push_str()` using a single-character string literal --> specta-macros/src/type/attr/common.rs:38:21 | 38 | s.push_str("\n"); | ^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `s.push('\n')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str = note: `#[warn(clippy::single_char_add_str)]` on by default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/type/attr/common.rs#L32
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/type/attr/common.rs:32:30 | 32 | pub fn from_attrs(attrs: &mut Vec<Attribute>) -> Result<Self> { | ^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [Attribute]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
redundant pattern matching, consider using `is_some()`: specta-macros/src/specta.rs#L37
warning: redundant pattern matching, consider using `is_some()` --> specta-macros/src/specta.rs:37:30 | 37 | let function_asyncness = match function.sig.asyncness { | ______________________________^ 38 | | Some(_) => true, 39 | | None => false, 40 | | }; | |_____^ help: try: `function.sig.asyncness.is_some()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching = note: `#[warn(clippy::redundant_pattern_matching)]` on by default
length comparison to zero: specta-macros/src/data_type_from/mod.rs#L24
warning: length comparison to zero --> specta-macros/src/data_type_from/mod.rs:24:8 | 24 | if generics.params.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!generics.params.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero = note: `#[warn(clippy::len_zero)]` on by default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/data_type_from/attr/field.rs:13:1 | 13 | / impl_parse! { 14 | | FieldAttr(attr, out) { 15 | | "skip" => out.skip = true, 16 | | "rename" => { ... | 22 | | } 23 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/data_type_from/attr/container.rs:12:1 | 12 | / impl_parse! { 13 | | ContainerAttr(attr, out) { 14 | | "crate" => out.crate_name = out.crate_name.take().or(Some(attr.parse_path()?.into_token_stream())), 15 | | } 16 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: `#[warn(clippy::ptr_arg)]` on by default = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
useless conversion to the same type: `proc_macro2::TokenStream`: specta-macros/src/utils.rs#L206
warning: useless conversion to the same type: `proc_macro2::TokenStream` --> specta-macros/src/utils.rs:206:55 | 206 | let attr = syn::parse::Parser::parse2(parser, attr.tokens.clone().into())?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `attr.tokens.clone()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default
this expression creates a reference which is immediately dereferenced by the compiler: specta-macros/src/type/generics.rs#L241
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:241:29 | 241 | let generics = generics(&crate_ref, quote!(&[#(#generic_var_idents),*])); | ^^^^^^^^^^ help: change this to: `crate_ref` | = 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: specta-macros/src/type/generics.rs#L192
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:192:17 | 192 | &crate_ref, | ^^^^^^^^^^ help: change this to: `crate_ref` | = 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: specta-macros/src/type/generics.rs#L169
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:169:37 | 169 | let generics = generics(&crate_ref, quote!(&[])); | ^^^^^^^^^^ help: change this to: `crate_ref` | = 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: specta-macros/src/type/generics.rs#L151
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:151:37 | 151 | let generics = generics(&crate_ref, quote!(&[#elem_var_ident])); | ^^^^^^^^^^ help: change this to: `crate_ref` | = 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: specta-macros/src/type/generics.rs#L131
warning: this expression creates a reference which is immediately dereferenced by the compiler --> specta-macros/src/type/generics.rs:131:37 | 131 | let generics = generics(&crate_ref, quote!(&[#(#generic_var_idents),*])); | ^^^^^^^^^^ help: change this to: `crate_ref` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
field assignment outside of initializer for an instance created with Default::default(): specta-macros/src/type/attr/variant.rs#L32
warning: field assignment outside of initializer for an instance created with Default::default() --> specta-macros/src/type/attr/variant.rs:32:9 | 32 | result.common = CommonAttr::from_attrs(attrs)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `r#type::attr::variant::VariantAttr { common: CommonAttr::from_attrs(attrs)?, ..Default::default() }` and removing relevant reassignments --> specta-macros/src/type/attr/variant.rs:31:9 | 31 | let mut result = Self::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/type/attr/variant.rs:18:1 | 18 | / impl_parse! { 19 | | VariantAttr(attr, out) { 20 | | "rename_all" => out.rename_all = out.rename_all.take().or(Some(attr.parse_inflection()?)), 21 | | "rename" => out.rename = out.rename.take().or(Some(attr.parse_string()?.to_token_stream())), ... | 26 | | } 27 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
field assignment outside of initializer for an instance created with Default::default(): specta-macros/src/type/attr/field.rs#L54
warning: field assignment outside of initializer for an instance created with Default::default() --> specta-macros/src/type/attr/field.rs:54:9 | 54 | result.common = CommonAttr::from_attrs(attrs)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `r#type::attr::field::FieldAttr { common: CommonAttr::from_attrs(attrs)?, ..Default::default() }` and removing relevant reassignments --> specta-macros/src/type/attr/field.rs:53:9 | 53 | let mut result = Self::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/type/attr/field.rs:20:1 | 20 | / impl_parse! { 21 | | FieldAttr(attr, out) { 22 | | "rename" => { 23 | | let attr = attr.parse_string()?; ... | 48 | | } 49 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/type/attr/enum.rs:25:1 | 25 | / impl_parse! { 26 | | EnumAttr(attr, out) { 27 | | // "tag" was already passed in the container so we don't need to do anything here 28 | | "content" => out.content = out.content.take().or(Some(attr.parse_string()?)), ... | 31 | | } 32 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
field assignment outside of initializer for an instance created with Default::default(): specta-macros/src/type/attr/container.rs#L54
warning: field assignment outside of initializer for an instance created with Default::default() --> specta-macros/src/type/attr/container.rs:54:9 | 54 | result.common = CommonAttr::from_attrs(attrs)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `r#type::attr::container::ContainerAttr { common: CommonAttr::from_attrs(attrs)?, ..Default::default() }` and removing relevant reassignments --> specta-macros/src/type/attr/container.rs:53:9 | 53 | let mut result = Self::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default = note: `#[warn(clippy::field_reassign_with_default)]` on by default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/type/attr/container.rs:24:1 | 24 | / impl_parse! { 25 | | ContainerAttr(attr, out) { 26 | | "rename_all" => out.rename_all = out.rename_all.take().or(Some(attr.parse_inflection()?)), 27 | | "rename" => { ... | 48 | | } 49 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead: specta-macros/src/type/attr/common.rs#L75
warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead --> specta-macros/src/type/attr/common.rs:75:32 | 75 | let note = attr | ________________________________^ 76 | | .iter() 77 | | .filter(|attr| attr.key == "note") 78 | | .next() | |_______________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#filter_next help: try | 75 ~ let note = attr 76 + .iter().find(|attr| attr.key == "note") |
called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead: specta-macros/src/type/attr/common.rs#L61
warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead --> specta-macros/src/type/attr/common.rs:61:33 | 61 | let since = attr | _________________________________^ 62 | | .iter() 63 | | .filter(|attr| attr.key == "since") 64 | | .next() | |_______________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#filter_next help: try | 61 ~ let since = attr 62 + .iter().find(|attr| attr.key == "since") |
called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead: specta-macros/src/type/attr/common.rs#L46
warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead --> specta-macros/src/type/attr/common.rs:46:35 | 46 | if let Some(attr_value) = attrs.iter().filter(|attr| attr.key == "deprecated").next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `attrs.iter().find(|attr| attr.key == "deprecated")` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#filter_next = note: `#[warn(clippy::filter_next)]` on by default
calling `push_str()` using a single-character string literal: specta-macros/src/type/attr/common.rs#L38
warning: calling `push_str()` using a single-character string literal --> specta-macros/src/type/attr/common.rs:38:21 | 38 | s.push_str("\n"); | ^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `s.push('\n')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str = note: `#[warn(clippy::single_char_add_str)]` on by default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/type/attr/common.rs#L32
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/type/attr/common.rs:32:30 | 32 | pub fn from_attrs(attrs: &mut Vec<Attribute>) -> Result<Self> { | ^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [Attribute]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
redundant pattern matching, consider using `is_some()`: specta-macros/src/specta.rs#L37
warning: redundant pattern matching, consider using `is_some()` --> specta-macros/src/specta.rs:37:30 | 37 | let function_asyncness = match function.sig.asyncness { | ______________________________^ 38 | | Some(_) => true, 39 | | None => false, 40 | | }; | |_____^ help: try: `function.sig.asyncness.is_some()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching = note: `#[warn(clippy::redundant_pattern_matching)]` on by default
length comparison to zero: specta-macros/src/data_type_from/mod.rs#L24
warning: length comparison to zero --> specta-macros/src/data_type_from/mod.rs:24:8 | 24 | if generics.params.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!generics.params.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero = note: `#[warn(clippy::len_zero)]` on by default
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/data_type_from/attr/field.rs:13:1 | 13 | / impl_parse! { 14 | | FieldAttr(attr, out) { 15 | | "skip" => out.skip = true, 16 | | "rename" => { ... | 22 | | } 23 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do: specta-macros/src/utils.rs#L218
warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> specta-macros/src/utils.rs:218:24 | 218 | attrs: &mut Vec<crate::utils::Attribute>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&mut [crate::utils::Attribute]` | ::: specta-macros/src/data_type_from/attr/container.rs:12:1 | 12 | / impl_parse! { 13 | | ContainerAttr(attr, out) { 14 | | "crate" => out.crate_name = out.crate_name.take().or(Some(attr.parse_path()?.into_token_stream())), 15 | | } 16 | | } | |_- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg = note: `#[warn(clippy::ptr_arg)]` on by default = note: this warning originates in the macro `impl_parse` (in Nightly builds, run with -Z macro-backtrace for more info)
useless conversion to the same type: `proc_macro2::TokenStream`: specta-macros/src/utils.rs#L206
warning: useless conversion to the same type: `proc_macro2::TokenStream` --> specta-macros/src/utils.rs:206:55 | 206 | let attr = syn::parse::Parser::parse2(parser, attr.tokens.clone().into())?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `attr.tokens.clone()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default
clippy
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions-rs/clippy-check@v1. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
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/