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

Remove pre-NLL borrow checker workarounds #1036

Merged
merged 1 commit into from
Jul 11, 2023
Merged

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Jul 11, 2023

NLL has been in use since Rust 1.31 (for edition 2018+) or Rust 1.36 (for edition 2015).

error[E0505]: cannot move out of `json` because it is borrowed
   --> src/raw.rs:184:29
    |
180 |             let borrowed = ::from_str::<&Self>(&json)?;
    |                                                 ---- borrow of `json` occurs here
...
184 |         Ok(Self::from_owned(json.into_boxed_str()))
    |                             ^^^^ move out of `json` occurs here

error[E0499]: cannot borrow `self.formatter` as mutable more than once at a time
   --> src/ser.rs:453:13
    |
444 |                 formatter: &mut self.formatter,
    |                                 -------------- first mutable borrow occurs here
...
453 |             self.formatter
    |             ^^^^^^^^^^^^^^ second mutable borrow occurs here
...
456 |     }
    |     - first borrow ends here

error[E0499]: cannot borrow `self.writer` as mutable more than once at a time
   --> src/ser.rs:454:34
    |
443 |                 writer: &mut self.writer,
    |                              ----------- first mutable borrow occurs here
...
454 |                 .end_string(&mut self.writer)
    |                                  ^^^^^^^^^^^ second mutable borrow occurs here
...
456 |     }
    |     - 

NLL has been in use since Rust 1.31 (for edition 2018+) or Rust
1.36 (for edition 2015).

    error[E0505]: cannot move out of `json` because it is borrowed
       --> src/raw.rs:184:29
        |
    180 |             let borrowed = ::from_str::<&Self>(&json)?;
        |                                                 ---- borrow of `json` occurs here
    ...
    184 |         Ok(Self::from_owned(json.into_boxed_str()))
        |                             ^^^^ move out of `json` occurs here

    error[E0499]: cannot borrow `self.formatter` as mutable more than once at a time
       --> src/ser.rs:453:13
        |
    444 |                 formatter: &mut self.formatter,
        |                                 -------------- first mutable borrow occurs here
    ...
    453 |             self.formatter
        |             ^^^^^^^^^^^^^^ second mutable borrow occurs here
    ...
    456 |     }
        |     - first borrow ends here

    error[E0499]: cannot borrow `self.writer` as mutable more than once at a time
       --> src/ser.rs:454:34
        |
    443 |                 writer: &mut self.writer,
        |                              ----------- first mutable borrow occurs here
    ...
    454 |                 .end_string(&mut self.writer)
        |                                  ^^^^^^^^^^^ second mutable borrow occurs here
    ...
    456 |     }
        |     - first borrow ends here
@dtolnay dtolnay merged commit 6c8523f into serde-rs:master Jul 11, 2023
13 checks passed
@dtolnay dtolnay deleted the nll branch July 11, 2023 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant