Skip to content
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

borrowed_box gives syntactically invalid suggestion #3128

Closed
vks opened this issue Sep 4, 2018 · 8 comments · Fixed by #6200
Closed

borrowed_box gives syntactically invalid suggestion #3128

vks opened this issue Sep 4, 2018 · 8 comments · Fixed by #6200
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@vks
Copy link
Contributor

vks commented Sep 4, 2018

It suggests &mut Trait + 'a, which is invalid syntax. It should be &mut (Trait + 'a) instead.

@phansch phansch added the C-bug Category: Clippy is not doing the correct thing label Sep 6, 2018
@phansch
Copy link
Member

phansch commented Sep 6, 2018

Thank you for the report!
Could you provide a small code snippet that produces the lint with the incorrect suggestion? You can use play.rust-lang.org which has Clippy available under 'Tools' on the right.

@logannc
Copy link

logannc commented Oct 25, 2018

https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=07873a52c9615f8f6b6ba782fdf3e9fe

It isn't really an incorrect suggestion (though it may be a bad one - I dont know) so much that if you do it verbatim it cannot possibly compile due to rustc parsing limitations. Though it can also require changing the callsite which may or may not be unwanted for this lint.

@logannc
Copy link

logannc commented Oct 25, 2018

Actually, borrowed_box in the context of a trait object might usually be an incorrect lint... (not confident enough to say always).

@mati865
Copy link
Contributor

mati865 commented Oct 25, 2018

@logannc it builds and applying clippy suggestion causes compiler error similar to OP's. Therefore that's good example, thanks!

@JohnTitor JohnTitor added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Dec 26, 2019
@mgr-inz-rafal
Copy link
Contributor

I just stumbled upon the same issue, here's one more link to the playground :)

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1f119c4d2e02176783b3106b0ca743b7

@ThibsG
Copy link
Contributor

ThibsG commented Aug 27, 2020

Weird but it seems that the lint doesn't trigger anymore, can anyone confirm? Same for #3971 no?

@rail-rain
Copy link
Contributor

I believe it's because of the lint now ignores every mutable references (#5491), and both of the two playground link uses mutable references. However, this issue is actually unrelated to mutability. It happens when the trait objects have auto traits or lifetime bounds.

playground link that uses an immutable reference

@rail-rain
Copy link
Contributor

@rust-lang/clippy. I think you'd better reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants