Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yutannihilation/485ba77d2584784fd339c7979a786b22 to your computer and use it in GitHub Desktop.
Save yutannihilation/485ba77d2584784fd339c7979a786b22 to your computer and use it in GitHub Desktop.
Clippy warnings
warning: matching on `Some` with `ok()` is redundant
--> extendr-macros/src/output_r.rs:20:5
|
20 | if let Some(manifest_dir) = env::current_dir().ok() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(clippy::if_let_some_result)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_let_some_result
help: consider matching on `Ok(manifest_dir)` and removing the call to `ok` instead
|
20 | if let Ok(manifest_dir) = env::current_dir() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: useless conversion to the same type: `std::path::PathBuf`
--> extendr-macros/src/output_r.rs:21:26
|
21 | let target_dir = PathBuf::from(manifest_dir).join("target");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `PathBuf::from()`: `manifest_dir`
|
= note: `#[warn(clippy::useless_conversion)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
warning: match expression looks like `matches!` macro
--> extendr-macros/src/output_r.rs:88:19
|
88 | let is_void = match return_type {
| ___________________^
89 | | ReturnType::Default => true,
90 | | _ => false,
91 | | };
| |_____^ help: try this: `matches!(return_type, ReturnType::Default)`
|
= note: `#[warn(clippy::match_like_matches_macro)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
warning: match expression looks like `matches!` macro
--> extendr-macros/src/lib.rs:184:20
|
184 | let has_self = match inputs.iter().next() {
| ____________________^
185 | | Some(FnArg::Receiver(_)) => true,
186 | | _ => false,
187 | | };
| |_____^ help: try this: `matches!(inputs.iter().next(), Some(FnArg::Receiver(_)))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
warning: unneeded `return` statement
--> extendr-macros/src/lib.rs:444:27
|
444 | Item::Fn(func) => return extendr_function(args, func),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `extendr_function(args, func)`
|
= note: `#[warn(clippy::needless_return)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
warning: unneeded `return` statement
--> extendr-macros/src/lib.rs:445:34
|
445 | Item::Impl(item_impl) => return extendr_impl(item_impl),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `extendr_impl(item_impl)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
warning: this boolean expression can be simplified
--> extendr-macros/src/lib.rs:470:20
|
470 | if !res.modname.is_none() {
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.modname.is_some()`
|
= note: `#[warn(clippy::nonminimal_bool)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
warning: redundant pattern matching, consider using `is_ok()`
--> extendr-macros/src/lib.rs:474:27
|
474 | } else if let Ok(_) = input.parse::<Token![fn]>() {
| -------^^^^^------------------------------ help: try this: `if input.parse::<Token![fn]>().is_ok()`
|
= note: `#[warn(clippy::redundant_pattern_matching)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
warning: redundant pattern matching, consider using `is_ok()`
--> extendr-macros/src/lib.rs:476:27
|
476 | } else if let Ok(_) = input.parse::<Token![impl]>() {
| -------^^^^^-------------------------------- help: try this: `if input.parse::<Token![impl]>().is_ok()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
warning: 9 warnings emitted
warning: unnecessary closure used to substitute value for `Option::None`
--> extendr-api/src/functions.rs:54:5
|
54 | / global_env()
55 | | .find_var(key)
56 | | .ok_or_else(|| Error::NotFound)
| |_______________________________________^
|
= note: `#[warn(clippy::unnecessary_lazy_evaluations)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
help: Use `ok_or` instead
|
54 | global_env()
55 | .find_var(key).ok_or(Error::NotFound)
|
warning: unnecessary closure used to substitute value for `Option::None`
--> extendr-api/src/functions.rs:76:5
|
76 | / current_env()
77 | | .find_var(key)
78 | | .ok_or_else(|| Error::NotFound)
| |_______________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
help: Use `ok_or` instead
|
76 | current_env()
77 | .find_var(key).ok_or(Error::NotFound)
|
warning: returning the result of a `let` binding from a block
--> extendr-api/src/matrix.rs:153:9
|
152 | let res = array.data.into();
| ---------------------------- unnecessary `let` binding
153 | res
| ^^^
|
= note: `#[warn(clippy::let_and_return)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
help: return the expression directly
|
152 |
153 | array.data.into()
|
warning: this boolean expression can be simplified
--> extendr-api/src/robj/from_robj.rs:270:19
|
270 | } else if !robj.as_typed_slice().is_some() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `robj.as_typed_slice().is_none()`
|
= note: `#[warn(clippy::nonminimal_bool)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
warning: unneeded `return` statement
--> extendr-api/src/robj/into_robj.rs:353:13
|
353 | return Robj::Owned(sexp);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `Robj::Owned(sexp)`
|
= note: `#[warn(clippy::needless_return)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
warning: unneeded `return` statement
--> extendr-api/src/robj/into_robj.rs:355:13
|
355 | return Robj::from(());
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `Robj::from(())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
warning: use of `offset` with a `usize` casted to an `isize`
--> extendr-api/src/robj/into_robj.rs:329:26
|
329 | *ptr.offset(i as isize) = v.to_real();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(i)`
|
= note: `#[warn(clippy::ptr_offset_with_cast)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
warning: use of `offset` with a `usize` casted to an `isize`
--> extendr-api/src/robj/into_robj.rs:335:26
|
335 | *ptr.offset(i as isize) = v.to_integer();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(i)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
warning: use of `offset` with a `usize` casted to an `isize`
--> extendr-api/src/robj/into_robj.rs:341:26
|
341 | *ptr.offset(i as isize) = v.to_logical();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(i)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
warning: using `clone` on a `Copy` type
--> extendr-api/src/robj/into_robj.rs:390:35
|
390 | if let (len, Some(max)) = self.size_hint().clone() {
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `self.size_hint()`
|
= note: `#[warn(clippy::clone_on_copy)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
warning: unneeded `return` statement
--> extendr-api/src/robj/iter.rs:23:13
|
23 | return None;
| ^^^^^^^^^^^^ help: remove `return`: `None`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
warning: you should consider adding a `Default` implementation for `robj::iter::PairlistIter`
--> extendr-api/src/robj/iter.rs:83:5
|
83 | / pub fn new() -> Self {
84 | | unsafe {
85 | | Self {
86 | | list_elem: R_NilValue,
87 | | }
88 | | }
89 | | }
| |_____^
|
= note: `#[warn(clippy::new_without_default)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try this
|
81 | impl Default for robj::iter::PairlistIter {
82 | fn default() -> Self {
83 | Self::new()
84 | }
85 | }
|
warning: you should consider adding a `Default` implementation for `robj::iter::PairlistTagIter<'a>`
--> extendr-api/src/robj/iter.rs:136:5
|
136 | / pub fn new() -> Self {
137 | | unsafe {
138 | | Self {
139 | | list_elem: R_NilValue,
... |
142 | | }
143 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try this
|
134 | impl Default for robj::iter::PairlistTagIter<'a> {
135 | fn default() -> Self {
136 | Self::new()
137 | }
138 | }
|
warning: you should consider adding a `Default` implementation for `robj::iter::StrIter`
--> extendr-api/src/robj/iter.rs:202:5
|
202 | / pub fn new() -> Self {
203 | | unsafe {
204 | | Self {
205 | | vector: R_NilValue,
... |
210 | | }
211 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try this
|
200 | impl Default for robj::iter::StrIter {
201 | fn default() -> Self {
202 | Self::new()
203 | }
204 | }
|
warning: unneeded `return` statement
--> extendr-api/src/robj/iter.rs:246:17
|
246 | return None;
| ^^^^^^^^^^^^ help: remove `return`: `None`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
warning: unneeded `return` statement
--> extendr-api/src/robj/iter.rs:253:17
|
253 | return None;
| ^^^^^^^^^^^^ help: remove `return`: `None`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
warning: use of `offset` with a `usize` casted to an `isize`
--> extendr-api/src/robj/iter.rs:250:26
|
250 | let j = *(INTEGER(self.vector).offset(i as isize));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `INTEGER(self.vector).add(i)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
warning: item `robj::Robj` has a public `len` method but no corresponding `is_empty` method
--> extendr-api/src/robj/mod.rs:164:1
|
164 | / impl Robj {
165 | | /// Get a copy of the underlying SEXP.
166 | | /// Note: this is unsafe.
167 | | #[doc(hidden)]
... |
768 | | }
769 | | }
| |_^
|
= note: `#[warn(clippy::len_without_is_empty)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
warning: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
--> extendr-api/src/robj/mod.rs:338:23
|
338 | Some(value.iter().cloned().collect::<Vec<_>>())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
|
= note: `#[warn(clippy::iter_cloned_collect)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
warning: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
--> extendr-api/src/robj/mod.rs:369:23
|
369 | Some(value.iter().cloned().collect::<Vec<_>>())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
warning: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
--> extendr-api/src/robj/mod.rs:452:23
|
452 | Some(value.iter().cloned().collect::<Vec<_>>())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
warning: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
--> extendr-api/src/robj/mod.rs:683:24
|
680 | if res.is_err() {
| ------------ the check is happening here
...
683 | Robj::from(res.unwrap())
| ^^^^^^^^^^^^
|
= note: `#[warn(clippy::unnecessary_unwrap)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
warning: useless conversion to the same type: `robj::Robj`
--> extendr-api/src/robj/mod.rs:683:13
|
683 | Robj::from(res.unwrap())
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `Robj::from()`: `res.unwrap()`
|
= note: `#[warn(clippy::useless_conversion)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
warning: match expression looks like `matches!` macro
--> extendr-api/src/robj/mod.rs:755:9
|
755 | / match self {
756 | | Robj::Owned(_) => true,
757 | | _ => false,
758 | | }
| |_________^ help: try this: `matches!(self, Robj::Owned(_))`
|
= note: `#[warn(clippy::match_like_matches_macro)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
warning: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
--> extendr-api/src/robj/mod.rs:763:21
|
763 | pub fn to_owned(self) -> Robj {
| ^^^^
|
= note: `#[warn(clippy::wrong_self_convention)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention
warning: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
--> extendr-api/src/robj/mod.rs:980:18
|
980 | iter.find(|&n| n == classname).is_some()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|n| n == classname)`
|
= note: `#[warn(clippy::search_is_some)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
warning: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
--> extendr-api/src/robj/mod.rs:1023:48
|
1022 | ... if tag.is_some() {
| ------------- the check is happening here
1023 | ... names.push(tag.unwrap().to_string());
| ^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
warning: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
--> extendr-api/src/robj/mod.rs:1031:40
|
1030 | if tag.is_some() {
| ------------- the check is happening here
1031 | names.push(tag.unwrap().to_string());
| ^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
warning: use of `offset` with a `usize` casted to an `isize`
--> extendr-api/src/wrapper.rs:199:18
|
199 | *ptr.offset(i as isize) = v;
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(i)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
warning: very complex type used. Consider factoring parts into `type` definitions
--> extendr-api/src/wrapper.rs:445:34
|
445 | pub fn as_pairlist(&self) -> Option<Pairlist<Vec<(Option<&str>, Robj)>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(clippy::type_complexity)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
warning: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
--> extendr-api/src/wrapper.rs:525:61
|
524 | ... if !obj.is_unbound_value() && tag.is_some() {
| ------------- the check is happening here
525 | ... names_and_values.insert(tag.unwrap(), obj);
| ^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
warning: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
--> extendr-api/src/wrapper.rs:535:53
|
534 | if !obj.is_unbound_value() && tag.is_some() {
| ------------- the check is happening here
535 | names_and_values.insert(tag.unwrap(), obj);
| ^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
warning: 32 warnings emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment