Skip to content

Commit 7156eaa

Browse files
committed
fix(isolated_declarations): fix memory leak
1 parent f81aa7f commit 7156eaa

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

crates/oxc_isolated_declarations/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a> IsolatedDeclarations<'a> {
7171
ast: AstBuilder::new(allocator),
7272
strip_internal,
7373
internal_annotations: FxHashSet::default(),
74-
scope: ScopeTree::new(allocator),
74+
scope: ScopeTree::new(),
7575
errors: RefCell::new(vec![]),
7676
}
7777
}

crates/oxc_isolated_declarations/src/scope.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
use std::cell::Cell;
22

33
use bitflags::bitflags;
4-
use oxc_allocator::{Allocator, Vec};
4+
use rustc_hash::FxHashMap;
5+
56
#[allow(clippy::wildcard_imports)]
67
use oxc_ast::ast::*;
7-
use oxc_ast::AstBuilder;
88
#[allow(clippy::wildcard_imports)]
99
use oxc_ast::{visit::walk::*, Visit};
1010
use oxc_span::Atom;
1111
use oxc_syntax::scope::{ScopeFlags, ScopeId};
12-
use rustc_hash::FxHashMap;
1312

1413
bitflags! {
1514
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -37,13 +36,12 @@ impl<'a> Scope<'a> {
3736
/// Linear tree of declaration scopes.
3837
#[derive(Debug)]
3938
pub struct ScopeTree<'a> {
40-
levels: Vec<'a, Scope<'a>>,
39+
levels: Vec<Scope<'a>>,
4140
}
4241

4342
impl<'a> ScopeTree<'a> {
44-
pub fn new(allocator: &'a Allocator) -> Self {
45-
let ast = AstBuilder::new(allocator);
46-
let levels = ast.vec1(Scope::new(ScopeFlags::Top));
43+
pub fn new() -> Self {
44+
let levels = vec![Scope::new(ScopeFlags::Top)];
4745
Self { levels }
4846
}
4947

0 commit comments

Comments
 (0)