-
Notifications
You must be signed in to change notification settings - Fork 192
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
NV_low_latency2 Impossible to use timings
array after mutably borrowing in GetLatencyMarkerInfoNV
#837
Comments
This definition for pub fn timings<'b: 'a>(mut self, timings: &'a mut [LatencyTimingsFrameReportNV<'b>]) -> Self {
self.timing_count = timings.len() as _;
self.p_timings = timings.as_mut_ptr().cast();
self
} There are two changes: introducing the longer lifetime |
Yeah, separating the lifetime of the slice from the lifetime of the nested borrow in let mut info = vk::GetLatencyMarkerInfoNV::default();
{
let mut timings = vec![vk::LatencyTimingsFrameReportNV::default()];
info = info.timings(&mut timings);
}
dbg!(&info); EDIT: Neither am I allowed to interact with That compiler warning suggesting the cast the other way around barely makes any sense, however... |
Yeah, the cast is required because
Sorry, what warning? |
Incidentally, I think we can omit the explicit lifetime name, since |
With this definition: pub fn timings(mut self, timings: &'a mut [LatencyTimingsFrameReportNV<'_>]) -> Self { Correct use compiles fine, and I get sensible errors for both incorrect use patterns:
Illegal aliasing:
|
The error when not using
|
Do you want to tackle this, or should I? |
CC @repi @VZout, in case you run into this while incorporating the updated extension bindings in your code. This happens after #816 was merged.
The
timings()
builder function onGetLatencyMarkerInfoNV
mutably borrows a slice ofLatencyTimingsFrameReportNV
, which itself contains pointers and a lifetime. Rust seems to assumeResults in:
(EDIT: Instead of
drop(info);
, we could also wraplet info
in a new lifetime scope{}
)More context: #815 (comment)
Originally posted by @MarijnS95 in #816 (comment)
The text was updated successfully, but these errors were encountered: