File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -256,11 +256,19 @@ impl NodeData {
256256 green : Green ,
257257 mutable : bool ,
258258 ) -> ptr:: NonNull < NodeData > {
259+ // Extract parent's self_alloc before wrapping in ManuallyDrop.
260+ // We read it while we still OWN the SyntaxNode (before any shared refs).
261+ let parent_alloc = parent. as_ref ( ) . map ( |p| {
262+ // p is &SyntaxNode from owned Option — safe to read here.
263+ // UnsafeCell::get gives *mut without freezing.
264+ let node_data = unsafe { * p. ptr . get ( ) } ;
265+ unsafe { ptr:: NonNull :: new_unchecked ( ( * node_data. as_ptr ( ) ) . self_alloc ) }
266+ } ) ;
259267 let parent = ManuallyDrop :: new ( parent) ;
260268 let res = NodeData {
261269 _c : Count :: new ( ) ,
262270 rc : Cell :: new ( 1 ) ,
263- parent : Cell :: new ( parent . as_ref ( ) . map ( |it| it . ptr ( ) ) ) ,
271+ parent : Cell :: new ( parent_alloc ) ,
264272 index : Cell :: new ( index) ,
265273 green,
266274
You can’t perform that action at this time.
0 commit comments