From 689607caa67f960d0e28eff491762f02d1867359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wo=C5=BAniak?= Date: Tue, 15 Oct 2024 16:14:26 +0200 Subject: [PATCH] feat: Add support for `sv::features` attribute. (#446) Remove `sv_replies` feature as it does not make the change non breaking. --- examples/Cargo.toml | 2 +- .../generic_contract/src/contract.rs | 1 + .../generics_forwarded/src/contract.rs | 1 + sylvia-derive/Cargo.toml | 2 - sylvia-derive/src/contract.rs | 6 ++- sylvia-derive/src/contract/mt.rs | 15 +++--- sylvia-derive/src/entry_points.rs | 9 +++- sylvia-derive/src/lib.rs | 9 ++++ .../src/parser/attributes/features.rs | 46 +++++++++++++++++++ sylvia-derive/src/parser/attributes/mod.rs | 10 ++++ sylvia/Cargo.toml | 2 - sylvia/src/types.rs | 28 ++++------- sylvia/tests/legacy_replies.rs | 4 +- sylvia/tests/messages_generation.rs | 2 - sylvia/tests/reply.rs | 3 +- sylvia/tests/reply_generation.rs | 3 +- .../ui/attributes/features/invalid_params.rs | 21 +++++++++ .../attributes/features/invalid_params.stderr | 6 +++ .../msg/overlapping_reply_handlers.rs | 2 +- sylvia/tests/ui/method_signature/reply.rs | 2 + sylvia/tests/ui/method_signature/reply.stderr | 8 ++-- 21 files changed, 135 insertions(+), 47 deletions(-) create mode 100644 sylvia-derive/src/parser/attributes/features.rs create mode 100644 sylvia/tests/ui/attributes/features/invalid_params.rs create mode 100644 sylvia/tests/ui/attributes/features/invalid_params.stderr diff --git a/examples/Cargo.toml b/examples/Cargo.toml index b156b4a8..cd94bc3c 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -27,7 +27,7 @@ version = "0.5.0" edition = "2021" [workspace.dependencies] -sylvia = { path = "../sylvia", features = ["sv_replies"] } +sylvia = { path = "../sylvia" } cw-storage-plus = "2.0.0" cw-utils = "2.0.0" cw2 = "2.0.0" diff --git a/examples/contracts/generic_contract/src/contract.rs b/examples/contracts/generic_contract/src/contract.rs index 663042f9..24ca171e 100644 --- a/examples/contracts/generic_contract/src/contract.rs +++ b/examples/contracts/generic_contract/src/contract.rs @@ -53,6 +53,7 @@ pub struct GenericContract< #[sv::messages(generic as Generic: custom(msg, query))] #[sv::messages(custom_and_generic as CustomAndGeneric)] #[sv::custom(msg=SvCustomMsg, query=SvCustomQuery)] +#[sv::features(replies)] impl< InstantiateT, Exec1T, diff --git a/examples/contracts/generics_forwarded/src/contract.rs b/examples/contracts/generics_forwarded/src/contract.rs index 1ba936bf..9eb72c32 100644 --- a/examples/contracts/generics_forwarded/src/contract.rs +++ b/examples/contracts/generics_forwarded/src/contract.rs @@ -58,6 +58,7 @@ pub struct GenericsForwardedContract< #[sv::messages(cw1 as Cw1: custom(msg, query))] #[sv::messages(custom_and_generic as CustomAndGeneric)] #[sv::custom(msg=CustomMsgT, query=CustomQueryT)] +#[sv::features(replies)] impl< InstantiateT, Exec1T, diff --git a/sylvia-derive/Cargo.toml b/sylvia-derive/Cargo.toml index 57ee7c7e..4918d60c 100644 --- a/sylvia-derive/Cargo.toml +++ b/sylvia-derive/Cargo.toml @@ -14,7 +14,6 @@ readme = "../README.md" [features] mt = [] cosmwasm_1_2 = [] -sv_replies = [] [lib] proc-macro = true @@ -43,7 +42,6 @@ sylvia = { path = "../sylvia", features = [ "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", - "sv_replies", ] } serde = { workspace = true } cosmwasm-schema = { workspace = true } diff --git a/sylvia-derive/src/contract.rs b/sylvia-derive/src/contract.rs index b52c980c..f2571c76 100644 --- a/sylvia-derive/src/contract.rs +++ b/sylvia-derive/src/contract.rs @@ -11,6 +11,7 @@ use proc_macro2::TokenStream; use quote::quote; use syn::{GenericParam, ItemImpl}; +use crate::parser::attributes::features::SylviaFeatures; use crate::parser::attributes::msg::MsgType; use crate::parser::variant_descs::AsVariantDescs; use crate::parser::{ @@ -46,6 +47,7 @@ pub struct ContractInput<'a> { custom: Custom, override_entry_points: Vec, interfaces: Interfaces, + sv_features: SylviaFeatures, } impl<'a> ContractInput<'a> { @@ -56,6 +58,7 @@ impl<'a> ContractInput<'a> { let parsed_attrs = ParsedSylviaAttributes::new(item.attrs.iter()); let error = parsed_attrs.error_attrs.unwrap_or_default(); let custom = parsed_attrs.custom_attr.unwrap_or_default(); + let sv_features = parsed_attrs.sv_features; let override_entry_points = parsed_attrs.override_entry_point_attrs; let interfaces = Interfaces::new(item); @@ -66,6 +69,7 @@ impl<'a> ContractInput<'a> { custom, override_entry_points, interfaces, + sv_features, } } @@ -186,7 +190,7 @@ impl<'a> ContractInput<'a> { } fn emit_reply(&self) -> TokenStream { - if cfg!(feature = "sv_replies") { + if self.sv_features.replies { let variants = MsgVariants::new(self.item.as_variants(), MsgType::Reply, &[], &None); Reply::new(self.item, &self.generics, &variants).emit() diff --git a/sylvia-derive/src/contract/mt.rs b/sylvia-derive/src/contract/mt.rs index 45934199..eb5cb0fe 100644 --- a/sylvia-derive/src/contract/mt.rs +++ b/sylvia-derive/src/contract/mt.rs @@ -4,6 +4,7 @@ use quote::quote; use syn::{parse_quote, GenericParam, ItemImpl, Type}; use crate::crate_module; +use crate::parser::attributes::features::SylviaFeatures; use crate::parser::attributes::msg::MsgType; use crate::parser::variant_descs::AsVariantDescs; use crate::parser::{ @@ -23,6 +24,7 @@ pub struct MtHelpers<'a> { where_clause: &'a Option, custom: &'a Custom, override_entry_points: Vec, + sv_features: SylviaFeatures, instantiate_variant: MsgVariants<'a, GenericParam>, exec_variants: MsgVariants<'a, GenericParam>, query_variants: MsgVariants<'a, GenericParam>, @@ -76,11 +78,10 @@ impl<'a> MtHelpers<'a> { where_clause, ); - let error_type = ParsedSylviaAttributes::new(source.attrs.iter()) - .error_attrs - .unwrap_or_default() - .error; + let parsed_attrs = ParsedSylviaAttributes::new(source.attrs.iter()); + let error_type = parsed_attrs.error_attrs.unwrap_or_default().error; let error_type = parse_quote! { #error_type }; + let sv_features = parsed_attrs.sv_features; let contract_name = &source.self_ty; @@ -92,6 +93,7 @@ impl<'a> MtHelpers<'a> { contract_name, custom, override_entry_points, + sv_features, instantiate_variant, exec_variants, query_variants, @@ -478,6 +480,7 @@ impl<'a> MtHelpers<'a> { contract_name, custom, override_entry_points, + sv_features, generic_params, migrate_variants, reply_variants, @@ -529,7 +532,7 @@ impl<'a> MtHelpers<'a> { quote! { #contract_ident } }; - if cfg!(feature = "sv_replies") { + if sv_features.replies { quote! { let contract = #contract_turbofish ::new(); dispatch_reply(deps, env, msg, contract).map_err(Into::into) @@ -537,7 +540,7 @@ impl<'a> MtHelpers<'a> { } else { let reply_name = _reply.name().to_case(Case::Snake); quote! { - self. #reply_name ((deps, env).into(), msg).map_err(Into::into) + self. #reply_name ((deps, env, 0, vec![], vec![]).into(), msg).map_err(Into::into) } } }) diff --git a/sylvia-derive/src/entry_points.rs b/sylvia-derive/src/entry_points.rs index 611c4aff..8fcaaf21 100644 --- a/sylvia-derive/src/entry_points.rs +++ b/sylvia-derive/src/entry_points.rs @@ -6,6 +6,7 @@ use syn::{parse_quote, GenericParam, Ident, ItemImpl, Type, WhereClause}; use crate::crate_module; use crate::fold::StripGenerics; +use crate::parser::attributes::features::SylviaFeatures; use crate::parser::attributes::msg::MsgType; use crate::parser::variant_descs::AsVariantDescs; use crate::parser::{ @@ -68,6 +69,7 @@ pub struct EntryPoints<'a> { generics: Vec<&'a GenericParam>, where_clause: &'a Option, attrs: &'a EntryPointArgs, + sv_features: SylviaFeatures, } impl<'a> EntryPoints<'a> { @@ -75,6 +77,7 @@ impl<'a> EntryPoints<'a> { let name = StripGenerics.fold_type(*source.self_ty.clone()); let parsed_attrs = ParsedSylviaAttributes::new(source.attrs.iter()); let override_entry_points = parsed_attrs.override_entry_point_attrs; + let sv_features = parsed_attrs.sv_features; let error = parsed_attrs.error_attrs.unwrap_or_default().error; @@ -96,6 +99,7 @@ impl<'a> EntryPoints<'a> { generics, where_clause, attrs, + sv_features, } } @@ -172,6 +176,7 @@ impl<'a> EntryPoints<'a> { error, attrs, reply, + sv_features, .. } = self; let sylvia = crate_module(); @@ -201,12 +206,12 @@ impl<'a> EntryPoints<'a> { _ => quote! { msg: < #contract as #sylvia ::types::ContractApi> :: #associated_name }, }; let dispatch = match msg_ty { - MsgType::Reply if cfg!(feature = "sv_replies") => quote! { + MsgType::Reply if sv_features.replies => quote! { let contract = #contract_turbofish ::new(); sv::dispatch_reply(deps, env, msg, contract).map_err(Into::into) }, MsgType::Reply => quote! { - #contract_turbofish ::new(). #reply((deps, env).into(), msg).map_err(Into::into) + #contract_turbofish ::new(). #reply((deps, env, 0, vec![], vec![]).into(), msg).map_err(Into::into) }, _ => quote! { msg.dispatch(& #contract_turbofish ::new() , ( #values )).map_err(Into::into) diff --git a/sylvia-derive/src/lib.rs b/sylvia-derive/src/lib.rs index 3403daf9..d7ccf583 100644 --- a/sylvia-derive/src/lib.rs +++ b/sylvia-derive/src/lib.rs @@ -282,6 +282,7 @@ fn interface_impl(_attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// /// ##[sylvia::contract] /// ##[sv::error(ContractError)] +/// ##[sv::features(replies)] /// impl SvContract { /// pub const fn new() -> Self { /// Self { @@ -621,6 +622,13 @@ fn interface_impl(_attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// and only for message types variants that resolves in an enum field, /// i.e. `exec`, `query` and `sudo`. /// +/// ### `sv::features(...)` +/// +/// Enables additional features for the contract. Allows user to use features that +/// are considered breaking before the major release. +/// +/// Currently supported features are: +/// * `replies` - enables better dispatching of `reply` as well as its auto deserialization. /// #[proc_macro_error] #[proc_macro_attribute] @@ -661,6 +669,7 @@ fn contract_impl(attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// /// ##[sylvia::entry_points] /// ##[sylvia::contract] +/// ##[sv::features(replies)] /// impl SvContract { /// pub const fn new() -> Self { /// Self diff --git a/sylvia-derive/src/parser/attributes/features.rs b/sylvia-derive/src/parser/attributes/features.rs new file mode 100644 index 00000000..00eed7dc --- /dev/null +++ b/sylvia-derive/src/parser/attributes/features.rs @@ -0,0 +1,46 @@ +use proc_macro_error::emit_error; +use syn::parse::{Parse, ParseStream, Parser}; +use syn::{Error, Ident, MetaList, Result, Token}; + +/// Type wrapping data parsed from `sv::features` attribute. +#[derive(Debug, Default)] +pub struct SylviaFeatures { + /// Enables better dispatching and deserialization for replies. + pub replies: bool, +} + +impl SylviaFeatures { + pub fn new(attr: &MetaList) -> Result { + SylviaFeatures::parse + .parse2(attr.tokens.clone()) + .map_err(|err| { + emit_error!(err.span(), err); + err + }) + } +} + +impl Parse for SylviaFeatures { + fn parse(input: ParseStream) -> Result { + let mut features = Self::default(); + + while !input.is_empty() { + let feature: Ident = input.parse()?; + match feature.to_string().as_str() { + "replies" => features.replies = true, + _ => { + return Err(Error::new( + feature.span(), + "Invalid feature.\n= note: Expected `#[sv::features(replies)];`.\n", + )) + } + } + if !input.peek(Token![,]) { + break; + } + let _: Token![,] = input.parse()?; + } + + Ok(features) + } +} diff --git a/sylvia-derive/src/parser/attributes/mod.rs b/sylvia-derive/src/parser/attributes/mod.rs index 9390dac6..2134e818 100644 --- a/sylvia-derive/src/parser/attributes/mod.rs +++ b/sylvia-derive/src/parser/attributes/mod.rs @@ -1,6 +1,7 @@ //! Module defining parsing of Sylvia attributes. //! Every Sylvia attribute should be prefixed with `sv::` +use features::SylviaFeatures; use proc_macro_error::emit_error; use syn::spanned::Spanned; use syn::{Attribute, MetaList, PathSegment}; @@ -8,6 +9,7 @@ use syn::{Attribute, MetaList, PathSegment}; pub mod attr; pub mod custom; pub mod error; +pub mod features; pub mod messages; pub mod msg; pub mod override_entry_point; @@ -31,6 +33,7 @@ pub enum SylviaAttribute { VariantAttrs, MsgAttrs, Payload, + Features, } impl SylviaAttribute { @@ -53,6 +56,7 @@ impl SylviaAttribute { "attr" => Some(Self::VariantAttrs), "msg_attr" => Some(Self::MsgAttrs), "payload" => Some(Self::Payload), + "features" => Some(Self::Features), _ => None, } } @@ -69,6 +73,7 @@ pub struct ParsedSylviaAttributes { pub override_entry_point_attrs: Vec, pub variant_attrs_forward: Vec, pub msg_attrs_forward: Vec, + pub sv_features: SylviaFeatures, } impl ParsedSylviaAttributes { @@ -167,6 +172,11 @@ impl ParsedSylviaAttributes { note = attr.span() => "The `sv::payload` should be used as a prefix for `Binary` payload."; ); } + SylviaAttribute::Features => { + if let Ok(features) = SylviaFeatures::new(attr) { + self.sv_features = features; + } + } } } } diff --git a/sylvia/Cargo.toml b/sylvia/Cargo.toml index 32bad4db..92df9d7a 100644 --- a/sylvia/Cargo.toml +++ b/sylvia/Cargo.toml @@ -38,8 +38,6 @@ cosmwasm_2_0 = [ "cw-multi-test/cosmwasm_2_0", "cosmwasm_1_4", ] -# Enables better replies -sv_replies = ["sylvia-derive/sv_replies"] [dependencies] sylvia-derive = { workspace = true } diff --git a/sylvia/src/types.rs b/sylvia/src/types.rs index b3999c6e..7eec2af9 100644 --- a/sylvia/src/types.rs +++ b/sylvia/src/types.rs @@ -1,8 +1,8 @@ //! Module providing utilities to build and use sylvia contracts. -use cosmwasm_std::{Binary, Coin, Deps, DepsMut, Empty, Env, MessageInfo, WasmMsg}; -#[cfg(feature = "sv_replies")] -use cosmwasm_std::{Event, MsgResponse}; +use cosmwasm_std::{ + Binary, Coin, Deps, DepsMut, Empty, Env, Event, MessageInfo, MsgResponse, WasmMsg, +}; use derivative::Derivative; use schemars::JsonSchema; use serde::de::DeserializeOwned; @@ -461,7 +461,7 @@ impl<'a, Contract: ?Sized> AsRef for Remote<'a, Contract> { } /// Represantation of `reply` context received in entry point. -#[cfg(feature = "sv_replies")] +#[non_exhaustive] pub struct ReplyCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, pub env: Env, @@ -470,20 +470,15 @@ pub struct ReplyCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub msg_responses: Vec, } -/// Represantation of `reply` context received in entry point. -#[cfg(not(feature = "sv_replies"))] -pub struct ReplyCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { - pub deps: DepsMut<'a, C>, - pub env: Env, -} - /// Represantation of `migrate` context received in entry point. +#[non_exhaustive] pub struct MigrateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, pub env: Env, } /// Represantation of `execute` context received in entry point. +#[non_exhaustive] pub struct ExecCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, pub env: Env, @@ -491,6 +486,7 @@ pub struct ExecCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { } /// Represantation of `instantiate` context received in entry point. +#[non_exhaustive] pub struct InstantiateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, pub env: Env, @@ -498,12 +494,14 @@ pub struct InstantiateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { } /// Represantation of `query` context received in entry point. +#[non_exhaustive] pub struct QueryCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: Deps<'a, C>, pub env: Env, } /// Represantation of `sudo` context received in entry point. +#[non_exhaustive] pub struct SudoCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, pub env: Env, @@ -544,7 +542,6 @@ impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env)> for MigrateCt } } -#[cfg(feature = "sv_replies")] impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env, u64, Vec, Vec)> for ReplyCtx<'a, C> { @@ -567,13 +564,6 @@ impl<'a, C: cosmwasm_std::CustomQuery> } } -#[cfg(not(feature = "sv_replies"))] -impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env)> for ReplyCtx<'a, C> { - fn from((deps, env): (DepsMut<'a, C>, Env)) -> Self { - Self { deps, env } - } -} - impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env, MessageInfo)> for ExecCtx<'a, C> { fn from((deps, env, info): (DepsMut<'a, C>, Env, MessageInfo)) -> Self { Self { deps, env, info } diff --git a/sylvia/tests/legacy_replies.rs b/sylvia/tests/legacy_replies.rs index 16c05b39..bb5a513f 100644 --- a/sylvia/tests/legacy_replies.rs +++ b/sylvia/tests/legacy_replies.rs @@ -1,5 +1,3 @@ -#![cfg(not(feature = "sv_replies"))] - #[cfg(all(test, feature = "mt"))] use cw_multi_test::IntoBech32; use sylvia::cw_std::testing::{mock_dependencies, mock_env}; @@ -34,7 +32,7 @@ mod noop_contract { } mod reply_contract { - use cosmwasm_std::{Binary, Reply, SubMsgResult}; + use cosmwasm_std::Reply; use sylvia::types::{ExecCtx, InstantiateCtx, ReplyCtx}; use sylvia::{contract, entry_points}; diff --git a/sylvia/tests/messages_generation.rs b/sylvia/tests/messages_generation.rs index 439febaa..a752ee6a 100644 --- a/sylvia/tests/messages_generation.rs +++ b/sylvia/tests/messages_generation.rs @@ -1,4 +1,3 @@ -#![cfg(not(feature = "sv_replies"))] use std::fmt::Debug; use std::str::FromStr; @@ -66,7 +65,6 @@ pub mod interface { } mod contract { - use cosmwasm_std::{Binary, SubMsgResult}; use sylvia::contract; use sylvia::cw_std::{Addr, Reply, Response, StdResult}; use sylvia::types::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, ReplyCtx, SudoCtx}; diff --git a/sylvia/tests/reply.rs b/sylvia/tests/reply.rs index 4c50daaf..ed478151 100644 --- a/sylvia/tests/reply.rs +++ b/sylvia/tests/reply.rs @@ -1,5 +1,3 @@ -#![cfg(feature = "sv_replies")] - use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_json_binary, BankMsg, CosmosMsg, Empty, SubMsgResult}; use cw_storage_plus::Item; @@ -81,6 +79,7 @@ pub struct Contract { #[contract] #[sv::error(ContractError)] #[sv::custom(msg=M, query=Q)] +#[sv::features(replies)] impl Contract where M: CustomMsg + 'static, diff --git a/sylvia/tests/reply_generation.rs b/sylvia/tests/reply_generation.rs index bf320208..a4f471ca 100644 --- a/sylvia/tests/reply_generation.rs +++ b/sylvia/tests/reply_generation.rs @@ -1,5 +1,3 @@ -#![cfg(feature = "sv_replies")] - use cosmwasm_std::{Binary, SubMsgResult}; use itertools::Itertools; use sylvia::cw_std::{Response, StdResult}; @@ -10,6 +8,7 @@ pub struct Contract; #[entry_points] #[contract] +#[sv::features(replies)] impl Contract { pub fn new() -> Self { Self diff --git a/sylvia/tests/ui/attributes/features/invalid_params.rs b/sylvia/tests/ui/attributes/features/invalid_params.rs new file mode 100644 index 00000000..a2c08e2f --- /dev/null +++ b/sylvia/tests/ui/attributes/features/invalid_params.rs @@ -0,0 +1,21 @@ +#![allow(unused_imports)] +use sylvia::contract; +use sylvia::cw_std::{Response, StdResult}; +use sylvia::types::InstantiateCtx; + +pub struct Contract; + +#[contract] +#[sv::features(unknown_parameter)] +impl Contract { + pub fn new() -> Self { + Self + } + + #[sv::msg(instantiate)] + pub fn instantiate(&self, _ctx: InstantiateCtx) -> StdResult { + Ok(Response::new()) + } +} + +fn main() {} diff --git a/sylvia/tests/ui/attributes/features/invalid_params.stderr b/sylvia/tests/ui/attributes/features/invalid_params.stderr new file mode 100644 index 00000000..bff21570 --- /dev/null +++ b/sylvia/tests/ui/attributes/features/invalid_params.stderr @@ -0,0 +1,6 @@ +error: Invalid feature. + = note: Expected `#[sv::features(replies)];`. + --> tests/ui/attributes/features/invalid_params.rs:9:16 + | +9 | #[sv::features(unknown_parameter)] + | ^^^^^^^^^^^^^^^^^ diff --git a/sylvia/tests/ui/attributes/msg/overlapping_reply_handlers.rs b/sylvia/tests/ui/attributes/msg/overlapping_reply_handlers.rs index 0a18cd84..baa3fcc0 100644 --- a/sylvia/tests/ui/attributes/msg/overlapping_reply_handlers.rs +++ b/sylvia/tests/ui/attributes/msg/overlapping_reply_handlers.rs @@ -1,5 +1,4 @@ #![allow(unused_imports)] -#![cfg(feature = "sv_replies")] use sylvia::contract; use sylvia::cw_std::{Reply, Response, StdResult}; @@ -8,6 +7,7 @@ use sylvia::types::{InstantiateCtx, ReplyCtx}; pub struct Contract; #[contract] +#[sv::features(replies)] impl Contract { pub fn new() -> Self { Self diff --git a/sylvia/tests/ui/method_signature/reply.rs b/sylvia/tests/ui/method_signature/reply.rs index 3ab7925f..b6775cea 100644 --- a/sylvia/tests/ui/method_signature/reply.rs +++ b/sylvia/tests/ui/method_signature/reply.rs @@ -8,6 +8,7 @@ pub mod mismatched_params { pub struct Contract {} #[sylvia::contract] + #[sv::features(replies)] impl Contract { pub const fn new() -> Self { Self {} @@ -46,6 +47,7 @@ pub mod mismatched_param_arity { pub struct Contract {} #[sylvia::contract] + #[sv::features(replies)] impl Contract { pub const fn new() -> Self { Self {} diff --git a/sylvia/tests/ui/method_signature/reply.stderr b/sylvia/tests/ui/method_signature/reply.stderr index b908c1f5..d75a4008 100644 --- a/sylvia/tests/ui/method_signature/reply.stderr +++ b/sylvia/tests/ui/method_signature/reply.stderr @@ -3,9 +3,9 @@ error: Mismatched parameter in reply handlers. = note: Parameters for the `on_instantiated` handler have to be the same. = note: Previous parameter defined for the `on_instantiated` handler. - --> tests/ui/method_signature/reply.rs:26:13 + --> tests/ui/method_signature/reply.rs:27:13 | -26 | param: String, +27 | param: String, | ^^^^^ error: Mismatched quantity of method parameters. @@ -13,7 +13,7 @@ error: Mismatched quantity of method parameters. = note: Both `on_instantiated` handlers should have the same number of parameters. = note: Previous definition of on_instantiated handler. - --> tests/ui/method_signature/reply.rs:60:12 + --> tests/ui/method_signature/reply.rs:62:12 | -60 | fn first_reply( +62 | fn first_reply( | ^^^^^^^^^^^