Add a warning when a copy value is used in a higher scope than it was created in (#2771)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-08-02 10:48:13 -07:00
1 parent 0acfe37398
commit 14081e7e45
9 files changed
+289 -115

No files matched your search

+12
View File
@@ -115,6 +115,18 @@ impl<T, S: Storage<T>> GenerationalBox<T, S> {
{
self.raw.take()
}
/// Try to get the location the generational box was created at. In release mode this will always return None.
pub fn created_at(&self) -> Option<&'static std::panic::Location<'static>> {
#[cfg(debug_assertions)]
{
Some(self.raw.location.created_at)
}
#[cfg(not(debug_assertions))]
{
None
}
}
}
impl<T, S> Copy for GenerationalBox<T, S> {}