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

Suggest ".clone" for "use of moved value" if the thing is cloneable #11345

Closed
pcwalton opened this issue Jan 6, 2014 · 3 comments
Closed

Suggest ".clone" for "use of moved value" if the thing is cloneable #11345

pcwalton opened this issue Jan 6, 2014 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@pcwalton
Copy link
Contributor

pcwalton commented Jan 6, 2014

This might help alleviate some confusion.

@reem
Copy link
Contributor

reem commented Sep 3, 2014

Triage.

I teach a relatively high number of people Rust face-to-face and when you are just learning "stick .clone everywhere" is shockingly common. Often, this is not actually needed, but it takes a while to learn the right way to structure code to avoid tons of clones. For this reason I think that the correct thing to do when confronted with "use of moved value" is to refactor, use references, and learn about ownership rather than blindly call .clone, ergo we shouldn't encourage it.

@steveklabnik
Copy link
Member

I would agree with that.

@steveklabnik steveklabnik added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Feb 10, 2015
@steveklabnik
Copy link
Member

Since new lints have a big impact on users of rustc, the policy is that they should go through the RFC process like other user-facing changes. As such, I'm going to give this one a close, but if anyone comes across this ticket and wants this lint, consider adding it to clippy and/or writing up an RFC. Thanks!

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 7, 2023
new lint: `iter_out_of_bounds`

Closes rust-lang#11345

The original idea in the linked issue seemed to be just about arrays afaict, but I extended this to catch some other iterator sources such as `iter::once` or `iter::empty`.

I'm not entirely sure if this name makes a lot of sense now that it's not just about arrays anymore (specifically, not sure if you can call `.take(1)` on an `iter::Empty` to be "out of bounds"?).

changelog: [`iter_out_of_bounds`]: new lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

3 participants