Skip to content

Borrow checker on beta rejects code accepted on stable. #60927

Closed
@khuey

Description

@khuey

See the repo at https://github.com/khuey/rust-nightly-borrow-checker-failure

This repository builds on 1.34.2. It fails on 1.35.0-beta.8 with

error[E0597]: `global_lock` does not live long enough
  --> src/lib.rs:24:26
   |
24 |             let locked = global_lock.as_ref().lock().unwrap();
   |                          ^^^^^^^^^^^ borrowed value does not live long enough
25 |             ptr::write(&mut self.global_lock, Some(locked));
   |                        --------------------- cast requires that `global_lock` is borrowed for `'static`
26 |         }
27 |     }
   |     - `global_lock` dropped here while still borrowed

error: aborting due to previous error

Metadata

Metadata

Assignees

Labels

A-borrow-checkerArea: The borrow checkerC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions