Skip to content

region-liveness-drop-no-may-dangle.rs compilation failure on MIR borrowck #46267

Closed
@KiChjang

Description

@KiChjang

Compiling with -Zborrowck-mir does not reveal the problem, but compiling with -Znll does:

error[E0597]: borrowed value does not live long enough (Mir)
  --> /home/keith/Workspace/rust/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs:26:51
   |
25 |     let mut v = [1, 2, 3];
   |         ----- temporary value created here
26 |     let p: Wrap<& /* R1 */ usize> = Wrap { value: &v[0] };
   |                                                   ^^^^^ temporary value dropped here while still borrowed
   |
   = note: consider using a `let` binding to increase its lifetime

@arielb1 said that this is due to us having an incorrect MIR borrowck before, and this should really throw a compilation error as seen.

Temporarily disabling this test in order to land my patch at #46100.

cc @nikomatsakis @arielb1 @pnkfelix

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions