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
@@ -511,6 +511,18 @@ impl ScopeId {
.flatten()
}
/// Check if the current scope is a descendant of the given scope
pub fn is_descendant_of(self, other: ScopeId) -> bool {
let mut current = self;
while let Some(parent) = current.parent_scope() {
if parent == other {
return true;
}
current = parent;
}
false
}
/// Mark the current scope as dirty, causing it to re-render
pub fn needs_update(self) {
Runtime::with_scope(self, |cx| cx.needs_update()).unwrap();