Skip to content

Improve diagnostics to guide users past Borrow checking regression in brotli #47349

Closed
@SimonSapin

Description

@SimonSapin

I mean regression in the sense that code that used to compile doesn’t anymore. Maybe that is an intentional soundness fix.

Compiling https://crates.io/crates/brotli / https://github.com/dropbox/rust-brotli with:

  • rustc 1.25.0-nightly (61452e5 2018-01-09): OK
  • rustc 1.25.0-nightly (f62f774 2018-01-10): borrowck error:
error[E0502]: cannot borrow `self.buckets_` as immutable because it is also borrowed as mutable
   --> src/enc/backward_references.rs:339:51
    |
338 |     (*self).buckets_.slice_mut()[(key as (usize)).wrapping_add((cur_ix >> 3)
    |     ---------------- mutable borrow occurs here
339 |                                     .wrapping_rem(self.buckets_.BUCKET_SWEEP() as
    |                                                   ^^^^^^^^^^^^^ immutable borrow occurs here
340 |                                                   usize))] = cur_ix as (u32);
    |                                                          - mutable borrow ends here

error: aborting due to previous error

error: Could not compile `brotli`.

Commit range: 61452e5...f62f774. #47167 seems relevant. CC @ivanbakel @eddyb

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.NLL-diagnosticsWorking towards the "diagnostic parity" goalP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions