Skip to content

fix: escape keyword when resolving path in workspace #527

fix: escape keyword when resolving path in workspace

fix: escape keyword when resolving path in workspace #527

GitHub Actions / clippy succeeded Nov 13, 2023 in 0s

clippy

46 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 46
Note 0
Help 0

Versions

  • rustc 1.76.0-nightly (2b603f95a 2023-11-12)
  • cargo 1.76.0-nightly (6790a5127 2023-11-10)
  • clippy 0.1.75 (2b603f9 2023-11-12)

Annotations

Check warning on line 241 in pilota-build/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7)
   --> pilota-build/src/lib.rs:232:5
    |
232 | /     pub fn build_cx(
233 | |         services: Vec<IdlService>,
234 | |         out: Option<Output>,
235 | |         mut parser: P,
...   |
240 | |         keep_unknown_fields: Vec<PathBuf>,
241 | |     ) -> Context {
    | |________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
    = note: `#[warn(clippy::too_many_arguments)]` on by default

Check warning on line 132 in pilota-build/src/plugin/mod.rs

See this annotation in the file changed.

@github-actions 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`
   --> pilota-build/src/plugin/mod.rs:129:13
    |
129 | /             match &node.kind {
130 | |                 NodeKind::Item(item) => p.on_item(cx, *def_id, item.clone()),
131 | |                 _ => {}
132 | |             }
    | |_____________^ help: try: `if let NodeKind::Item(item) = &node.kind { p.on_item(cx, *def_id, item.clone()) }`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match

Check warning on line 43 in pilota-build/src/plugin/workspace.rs

See this annotation in the file changed.

@github-actions 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`
  --> pilota-build/src/plugin/workspace.rs:34:9
   |
34 | /         match &*item {
35 | |             Item::Service(s) => {
36 | |                 if let Some(loc) = cx.location_map.get(&def_id) {
37 | |                     if let Some(mut gen) = cx.plugin_gen.get_mut(loc) {
...  |
42 | |             _ => {}
43 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
   |
34 ~         if let Item::Service(s) = &*item {
35 +             if let Some(loc) = cx.location_map.get(&def_id) {
36 +                 if let Some(mut gen) = cx.plugin_gen.get_mut(loc) {
37 +                     gen.push_str(&format!("pub struct {};", s.name.sym));
38 +                 }
39 +             };
40 +         }
   |

Check warning on line 22 in pilota-build/src/plugin/workspace.rs

See this annotation in the file changed.

@github-actions 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`
  --> pilota-build/src/plugin/workspace.rs:19:21
   |
19 | /                     match &node.kind {
20 | |                         NodeKind::Item(item) => self.on_item(cx, *def_id, item.clone()),
21 | |                         _ => {}
22 | |                     }
   | |_____________________^ help: try: `if let NodeKind::Item(item) = &node.kind { self.on_item(cx, *def_id, item.clone()) }`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match

Check warning on line 458 in pilota-build/src/resolve.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

accessing first element with `status.r#mod.get(0)`

warning: accessing first element with `status.r#mod.get(0)`
   --> pilota-build/src/resolve.rs:458:31
    |
458 |             Namespace::Mod => status.r#mod.get(0),
    |                               ^^^^^^^^^^^^^^^^^^^ help: try: `status.r#mod.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

Check warning on line 457 in pilota-build/src/resolve.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

accessing first element with `status.ty.get(0)`

warning: accessing first element with `status.ty.get(0)`
   --> pilota-build/src/resolve.rs:457:30
    |
457 |             Namespace::Ty => status.ty.get(0),
    |                              ^^^^^^^^^^^^^^^^ help: try: `status.ty.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

Check warning on line 456 in pilota-build/src/resolve.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

accessing first element with `status.value.get(0)`

warning: accessing first element with `status.value.get(0)`
   --> pilota-build/src/resolve.rs:456:33
    |
456 |             Namespace::Value => status.value.get(0),
    |                                 ^^^^^^^^^^^^^^^^^^^ help: try: `status.value.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
    = note: `#[warn(clippy::get_first)]` on by default

Check warning on line 172 in pilota-build/src/resolve.rs

See this annotation in the file changed.

@github-actions 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`
   --> pilota-build/src/resolve.rs:167:13
    |
167 | /             match &item.kind {
168 | |                 ir::ItemKind::Enum(e) => e.variants.iter().for_each(|e| {
169 | |                     self.def_sym(Namespace::Value, (*e.name).clone());
170 | |                 }),
171 | |                 _ => {}
172 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
    = note: `#[warn(clippy::single_match)]` on by default
help: try
    |
167 ~             if let ir::ItemKind::Enum(e) = &item.kind { e.variants.iter().for_each(|e| {
168 +                 self.def_sym(Namespace::Value, (*e.name).clone());
169 +             }) }
    |

Check warning on line 66 in pilota-build/src/parser/protobuf/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

parameter is only used in recursion

warning: parameter is only used in recursion
  --> pilota-build/src/parser/protobuf/mod.rs:66:9
   |
66 |         message_name: Option<&str>,
   |         ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_message_name`
   |
note: parameter used here
  --> pilota-build/src/parser/protobuf/mod.rs:81:33
   |
81 | ...                   message_name,
   |                       ^^^^^^^^^^^^
...
87 | ...                   message_name,
   |                       ^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#only_used_in_recursion
   = note: `#[warn(clippy::only_used_in_recursion)]` on by default

Check warning on line 97 in pilota-build/src/middle/resolver.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you seem to use `.enumerate()` and immediately discard the index

warning: you seem to use `.enumerate()` and immediately discard the index
  --> pilota-build/src/middle/resolver.rs:97:26
   |
97 |         for (_idx, k) in path.into_iter().enumerate() {
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
   = note: `#[warn(clippy::unused_enumerate_index)]` on by default
help: remove the `.enumerate()` call
   |
97 |         for k in path.into_iter() {
   |             ~    ~~~~~~~~~~~~~~~~

Check warning on line 917 in pilota-build/src/middle/context.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

single-character string constant used as pattern

warning: single-character string constant used as pattern
   --> pilota-build/src/middle/context.rs:917:38
    |
917 | ...                   .replace(".", "_")
    |                                ^^^ 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)]` on by default

Check warning on line 908 in pilota-build/src/middle/context.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

redundant closure

warning: redundant closure
   --> pilota-build/src/middle/context.rs:908:45
    |
908 |                     .map(|s| s.as_str().map(|s| FastStr::new(s)))
    |                                             ^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `FastStr::new`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

Check warning on line 909 in pilota-build/src/middle/context.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

called `map(..).flatten()` on `Option`

warning: called `map(..).flatten()` on `Option`
   --> pilota-build/src/middle/context.rs:908:22
    |
908 |                       .map(|s| s.as_str().map(|s| FastStr::new(s)))
    |  ______________________^
909 | |                     .flatten()
    | |______________________________^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|s| s.as_str().map(|s| FastStr::new(s)))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
    = note: `#[warn(clippy::map_flatten)]` on by default

Check warning on line 442 in pilota-build/src/middle/context.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

use of `or_insert_with` to construct default value

warning: use of `or_insert_with` to construct default value
   --> pilota-build/src/middle/context.rs:442:55
    |
442 |         let adjust = &mut *self.adjusts.entry(def_id).or_insert_with(Default::default);
    |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
    = note: `#[warn(clippy::unwrap_or_default)]` on by default

Check warning on line 377 in pilota-build/src/middle/context.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

if let .. else expression looks like `matches!` macro

warning: if let .. else expression looks like `matches!` macro
   --> pilota-build/src/middle/context.rs:369:33
    |
369 | / ...                   if let Some(crate::tags::KeepUnknownFields(false)) =
370 | | ...                       cx.db.tags_map().get(&tags).and_then(|tags| {
371 | | ...                           tags.get::<crate::tags::KeepUnknownFields>()
372 | | ...                       })
...   |
376 | | ...                       true
377 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
    = note: `#[warn(clippy::match_like_matches_macro)]` on by default
help: try
    |
369 ~                                 !matches!(cx.db.tags_map().get(&tags).and_then(|tags| {
370 +                                         tags.get::<crate::tags::KeepUnknownFields>()
371 +                                     }), Some(crate::tags::KeepUnknownFields(false)))
    |

Check warning on line 358 in pilota-build/src/middle/context.rs

See this annotation in the file changed.

@github-actions 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
   --> pilota-build/src/middle/context.rs:358:38
    |
358 |                 let file = files.get(&file_id).unwrap();
    |                                      ^^^^^^^^ help: change this to: `file_id`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 224 in pilota-build/src/middle/context.rs

See this annotation in the file changed.

@github-actions 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
   --> pilota-build/src/middle/context.rs:224:62
    |
224 |                         PathCollector { cx, set }.visit_path(&p);
    |                                                              ^^ help: change this to: `p`
    |
    = 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

Check warning on line 427 in pilota-build/src/codegen/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this lifetime isn't used in the function definition

warning: this lifetime isn't used in the function definition
   --> pilota-build/src/codegen/mod.rs:427:24
    |
427 |     pub fn write_items<'a>(&self, stream: &mut String, items: impl Iterator<Item = CodegenItem>)
    |                        ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
    = note: `#[warn(clippy::extra_unused_lifetimes)]` on by default

Check warning on line 721 in pilota-build/src/codegen/thrift/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

useless use of `format!`

warning: useless use of `format!`
   --> pilota-build/src/codegen/thrift/mod.rs:716:33
    |
716 | / ...                   format!(
717 | | ...                       r#"Err(::pilota::thrift::DecodeError::new(
718 | | ...                           ::pilota::thrift::DecodeErrorKind::InvalidData,
719 | | ...                           "received empty union from remote Message")
720 | | ...                       )"#
721 | | ...                   )
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
    = note: `#[warn(clippy::useless_format)]` on by default
help: consider using `.to_string()`
    |
716 ~                                 r#"Err(::pilota::thrift::DecodeError::new(
717 +                                         ::pilota::thrift::DecodeErrorKind::InvalidData,
718 +                                         "received empty union from remote Message")
719 +                                     )"#.to_string()
    |

Check warning on line 1648 in pilota/src/thrift/compact.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded `return` statement

warning: unneeded `return` statement
    --> pilota/src/thrift/compact.rs:1648:18
     |
1648 |         unsafe { return Ok(FastStr::from_bytes_unchecked(bytes)) }
     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
     |
1648 |         unsafe { Ok(FastStr::from_bytes_unchecked(bytes)) }
     |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check warning on line 350 in pilota-build/src/codegen/thrift/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

writing `&mut String` instead of `&mut str` involves a new object where a slice will do

warning: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
   --> pilota-build/src/codegen/thrift/mod.rs:350:59
    |
350 |     fn codegen_entry_enum(&self, _def_id: DefId, _stream: &mut String, _e: &rir::Enum) {
    |                                                           ^^^^^^^^^^^ help: change this to: `&mut str`
    |
    = 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

Check warning on line 1123 in pilota/src/thrift/compact.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

question mark operator is useless here

warning: question mark operator is useless here
    --> pilota/src/thrift/compact.rs:1123:9
     |
1123 |         Ok(self.read_varint_async::<i64>().await?)
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `self.read_varint_async::<i64>().await`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark

Check warning on line 1118 in pilota/src/thrift/compact.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

question mark operator is useless here

warning: question mark operator is useless here
    --> pilota/src/thrift/compact.rs:1118:9
     |
1118 |         Ok(self.read_varint_async::<i32>().await?)
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `self.read_varint_async::<i32>().await`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark

Check warning on line 1113 in pilota/src/thrift/compact.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

question mark operator is useless here

warning: question mark operator is useless here
    --> pilota/src/thrift/compact.rs:1113:9
     |
1113 |         Ok(self.read_varint_async::<i16>().await?)
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `self.read_varint_async::<i16>().await`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
     = note: `#[warn(clippy::needless_question_mark)]` on by default

Check warning on line 1169 in pilota/src/thrift/binary_unsafe.rs

See this annotation in the file changed.

@github-actions 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
    --> pilota/src/thrift/binary_unsafe.rs:1169:9
     |
1169 |         &mut self.trans
     |         ^^^^^^^^^^^^^^^ help: change this to: `self.trans`
     |
     = 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