fix: warnings in libjsonnet.so #639
clippy
133 warnings
Details
Results
Message level | Amount |
---|---|
Internal compiler error | 0 |
Error | 0 |
Warning | 133 |
Note | 0 |
Help | 0 |
Versions
- rustc 1.75.0-nightly (2f1bd0729 2023-10-27)
- cargo 1.75.0-nightly (df3509237 2023-10-24)
- clippy 0.1.75 (2f1bd07 2023-10-27)
Annotations
Check warning on line 156 in cmds/jrsonnet/src/main.rs
github-actions / clippy
consider adding a `;` to the last statement for consistent formatting
warning: consider adding a `;` to the last statement for consistent formatting
--> cmds/jrsonnet/src/main.rs:156:4
|
156 | eprintln!("{out}")
| ^^^^^^^^^^^^^^^^^^ help: add a `;` here: `eprintln!("{out}");`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
= note: `-W clippy::semicolon-if-nothing-returned` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::semicolon_if_nothing_returned)]`
Check warning on line 105 in crates/jrsonnet-cli/src/lib.rs
github-actions / clippy
consider adding a `;` to the last statement for consistent formatting
warning: consider adding a `;` to the last statement for consistent formatting
--> crates/jrsonnet-cli/src/lib.rs:105:3
|
105 | eprintln!("Tracked: {}", jrsonnet_gcmodule::count_thread_tracked())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `eprintln!("Tracked: {}", jrsonnet_gcmodule::count_thread_tracked());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
Check warning on line 91 in crates/jrsonnet-cli/src/lib.rs
github-actions / clippy
redundant closure
warning: redundant closure
--> crates/jrsonnet-cli/src/lib.rs:91:28
|
91 | with_thread_object_space(|s| s.leak())
| ^^^^^^^^^^^^ help: replace the closure with the method itself: `jrsonnet_gcmodule::ObjectSpace::leak`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
= note: `-W clippy::redundant-closure-for-method-calls` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::redundant_closure_for_method_calls)]`
Check warning on line 91 in crates/jrsonnet-cli/src/lib.rs
github-actions / clippy
consider adding a `;` to the last statement for consistent formatting
warning: consider adding a `;` to the last statement for consistent formatting
--> crates/jrsonnet-cli/src/lib.rs:91:3
|
91 | with_thread_object_space(|s| s.leak())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `with_thread_object_space(|s| s.leak());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
= note: `-W clippy::semicolon-if-nothing-returned` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::semicolon_if_nothing_returned)]`
Check warning on line 121 in crates/jrsonnet-cli/src/stdlib.rs
github-actions / clippy
it is more concise to loop over references to containers instead of using explicit iteration methods
warning: it is more concise to loop over references to containers instead of using explicit iteration methods
--> crates/jrsonnet-cli/src/stdlib.rs:121:14
|
121 | for ext in self.ext_code_file.iter() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&self.ext_code_file`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop
Check warning on line 118 in crates/jrsonnet-cli/src/stdlib.rs
github-actions / clippy
it is more concise to loop over references to containers instead of using explicit iteration methods
warning: it is more concise to loop over references to containers instead of using explicit iteration methods
--> crates/jrsonnet-cli/src/stdlib.rs:118:14
|
118 | for ext in self.ext_code.iter() {
| ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&self.ext_code`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop
Check warning on line 115 in crates/jrsonnet-cli/src/stdlib.rs
github-actions / clippy
it is more concise to loop over references to containers instead of using explicit iteration methods
warning: it is more concise to loop over references to containers instead of using explicit iteration methods
--> crates/jrsonnet-cli/src/stdlib.rs:115:14
|
115 | for ext in self.ext_str_file.iter() {
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&self.ext_str_file`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop
Check warning on line 112 in crates/jrsonnet-cli/src/stdlib.rs
github-actions / clippy
it is more concise to loop over references to containers instead of using explicit iteration methods
warning: it is more concise to loop over references to containers instead of using explicit iteration methods
--> crates/jrsonnet-cli/src/stdlib.rs:112:14
|
112 | for ext in self.ext_str.iter() {
| ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&self.ext_str`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop
= note: `-W clippy::explicit-iter-loop` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::explicit_iter_loop)]`
Check warning on line 46 in crates/jrsonnet-cli/src/stdlib.rs
github-actions / clippy
unnecessary structure name repetition
warning: unnecessary structure name repetition
--> crates/jrsonnet-cli/src/stdlib.rs:46:15
|
46 | None => Ok(ExtStr {
| ^^^^^^ help: use the applicable keyword: `Self`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
Check warning on line 42 in crates/jrsonnet-cli/src/stdlib.rs
github-actions / clippy
unnecessary structure name repetition
warning: unnecessary structure name repetition
--> crates/jrsonnet-cli/src/stdlib.rs:42:20
|
42 | Some(idx) => Ok(ExtStr {
| ^^^^^^ help: use the applicable keyword: `Self`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
= note: `-W clippy::use-self` implied by `-W clippy::nursery`
= help: to override `-W clippy::nursery` add `#[allow(clippy::use_self)]`
Check warning on line 419 in crates/jrsonnet-stdlib/src/lib.rs
github-actions / clippy
consider adding a `;` to the last statement for consistent formatting
warning: consider adding a `;` to the last statement for consistent formatting
--> crates/jrsonnet-stdlib/src/lib.rs:419:3
|
419 | self.settings_mut().context_initializer = tb!(initializer)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `self.settings_mut().context_initializer = tb!(initializer);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
Check warning on line 326 in crates/jrsonnet-stdlib/src/lib.rs
github-actions / clippy
used binding `_s` which is prefixed with an underscore. A leading underscore signals that a binding will not be used
warning: used binding `_s` which is prefixed with an underscore. A leading underscore signals that a binding will not be used
--> crates/jrsonnet-stdlib/src/lib.rs:326:53
|
326 | let mut context = ContextBuilder::with_capacity(_s, 1);
| ^^
|
note: `_s` is defined here
--> crates/jrsonnet-stdlib/src/lib.rs:312:13
|
312 | pub fn new(_s: State, resolver: PathResolver) -> Self {
| ^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_binding
= note: `-W clippy::used-underscore-binding` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::used_underscore_binding)]`
Check warning on line 315 in crates/jrsonnet-stdlib/src/lib.rs
github-actions / clippy
calling `HashMap::default()` is more clear than this expression
warning: calling `HashMap::default()` is more clear than this expression
--> crates/jrsonnet-stdlib/src/lib.rs:315:17
|
315 | ext_natives: Default::default(),
| ^^^^^^^^^^^^^^^^^^ help: try: `HashMap::default()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#default_trait_access
Check warning on line 314 in crates/jrsonnet-stdlib/src/lib.rs
github-actions / clippy
calling `HashMap::default()` is more clear than this expression
warning: calling `HashMap::default()` is more clear than this expression
--> crates/jrsonnet-stdlib/src/lib.rs:314:14
|
314 | ext_vars: Default::default(),
| ^^^^^^^^^^^^^^^^^^ help: try: `HashMap::default()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#default_trait_access
= note: `-W clippy::default-trait-access` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::default_trait_access)]`
Check warning on line 274 in crates/jrsonnet-stdlib/src/lib.rs
github-actions / clippy
use Option::map_or_else instead of an if let/else
warning: use Option::map_or_else instead of an if let/else
--> crates/jrsonnet-stdlib/src/lib.rs:271:5
|
271 | / match loc.0.source_path().path() {
272 | | Some(p) => self.resolver.resolve(p),
273 | | None => loc.0.source_path().to_string(),
274 | | },
| |_________________^ help: try: `loc.0.source_path().path().map_or_else(|| loc.0.source_path().to_string(), |p| self.resolver.resolve(p))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else
Check warning on line 199 in crates/jrsonnet-stdlib/src/lib.rs
github-actions / clippy
used `cloned` where `copied` could be used instead
warning: used `cloned` where `copied` could be used instead
--> crates/jrsonnet-stdlib/src/lib.rs:199:3
|
199 | .cloned()
| ^^^^^^ help: try: `copied`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied
= note: `-W clippy::cloned-instead-of-copied` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::cloned_instead_of_copied)]`
Check warning on line 250 in crates/jrsonnet-stdlib/src/lib.rs
github-actions / clippy
this function has too many lines (176/100)
warning: this function has too many lines (176/100)
--> crates/jrsonnet-stdlib/src/lib.rs:51:1
|
51 | / pub fn stdlib_uncached(settings: Rc<RefCell<Settings>>) -> ObjValue {
52 | | let mut builder = ObjValueBuilder::new();
53 | |
54 | | let expr = expr::stdlib_expr();
... |
249 | | builder.build()
250 | | }
| |_^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines
= note: `-W clippy::too-many-lines` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::too_many_lines)]`
Check warning on line 74 in crates/jrsonnet-stdlib/src/misc.rs
github-actions / clippy
use Option::map_or_else instead of an if let/else
warning: use Option::map_or_else instead of an if let/else
--> crates/jrsonnet-stdlib/src/misc.rs:70:2
|
70 | / if let Some(rest) = rest {
71 | | rest.evaluate()
72 | | } else {
73 | | Ok(str)
74 | | }
| |_____^ help: try: `rest.map_or_else(|| Ok(str), |rest| rest.evaluate())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else
Check warning on line 151 in crates/jrsonnet-stdlib/src/strings.rs
github-actions / clippy
casting `u32` to `f64` may become silently lossy if you later change the type
warning: casting `u32` to `f64` may become silently lossy if you later change the type
--> crates/jrsonnet-stdlib/src/strings.rs:151:26
|
151 | Ok(base * aggregate + digit as f64)
| ^^^^^^^^^^^^ help: try: `f64::from(digit)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
Check warning on line 151 in crates/jrsonnet-stdlib/src/strings.rs
github-actions / clippy
multiply and add expressions can be calculated more efficiently and accurately
warning: multiply and add expressions can be calculated more efficiently and accurately
--> crates/jrsonnet-stdlib/src/strings.rs:151:7
|
151 | Ok(base * aggregate + digit as f64)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `base.mul_add(aggregate, digit as f64)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suboptimal_flops
= note: `-W clippy::suboptimal-flops` implied by `-W clippy::nursery`
= help: to override `-W clippy::nursery` add `#[allow(clippy::suboptimal_flops)]`
Check warning on line 148 in crates/jrsonnet-stdlib/src/strings.rs
github-actions / clippy
use Option::map_or_else instead of an if let/else
warning: use Option::map_or_else instead of an if let/else
--> crates/jrsonnet-stdlib/src/strings.rs:142:15
|
142 | let digit = if let Some(digit) = checked_sub_if(BASE > 10, digit, LOWER_A_CODE) {
| _____________________^
143 | | digit + 10
144 | | } else if let Some(digit) = checked_sub_if(BASE > 10, digit, UPPER_A_CODE) {
145 | | digit + 10
146 | | } else {
147 | | digit.checked_sub(ZERO_CODE).unwrap_or(BASE)
148 | | };
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else
help: try
|
142 ~ let digit = checked_sub_if(BASE > 10, digit, LOWER_A_CODE).map_or_else(|| if let Some(digit) = checked_sub_if(BASE > 10, digit, UPPER_A_CODE) {
143 ~ digit + 10
144 ~ } else {
145 ~ digit.checked_sub(ZERO_CODE).unwrap_or(BASE)
146 ~ }, |digit| digit + 10);
|
Check warning on line 138 in crates/jrsonnet-stdlib/src/strings.rs
github-actions / clippy
casting `u32` to `f64` may become silently lossy if you later change the type
warning: casting `u32` to `f64` may become silently lossy if you later change the type
--> crates/jrsonnet-stdlib/src/strings.rs:138:13
|
138 | let base = BASE as f64;
| ^^^^^^^^^^^ help: try: `f64::from(BASE)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
= note: `-W clippy::cast-lossless` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::cast_lossless)]`
Check warning on line 136 in crates/jrsonnet-stdlib/src/strings.rs
github-actions / clippy
adding items after statements is confusing, since items exist from the start of the scope
warning: adding items after statements is confusing, since items exist from the start of the scope
--> crates/jrsonnet-stdlib/src/strings.rs:130:2
|
130 | / fn checked_sub_if(condition: bool, lhs: u32, rhs: u32) -> Option<u32> {
131 | | if condition {
132 | | lhs.checked_sub(rhs)
133 | | } else {
134 | | None
135 | | }
136 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
Check warning on line 127 in crates/jrsonnet-stdlib/src/strings.rs
github-actions / clippy
adding items after statements is confusing, since items exist from the start of the scope
warning: adding items after statements is confusing, since items exist from the start of the scope
--> crates/jrsonnet-stdlib/src/strings.rs:127:2
|
127 | const LOWER_A_CODE: u32 = 'a' as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
Check warning on line 126 in crates/jrsonnet-stdlib/src/strings.rs
github-actions / clippy
adding items after statements is confusing, since items exist from the start of the scope
warning: adding items after statements is confusing, since items exist from the start of the scope
--> crates/jrsonnet-stdlib/src/strings.rs:126:2
|
126 | const UPPER_A_CODE: u32 = 'A' as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements