-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Extern fn declarations can have dangling lifetimes #35851
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
Comments
Probably would be a breaking change to fix. But soundness. |
Elision was never added to them. cc @rust-lang/lang |
Seems fine to break to me. References in extern blocks is very likely not what you want anyway for non-Rust ABIs (i.e. is a bug). |
Well, it also happens with lifetime parameter elision. For the servo-gecko stuff we've managed to configure bindgen to return typedefs to types with lifetimes for things which are conceptually borrows. So we're using lifetime params in ffi today 😄 (thats how I discovered this, someone else added a dangling lifetime and I was bewildered by it. We're going to merge it for now because my safer bindings glue isn't complete yet, so the input lifetime for that function can't exist yet, but it will soon) |
Discussed in @rust-lang/lang meeting. This is definitely a bug; we should "just fix it". We should measure the impact, of course. |
triage: P-medium |
@eddyb So I presume that we don't currently have the lazy-start branch in tree, since this hasn't been fixed. Perhaps the two codepaths were un-unified? |
Yeah, I redid some things, and tried to avoid regressing anything at all. |
It would probably be good to deprecate (future compat warning?) code using this pattern. |
Well, for sure we should deprecate. It doesn't necessarily have to be a future-compat warning. i.e., we could live with this. |
I'd like to tackle this issue. How shall we begin? |
Seems fixed, there's a test for it here. |
Indeed it seems so; closing therefore. |
(playpen)
compiles fine. The
&u8
has a dangling lifetime, which doesn't compile for functions that have bodies.This probably should throw an error.
The text was updated successfully, but these errors were encountered: