Skip to content

Warn about unnecessary heap allocations #6145

Description

@jruderman

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?).

Activity

  1. Aatch commented on May 1, 2013

    @Aatch
    Contributor

    Nominating for maturity 5, production ready.

  2. kud1ing commented on May 22, 2013

    @kud1ing

    Is this fixed by #6647?

  3. sanxiyn commented on May 23, 2013

    @sanxiyn
    Contributor

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

  4. kud1ing commented on May 23, 2013

    @kud1ing

    Very good, thanks.

  5. jruderman commented on May 24, 2013

    @jruderman
    ContributorAuthor

    Is the lint only for strings and vecs?

  6. sanxiyn commented on May 24, 2013

    @sanxiyn
    Contributor

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

  7. added a commit that references this issue on May 27, 2013
    b0f3686
  8. added a commit that references this issue on Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions