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

Point to let when modifying field of immutable variable #40445

Merged
merged 3 commits into from
Mar 19, 2017

Commits on Mar 11, 2017

  1. Point to let when modifying field of immutable variable

    Point at the immutable local variable when trying to modify one of its
    fields.
    
    Given a file:
    
    ```rust
    struct Foo {
        pub v: Vec<String>
    }
    
    fn main() {
        let f = Foo { v: Vec::new() };
        f.v.push("cat".to_string());
    }
    ```
    
    present the following output:
    
    ```
    error: cannot borrow immutable field `f.v` as mutable
     --> file.rs:7:13
      |
    6 |    let f = Foo { v: Vec::new() };
      |        - this should be `mut`
    7 |    f.v.push("cat".to_string());
      |    ^^^
    
    error: aborting due to previous error
    ```
    estebank committed Mar 11, 2017
    Configuration menu
    Copy the full SHA
    6ba494b View commit details
    Browse the repository at this point in the history

Commits on Mar 12, 2017

  1. Change label to "consider changing this to mut f"

    Change the wording of mutable borrow on immutable binding from "this
    should be `mut`" to "consider changing this to `mut f`".
    estebank committed Mar 12, 2017
    Configuration menu
    Copy the full SHA
    38b5b29 View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2017

  1. Configuration menu
    Copy the full SHA
    9ac628d View commit details
    Browse the repository at this point in the history