Skip to content

Clippy identifying an immediate dereferencing of a reference #474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Libbum opened this issue Jul 8, 2018 · 3 comments
Closed

Clippy identifying an immediate dereferencing of a reference #474

Libbum opened this issue Jul 8, 2018 · 3 comments

Comments

@Libbum
Copy link
Contributor

Libbum commented Jul 8, 2018

Just did a clippy lint over a project I'm trying to dust off, and managed to hit a whole heap of these:

warning: immediately dereferencing a reference
   --> src/grid.rs:342:43
    |
342 |                         let l = phi.slice(s![lx - 2..lx + 3, ly - 2..ly + 3, lz - 2..lz + 3]);
    |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#deref_addrof
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
help: try this
    |
39  | & match $ r {
40  | r => {
41  | s ! [
42  | @ parse $ crate :: SliceNextDim :: next_dim ( & r , $ dim ) , [
43  | $ ( $ stack ) * s ! ( @ convert r ) , ] $ ( $ t ) * ] } } } ;

The macro it's highlighting is this one, but adding the suggested additional ampersand isn't the entire solution (if it is at least part of it).

My macro capability is close to 0, so hopefully someone else can identify a fix.

@jturner314
Copy link
Member

My guess is that this warning is a result of this workaround for compiler bug rust-lang/rust#23014. I just tried removing the extra *& on the latest stable compiler (1.27), but the workaround is still necessary.

I just tried a few different ways of adding an annotation to tell clippy to ignore this, but didn't have much success getting anything that allowed the tests to compile. (The compiler gave a variety of errors for my attempts, the most common one being error[E0658]: attributes on expressions are experimental. (see issue #15701).)

If anyone can find a way to add an attribute to tell clippy to ignore this, please feel free to submit a PR.

@lambda-fairy
Copy link

I recall that Clippy has special logic to ignore macro-expanded code. Could that logic be added to this lint?

(I also notice that this bug is two years old, so that may have been done already.)

@bluss
Copy link
Member

bluss commented Mar 29, 2021

Closing since the macro involved etc has changed, probably not relevant now.

@bluss bluss closed this as completed Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants