Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ref<T> and &T have different lifetime requirements #37785

Closed
KiChjang opened this issue Nov 15, 2016 · 5 comments
Closed

Ref<T> and &T have different lifetime requirements #37785

KiChjang opened this issue Nov 15, 2016 · 5 comments
Labels
A-destructors Area: Destructors (`Drop`, …) A-lifetimes Area: Lifetimes / regions C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@KiChjang
Copy link
Member

This does not compile: https://is.gd/aNuNEg

This compiles: https://is.gd/lInFDJ

Found when trying to solve servo/servo#13418 (comment)

@bluss
Copy link
Member

bluss commented Nov 15, 2016

Ref has the drop-check rule because it has a destructor (Essentially issue #22321)

@KalitaAlexey
Copy link
Contributor

Dear @bluss,
Is there any work in progress on it?

@Mark-Simulacrum Mark-Simulacrum added the A-lifetimes Area: Lifetimes / regions label May 16, 2017
@Mark-Simulacrum Mark-Simulacrum added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-destructors Area: Destructors (`Drop`, …) labels Jul 26, 2017
@memoryruins
Copy link
Contributor

memoryruins commented Jan 30, 2019

Triage: now compiles on 2018.
2015 errors:

error[E0597]: borrowed value does not live long enough
  --> src/main.rs:18:9
   |
18 |         Document { url: RefCell::new("hi".into()) }.url().clone()
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
19 |     }
   |     - temporary value dropped here while still borrowed
   |
   = note: values in a scope are dropped in the opposite order they are created

rustc: 1.32.0

edit: removing fixed-by-nll tag as I am not certain how it affects drop glue. pointing this out in another triage thread.

@memoryruins memoryruins added NLL-fixed-by-NLL Bugs fixed, but only when NLL is enabled. and removed NLL-fixed-by-NLL Bugs fixed, but only when NLL is enabled. labels Jan 30, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Feb 1, 2019

FYI @memoryruins The use of NLL should not affect the dynamic semantics, at least in terms of when values are dropped.

Therefore the use of NLL-fixed-by-NLL might remain appropriate here. I'm investigating now.

@matthewjasper
Copy link
Contributor

Closing since the code now compiles on both editions on nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-destructors Area: Destructors (`Drop`, …) A-lifetimes Area: Lifetimes / regions C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

7 participants