Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case of Rust 1.79 behavior of stringify! on crate path #1821

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fix "chain configuration not found" error - [#1786](https://github.com/paritytech/cargo-contract/pull/1786)
- Fix "chain configuration not found" error (Rust 1.79) - [#1821](https://github.com/paritytech/cargo-contract/pull/1821)

## [5.0.0-alpha]

Expand Down
30 changes: 8 additions & 22 deletions crates/cargo-contract/src/cmd/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,14 @@ where

#[macro_export]
macro_rules! call_with_config_internal {
($obj:tt ,$function:tt, $config_name:expr, $($config:ty),*) => {
($obj:tt ,$function:tt, $config_name:expr, $( ($config_str:literal, $config_obj:ty) ),*) => {
match $config_name {
$(
stringify!($config) => $obj.$function::<$config>().await,
$config_str => $obj.$function::<$config_obj>().await,
)*
_ => {
let configs = vec![$(stringify!($config)),*].iter()
.map(|s| s.replace(" ", ""))
.map(|s| s.trim_start_matches("$crate::cmd::config::").to_string())
let configs = vec![$($config_str),*].iter()
.map(|s| s.to_string())
.collect::<Vec<_>>()
.join(", ");
Err(ErrorVariant::Generic(
Expand Down Expand Up @@ -254,27 +253,14 @@ macro_rules! call_with_config {
$config_name
);

let res_nonspaced = $crate::call_with_config_internal!(
$obj,
$function,
format!("$crate::cmd::config::{}", $config_name).as_str(),
// All available chain configs need to be specified here
$crate::cmd::config::Polkadot,
$crate::cmd::config::Substrate,
$crate::cmd::config::Ecdsachain
);
if !res_nonspaced.is_err() {
return res_nonspaced
}

$crate::call_with_config_internal!(
$obj,
$function,
format!("$crate :: cmd :: config :: {}", $config_name).as_str(),
$config_name,
// All available chain configs need to be specified here
$crate::cmd::config::Polkadot,
$crate::cmd::config::Substrate,
$crate::cmd::config::Ecdsachain
("Polkadot", $crate::cmd::config::Polkadot),
("Substrate", $crate::cmd::config::Substrate),
("Ecdssachain", $crate::cmd::config::Ecdsachain)
cmichi marked this conversation as resolved.
Show resolved Hide resolved
)
}};
}
Loading