Skip to content

Commit 1c3814f

Browse files
committed
Merge branch 'master' into gn/5.0.0-rc.3
2 parents e6e17ba + 0f2b2c6 commit 1c3814f

26 files changed

+278
-102
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
## Version 5.0.0-rc.3
1010

1111
### Changed
12+
- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/paritytech/ink/pull/2140)
13+
- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/paritytech/ink/pull/2143)
1214
- Bump Substrate crates - [#2141](https://github.com/paritytech/ink/pull/2141)
1315
- Minor fixes - [#2144](https://github.com/paritytech/ink/pull/2144),
1416
[#2137](https://github.com/paritytech/ink/pull/2137), [#2132](https://github.com/paritytech/ink/pull/2132)

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ heck = { version = "0.4.0" }
4747
impl-serde = { version = "0.4.0", default-features = false }
4848
itertools = { version = "0.12", default-features = false }
4949
jsonrpsee = { version = "0.22.2" }
50-
linkme = { version = "0.3.23" }
50+
linkme = { version = "0.3.25" }
5151
num-traits = { version = "0.2", default-features = false }
5252
paste = { version = "1.0" }
5353
pretty_assertions = { version = "1" }

crates/e2e/macro/src/config.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl Node {
6666
#[derive(Clone, Eq, PartialEq, Debug, darling::FromMeta)]
6767
pub enum RuntimeOnly {
6868
#[darling(word)]
69+
#[darling(skip)]
6970
Default,
7071
Runtime(syn::Path),
7172
}
@@ -134,6 +135,18 @@ mod tests {
134135
assert_eq!(config.backend(), Backend::RuntimeOnly(RuntimeOnly::Default));
135136
}
136137

138+
#[test]
139+
#[should_panic(expected = "ErrorUnknownField")]
140+
fn config_works_backend_runtime_only_default_not_allowed() {
141+
let input = quote! {
142+
backend(runtime_only(default)),
143+
};
144+
let config =
145+
E2EConfig::from_list(&NestedMeta::parse_meta_list(input).unwrap()).unwrap();
146+
147+
assert_eq!(config.backend(), Backend::RuntimeOnly(RuntimeOnly::Default));
148+
}
149+
137150
#[test]
138151
fn config_works_runtime_only_with_custom_backend() {
139152
let input = quote! {

crates/ink/ir/src/ast/attr_args.rs

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use super::MetaNameValue;
15+
use super::Meta;
1616
use syn::{
1717
parse::{
1818
Parse,
@@ -28,7 +28,7 @@ use syn::{
2828
/// in `#[ink::contract(env = ::my::env::Environment)]`.
2929
#[derive(Clone, Debug, PartialEq, Eq)]
3030
pub struct AttributeArgs {
31-
args: Punctuated<MetaNameValue, Token![,]>,
31+
args: Punctuated<Meta, Token![,]>,
3232
}
3333

3434
impl quote::ToTokens for AttributeArgs {
@@ -38,8 +38,8 @@ impl quote::ToTokens for AttributeArgs {
3838
}
3939

4040
impl IntoIterator for AttributeArgs {
41-
type Item = MetaNameValue;
42-
type IntoIter = syn::punctuated::IntoIter<MetaNameValue>;
41+
type Item = Meta;
42+
type IntoIter = syn::punctuated::IntoIter<Meta>;
4343

4444
fn into_iter(self) -> Self::IntoIter {
4545
self.args.into_iter()
@@ -57,14 +57,17 @@ impl Parse for AttributeArgs {
5757
#[cfg(test)]
5858
mod tests {
5959
use super::*;
60-
use crate::ast::MetaValue;
60+
use crate::ast::{
61+
MetaNameValue,
62+
MetaValue,
63+
};
6164
use quote::quote;
6265

6366
impl AttributeArgs {
6467
/// Creates a new attribute argument list from the given arguments.
6568
pub fn new<I>(args: I) -> Self
6669
where
67-
I: IntoIterator<Item = MetaNameValue>,
70+
I: IntoIterator<Item = Meta>,
6871
{
6972
Self {
7073
args: args.into_iter().collect(),
@@ -80,51 +83,59 @@ mod tests {
8083
)
8184
}
8285

86+
#[test]
87+
fn flag_works() {
88+
assert_eq!(
89+
syn::parse2::<AttributeArgs>(quote! { flag }).unwrap(),
90+
AttributeArgs::new(vec![Meta::Path(syn::parse_quote! { flag })])
91+
)
92+
}
93+
8394
#[test]
8495
fn literal_bool_value_works() {
8596
assert_eq!(
8697
syn::parse2::<AttributeArgs>(quote! { name = true }).unwrap(),
87-
AttributeArgs::new(vec![MetaNameValue {
98+
AttributeArgs::new(vec![Meta::NameValue(MetaNameValue {
8899
name: syn::parse_quote! { name },
89100
eq_token: syn::parse_quote! { = },
90101
value: MetaValue::Lit(syn::parse_quote! { true }),
91-
}])
102+
})])
92103
)
93104
}
94105

95106
#[test]
96107
fn literal_str_value_works() {
97108
assert_eq!(
98109
syn::parse2::<AttributeArgs>(quote! { name = "string literal" }).unwrap(),
99-
AttributeArgs::new(vec![MetaNameValue {
110+
AttributeArgs::new(vec![Meta::NameValue(MetaNameValue {
100111
name: syn::parse_quote! { name },
101112
eq_token: syn::parse_quote! { = },
102113
value: MetaValue::Lit(syn::parse_quote! { "string literal" }),
103-
}])
114+
})])
104115
)
105116
}
106117

107118
#[test]
108119
fn ident_value_works() {
109120
assert_eq!(
110121
syn::parse2::<AttributeArgs>(quote! { name = MyIdentifier }).unwrap(),
111-
AttributeArgs::new(vec![MetaNameValue {
122+
AttributeArgs::new(vec![Meta::NameValue(MetaNameValue {
112123
name: syn::parse_quote! { name },
113124
eq_token: syn::parse_quote! { = },
114125
value: MetaValue::Path(syn::parse_quote! { MyIdentifier }),
115-
}])
126+
})])
116127
)
117128
}
118129

119130
#[test]
120131
fn root_path_value_works() {
121132
assert_eq!(
122133
syn::parse2::<AttributeArgs>(quote! { name = ::this::is::my::Path }).unwrap(),
123-
AttributeArgs::new(vec![MetaNameValue {
134+
AttributeArgs::new(vec![Meta::NameValue(MetaNameValue {
124135
name: syn::parse_quote! { name },
125136
eq_token: syn::parse_quote! { = },
126137
value: MetaValue::Path(syn::parse_quote! { ::this::is::my::Path }),
127-
}])
138+
})])
128139
)
129140
}
130141

@@ -133,24 +144,24 @@ mod tests {
133144
assert_eq!(
134145
syn::parse2::<AttributeArgs>(quote! { name = this::is::my::relative::Path })
135146
.unwrap(),
136-
AttributeArgs::new(vec![MetaNameValue {
147+
AttributeArgs::new(vec![Meta::NameValue(MetaNameValue {
137148
name: syn::parse_quote! { name },
138149
eq_token: syn::parse_quote! { = },
139150
value: MetaValue::Path(
140151
syn::parse_quote! { this::is::my::relative::Path }
141152
),
142-
}])
153+
})])
143154
)
144155
}
145156

146157
#[test]
147158
fn trailing_comma_works() {
148159
let mut expected_args = Punctuated::new();
149-
expected_args.push_value(MetaNameValue {
160+
expected_args.push_value(Meta::NameValue(MetaNameValue {
150161
name: syn::parse_quote! { name },
151162
eq_token: syn::parse_quote! { = },
152163
value: MetaValue::Path(syn::parse_quote! { value }),
153-
});
164+
}));
154165
expected_args.push_punct(<Token![,]>::default());
155166
assert_eq!(
156167
syn::parse2::<AttributeArgs>(quote! { name = value, }).unwrap(),
@@ -164,6 +175,7 @@ mod tests {
164175
fn many_mixed_works() {
165176
assert_eq!(
166177
syn::parse2::<AttributeArgs>(quote! {
178+
flag,
167179
name1 = ::root::Path,
168180
name2 = false,
169181
name3 = "string literal",
@@ -172,31 +184,32 @@ mod tests {
172184
})
173185
.unwrap(),
174186
AttributeArgs::new(vec![
175-
MetaNameValue {
187+
Meta::Path(syn::parse_quote! { flag }),
188+
Meta::NameValue(MetaNameValue {
176189
name: syn::parse_quote! { name1 },
177190
eq_token: syn::parse_quote! { = },
178191
value: MetaValue::Path(syn::parse_quote! { ::root::Path }),
179-
},
180-
MetaNameValue {
192+
}),
193+
Meta::NameValue(MetaNameValue {
181194
name: syn::parse_quote! { name2 },
182195
eq_token: syn::parse_quote! { = },
183196
value: MetaValue::Lit(syn::parse_quote! { false }),
184-
},
185-
MetaNameValue {
197+
}),
198+
Meta::NameValue(MetaNameValue {
186199
name: syn::parse_quote! { name3 },
187200
eq_token: syn::parse_quote! { = },
188201
value: MetaValue::Lit(syn::parse_quote! { "string literal" }),
189-
},
190-
MetaNameValue {
202+
}),
203+
Meta::NameValue(MetaNameValue {
191204
name: syn::parse_quote! { name4 },
192205
eq_token: syn::parse_quote! { = },
193206
value: MetaValue::Lit(syn::parse_quote! { 42 }),
194-
},
195-
MetaNameValue {
207+
}),
208+
Meta::NameValue(MetaNameValue {
196209
name: syn::parse_quote! { name5 },
197210
eq_token: syn::parse_quote! { = },
198211
value: MetaValue::Lit(syn::parse_quote! { 7.7 }),
199-
},
212+
}),
200213
])
201214
)
202215
}

0 commit comments

Comments
 (0)