@@ -15,7 +15,7 @@ use crate::expand::{
15
15
use crate :: fds:: open_cloexec;
16
16
use crate :: flog:: FLOGF ;
17
17
use crate :: function;
18
- use crate :: global_safety:: { RelaxedAtomicBool , SharedFromThis , SharedFromThisBase } ;
18
+ use crate :: global_safety:: RelaxedAtomicBool ;
19
19
use crate :: io:: IoChain ;
20
20
use crate :: job_group:: MaybeJobId ;
21
21
use crate :: operation_context:: { OperationContext , EXPANSION_LIMIT_DEFAULT } ;
@@ -42,7 +42,7 @@ use std::ffi::{CStr, OsStr};
42
42
use std:: os:: fd:: { AsRawFd , OwnedFd , RawFd } ;
43
43
use std:: os:: unix:: prelude:: OsStrExt ;
44
44
use std:: pin:: Pin ;
45
- use std:: rc:: Rc ;
45
+ use std:: rc:: { Rc , Weak } ;
46
46
use std:: sync:: {
47
47
atomic:: { AtomicIsize , AtomicU64 , Ordering } ,
48
48
Arc ,
@@ -295,7 +295,7 @@ pub type BlockId = usize;
295
295
pub type ParserRef = Rc < Parser > ;
296
296
297
297
pub struct Parser {
298
- base : SharedFromThisBase < Parser > ,
298
+ this : Weak < Self > ,
299
299
300
300
/// The current execution context.
301
301
execution_context : RefCell < Option < ParseExecutionContext > > ,
@@ -335,17 +335,11 @@ pub struct Parser {
335
335
pub global_event_blocks : AtomicU64 ,
336
336
}
337
337
338
- impl SharedFromThis < Parser > for Parser {
339
- fn get_base ( & self ) -> & SharedFromThisBase < Parser > {
340
- & self . base
341
- }
342
- }
343
-
344
338
impl Parser {
345
339
/// Create a parser
346
340
pub fn new ( variables : EnvStackRef , is_principal : bool ) -> ParserRef {
347
- let result = Rc :: new ( Self {
348
- base : SharedFromThisBase :: new ( ) ,
341
+ let result = Rc :: new_cyclic ( | this : & Weak < Self > | Self {
342
+ this : Weak :: clone ( this ) ,
349
343
execution_context : RefCell :: default ( ) ,
350
344
job_list : RefCell :: default ( ) ,
351
345
wait_handles : RefCell :: new ( WaitHandleStore :: new ( ) ) ,
@@ -372,7 +366,6 @@ impl Parser {
372
366
}
373
367
}
374
368
375
- result. base . initialize ( & result) ;
376
369
result
377
370
}
378
371
@@ -1075,7 +1068,7 @@ impl Parser {
1075
1068
1076
1069
/// \return a shared pointer reference to this parser.
1077
1070
pub fn shared ( & self ) -> ParserRef {
1078
- self . shared_from_this ( )
1071
+ self . this . upgrade ( ) . unwrap ( )
1079
1072
}
1080
1073
1081
1074
/// \return the operation context for this parser.
0 commit comments