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

Warn about unnecessary heap allocations #6145

Closed
jruderman opened this issue May 1, 2013 · 6 comments
Closed

Warn about unnecessary heap allocations #6145

jruderman opened this issue May 1, 2013 · 6 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@jruderman
Copy link
Contributor

Per https://mail.mozilla.org/pipermail/rust-dev/2013-April/003867.html these are unnecessarily inefficient:

~"foo" == x

x == ~"foo"

More generally, whenever a heap literal (~value or @value) appears where a borrow is used, the compiler could warn. I'm not sure if want this to apply to all locals or only some (small ones? temporaries within expressions?).

@Aatch
Copy link
Contributor

Aatch commented May 1, 2013

Nominating for maturity 5, production ready.

@kud1ing
Copy link

kud1ing commented May 22, 2013

Is this fixed by #6647?

@sanxiyn
Copy link
Member

sanxiyn commented May 23, 2013

@kud1ing, not yet, because #6647 is restricted to function arguments and does not cover operator overloading. But I have a branch that fixes this.

@kud1ing
Copy link

kud1ing commented May 23, 2013

Very good, thanks.

@jruderman
Copy link
Contributor Author

Is the lint only for strings and vecs?

@sanxiyn
Copy link
Member

sanxiyn commented May 24, 2013

Yes, it only warns about string and vector literals at the moment, but I do plan to extend the lint to cover more cases.

bors added a commit that referenced this issue May 27, 2013
Fix #6145. In particular, handle operator overloading.
@sanxiyn sanxiyn closed this as completed May 29, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 9, 2020
Backport remerge

Step 1 in the release process.

r? `@ghost`

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants