Skip to content

Don't suggest ref for let bindings. #40402

Closed
@steveklabnik

Description

@steveklabnik

UPDATE: There are some initial mentoring instructions below.


fn main() {
    let v = vec![String::from("oh no")];
    
    let e = v[0];
}

suggests

error[E0507]: cannot move out of indexed content
 --> <anon>:4:13
  |
4 |     let e = v[0];
  |         -   ^^^^ cannot move out of indexed content
  |         |
  |         hint: to prevent move, use `ref e` or `ref mut e`

let ref e is not idiomatic here, so this is misleading (and confusing, frankly)

cc @eevee

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions