浏览代码

feat: Allow building the IDL on stable (#3842)

Jamie Hill-Daniel 1 月之前
父节点
当前提交
38f2b554b2
共有 3 个文件被更改,包括 3 次插入8 次删除
  1. 2 3
      idl/src/build.rs
  2. 0 4
      lang/syn/Cargo.toml
  3. 1 1
      lang/syn/src/idl/defined.rs

+ 2 - 3
idl/src/build.rs

@@ -138,10 +138,9 @@ fn build(
     no_docs: bool,
     cargo_args: &[String],
 ) -> Result<Idl> {
-    // `nightly` toolchain is currently required for building the IDL.
     let toolchain = std::env::var("RUSTUP_TOOLCHAIN")
         .map(|toolchain| format!("+{toolchain}"))
-        .unwrap_or_else(|_| "+nightly".to_string());
+        .unwrap_or_else(|_| "+stable".to_string());
 
     install_toolchain_if_needed(&toolchain)?;
     let output = Command::new("cargo")
@@ -167,7 +166,7 @@ fn build(
             if skip_lint { "TRUE" } else { "FALSE" },
         )
         .env("ANCHOR_IDL_BUILD_PROGRAM_PATH", program_path)
-        .env("RUSTFLAGS", "--cfg procmacro2_semver_exempt -A warnings")
+        .env("RUSTFLAGS", "-A warnings")
         .current_dir(program_path)
         .stderr(Stdio::inherit())
         .output()?;

+ 0 - 4
lang/syn/Cargo.toml

@@ -34,7 +34,3 @@ thiserror = "1"
 
 # `idl-build` feature only
 cargo_toml = { version = "0.19", optional = true }
-
-# https://blog.rust-lang.org/2024/05/06/check-cfg.html#expecting-custom-cfgs
-[lints.rust]
-unexpected_cfgs = { level = "allow", check-cfg = ["cfg(procmacro2_semver_exempt)"] }

+ 1 - 1
lang/syn/src/idl/defined.rs

@@ -490,7 +490,6 @@ pub fn gen_idl_type(
             }
 
             // Handle type aliases and external types
-            #[cfg(procmacro2_semver_exempt)]
             {
                 use super::{common::find_path, external::get_external_type};
                 use crate::parser::context::CrateContext;
@@ -498,6 +497,7 @@ pub fn gen_idl_type(
 
                 // If no path was found, just return an empty path and let the find_path function handle it
                 let source_path = proc_macro2::Span::call_site()
+                    .unwrap()
                     .local_file()
                     .unwrap_or_default();