Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
KiChjang opened this issue Nov 25, 2017 · 7 comments
Closed
Assignees
Labels
C-bug Category: This is a bug.
Milestone

Comments

@KiChjang
Copy link
Member

KiChjang commented Nov 25, 2017

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

@arielb1 arielb1 added this to the NLL prototype milestone Nov 25, 2017
@KiChjang
Copy link
Member Author

Possibly related to #45537.

@nikomatsakis
Copy link
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.)

@arielb1
Copy link
Contributor

arielb1 commented Nov 28, 2017

@nikomatsakis

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

@TimNN TimNN added the C-bug Category: This is a bug. label Nov 28, 2017
@nikomatsakis
Copy link
Contributor

Fixed

@pnkfelix
Copy link
Member

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

@pnkfelix pnkfelix reopened this Jul 28, 2018
@pnkfelix pnkfelix self-assigned this Jul 28, 2018
@matthewjasper
Copy link
Contributor

The test was reenabled in #46320.

@pnkfelix
Copy link
Member

pnkfelix commented Aug 4, 2018

Thanks @matthewjasper sorry for the noise,

@pnkfelix pnkfelix closed this as completed Aug 4, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

6 participants