Skip to content

Use last-use to provide "fixit" hints #3755

Closed
@catamorphism

Description

@catamorphism

Now that last-use is gone, it would be good to use it to provide feedback in error messages. I can imagine two ways to do this:

  1. I changed the kind checker to suggest adding a move in some cases where a noncopyable value gets copied. However, it may suggest it in a situation where a move would be illegal, which is kind of rude. The kind checker could use last-use results to provide a more accurate error message.
  2. There may be situations now where there are copies that could instead be moves (because they're actually last-uses, but copying is legal). A lint pass based on last-use results could warn about these. I don't know if it's possible for such a situation to arise, though (maybe these are all "noncopyable" errors or "non-implicitly-copyable" warnings now, I'm not sure).

Of course, if we end up doing @nikomatsakis 's "move or copy based on type" idea, both of these points will be moot.

This was part of #2633, but I wanted to close #2633.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions