File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -339,12 +339,30 @@ fn generate_idl(
339339) -> Result < Idl > {
340340 check_idl_build_feature ( ) ?;
341341
342- anchor_lang_idl:: build:: IdlBuilder :: new ( )
342+ // smoelius: If `RUSTUP_TOOLCHAIN` is not cleared, `Span::unwrap` might not be found in
343+ // `proc-macro2`. The affected code is in `anchor-syn`:
344+ // https://github.com/solana-foundation/anchor/blob/38f2b554b2dc6632376241f94048639eaf33d7bd/lang/syn/src/idl/defined.rs#L498-L502
345+ let rustup_toolchain = std:: env:: var_os ( "RUSTUP_TOOLCHAIN" ) ;
346+ if rustup_toolchain. is_some ( ) {
347+ unsafe {
348+ std:: env:: remove_var ( "RUSTUP_TOOLCHAIN" ) ;
349+ }
350+ }
351+
352+ let result = anchor_lang_idl:: build:: IdlBuilder :: new ( )
343353 . resolution ( cfg. features . resolution )
344354 . skip_lint ( cfg. features . skip_lint || skip_lint)
345355 . no_docs ( no_docs)
346356 . cargo_args ( cargo_args. into ( ) )
347- . build ( )
357+ . build ( ) ;
358+
359+ if let Some ( rustup_toolchain) = rustup_toolchain {
360+ unsafe {
361+ std:: env:: set_var ( "RUSTUP_TOOLCHAIN" , rustup_toolchain) ;
362+ }
363+ }
364+
365+ result
348366}
349367
350368fn idl_ts ( idl : & Idl ) -> Result < String > {
You can’t perform that action at this time.
0 commit comments