Skip to content

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

Closed

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

Activity

  1. added this to the NLL prototype milestone on Nov 25, 2017
  2. KiChjang commented on Nov 26, 2017

    @KiChjang
    ContributorAuthor

    Possibly related to #45537.

  3. nikomatsakis commented on Nov 28, 2017

    @nikomatsakis
    Contributor

    @arielb1 can you elaborate on why you think that this test ought to report a compilation error? I don't understand why that is true.

    (Among other things, the code does compile today -- i.e., without NLL etc.)

  4. arielb1 commented on Nov 28, 2017

    @arielb1
    Contributor

    @nikomatsakis

    The test is not supposed to cause a compilation error. The bug is that the test fails to compile with -Z nll.

  5. nikomatsakis commented on Dec 12, 2017

    @nikomatsakis
    Contributor

    Fixed

  6. pnkfelix commented on Jul 28, 2018

    @pnkfelix
    Contributor

    Wait a minute: does this test work or not? Has it been reenabled on master yet? Is there a latent bug in NLL still?

  7. self-assigned this
    on Jul 28, 2018
  8. matthewjasper commented on Aug 3, 2018

    @matthewjasper
    Contributor

    The test was reenabled in #46320.

  9. pnkfelix commented on Aug 4, 2018

    @pnkfelix
    Contributor

    Thanks @matthewjasper sorry for the noise,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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