carlosahs commented on issue #18881:
URL: https://github.com/apache/datafusion/issues/18881#issuecomment-3620944778

   Hi all. When trying to use `#[expect]` in 
https://github.com/apache/datafusion/blob/6746007826ebd3fcb5614bf87183674435bbb134/datafusion/physical-optimizer/src/aggregate_statistics.rs#L43-L98
 I get the following error when running `sh ci/scripts/rust_clippy.sh`:
   
   ```
   error: this lint expectation is unfulfilled
     --> datafusion/physical-optimizer/src/aggregate_statistics.rs:44:14
      |
   44 |     #[expect(clippy::only_used_in_recursion)]
      |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = note: `-D unfulfilled-lint-expectations` implied by `-D warnings`
      = help: to override `-D warnings` add 
`#[allow(unfulfilled_lint_expectations)]`
   
   error: could not compile `datafusion-physical-optimizer` (lib) due to 1 
previous error
   ```
   
   Took a look at https://github.com/rust-lang/rust-clippy/issues/14566 and If 
I run `cargo clippy -p datafusion-physical-optimizer -- -D warnings`, I don't 
get any errors as lint expectation is fulfilled. But if I run `cargo clippy 
cargo clippy -p datafusion-physical-optimizer -p datafusion -- -D warnings`, I 
get the same error as above. Tried with other package combinations and seems 
like `clippy::only_used_in_recursion` is only unfulfilled when `datafusion` is 
included, thus the unfulfilled lint error when running `sh 
ci/scripts/rust_clippy.sh`.
   
   Checked for references of `optmize_plan` in `datafusion` crate and it's used 
in:
   + 
https://github.com/apache/datafusion/blob/6746007826ebd3fcb5614bf87183674435bbb134/datafusion/core/tests/physical_optimizer/aggregate_statistics.rs#L73-L74
   + 
https://github.com/apache/datafusion/blob/6746007826ebd3fcb5614bf87183674435bbb134/datafusion/core/tests/physical_optimizer/aggregate_statistics.rs#L272-L273
   + 
https://github.com/apache/datafusion/blob/6746007826ebd3fcb5614bf87183674435bbb134/datafusion/core/tests/physical_optimizer/aggregate_statistics.rs#L318-L319
   
   Anyone has any insights as to why `clippy::only_used_in_recursion` is only 
unfulfilled when `datafusion` package is included?
   
   Some things I've tried:
   
   + Commented the `optmize_plan` references in `datafusion` to check if it had 
any effect on the lint fulfillment but lint error persists,
   + Removed `clippy::only_used_in_recursion` but then I get
     ```
     error: parameter is only used in recursion
       --> datafusion/physical-optimizer/src/aggregate_statistics.rs:48:9
        |
     48 |         context: &OptimizerContext,
        |         ^^^^^^^ help: if this is intentional, prefix it with an 
underscore: `_context`
        |
     note: parameter used here
       --> datafusion/physical-optimizer/src/aggregate_statistics.rs:88:47
        |
     88 |                     self.optimize_plan(child, 
context).map(Transformed::yes)
        |                                               ^^^^^^^
     ...
     94 |                 self.optimize_plan(child, 
context).map(Transformed::yes)
        |                                           ^^^^^^^
        = help: for further information visit 
https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#only_used_in_recursion
        = note: `-D clippy::only-used-in-recursion` implied by `-D warnings`
        = help: to override `-D warnings` add 
`#[allow(clippy::only_used_in_recursion)]`
     
     error: could not compile `datafusion-physical-optimizer` (lib) due to 1 
previous error
     ```
     when running `cargo clippy -p datafusion-physical-optimizer -- -D 
warnings` and no errors when running `sh ci/scripts/rust_clippy.sh`.
   
   Some solutions I'm thinking about:
   
   + Try to implement `optimize_plan` without recursion,
   + Try to define a helper recursion function within `optimize_plan` so that 
it only takes on `plan` variables and then prefix `context` with an underscore.
   + Maybe there is a simple solution involving some clippy configuration that 
I'm unable to see right now.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to