From 5913328ecf44d59d1820a3373f0f146142ff7ce7 Mon Sep 17 00:00:00 2001 From: SkymanOne Date: Wed, 16 Nov 2022 20:54:36 +0000 Subject: [PATCH] explicit prelude + fixing test error messages --- crates/ink/codegen/src/generator/dispatch.rs | 2 + crates/ink/codegen/src/generator/metadata.rs | 4 +- .../constructor-return-result-invalid.stderr | 15 +++---- ...uctor-return-result-non-codec-error.stderr | 40 ++++++++----------- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/crates/ink/codegen/src/generator/dispatch.rs b/crates/ink/codegen/src/generator/dispatch.rs index ae0d4774f9f..dbfbdacd36d 100644 --- a/crates/ink/codegen/src/generator/dispatch.rs +++ b/crates/ink/codegen/src/generator/dispatch.rs @@ -582,6 +582,8 @@ impl Dispatch<'_> { quote_spanned!(constructor_span=> Self::#constructor_ident(input) => { + use ::core::default::Default; + if #any_constructor_accept_payment && #deny_payment { ::ink::codegen::deny_payment::< <#storage_ident as ::ink::reflect::ContractEnv>::Env>()?; diff --git a/crates/ink/codegen/src/generator/metadata.rs b/crates/ink/codegen/src/generator/metadata.rs index 90390f713ae..3e9c47367d6 100644 --- a/crates/ink/codegen/src/generator/metadata.rs +++ b/crates/ink/codegen/src/generator/metadata.rs @@ -338,7 +338,7 @@ impl Metadata<'_> { quote_spanned!(span=> ::ink::metadata::ReturnTypeSpec::new( if #constructor_info ::IS_RESULT { - Some(::ink::metadata::TypeSpec::with_name_str::< + ::core::option::Option::Some(::ink::metadata::TypeSpec::with_name_str::< ::core::result::Result< (), #constructor_info ::Error @@ -348,7 +348,7 @@ impl Metadata<'_> { ) ) } else { - None + ::core::option::Option::None } ) ) diff --git a/crates/ink/tests/ui/contract/fail/constructor-return-result-invalid.stderr b/crates/ink/tests/ui/contract/fail/constructor-return-result-invalid.stderr index 7d06785ab53..7101544b93e 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-return-result-invalid.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-return-result-invalid.stderr @@ -1,14 +1,9 @@ -error[E0277]: the trait bound `codegen::dispatch::execution::private::Seal>: codegen::dispatch::execution::ConstructorReturnType` is not satisfied +error[E0277]: the trait bound `ConstructorOutputValue>: ConstructorOutput` is not satisfied --> tests/ui/contract/fail/constructor-return-result-invalid.rs:14:9 | 14 | pub fn constructor() -> Result { - | ^^^ the trait `codegen::dispatch::execution::ConstructorReturnType` is not implemented for `codegen::dispatch::execution::private::Seal>` + | ^^^ the trait `ConstructorOutput` is not implemented for `ConstructorOutputValue>` | - = help: the following other types implement trait `codegen::dispatch::execution::ConstructorReturnType`: - codegen::dispatch::execution::private::Seal - codegen::dispatch::execution::private::Seal> -note: required by a bound in `execute_constructor` - --> src/codegen/dispatch/execution.rs - | - | private::Seal: ConstructorReturnType, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `execute_constructor` + = help: the following other types implement trait `ConstructorOutput`: + ConstructorOutputValue + ConstructorOutputValue> diff --git a/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr b/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr index f26d2e4579f..f6256d78c59 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr @@ -1,31 +1,21 @@ -error[E0277]: the trait bound `contract::Error: WrapperTypeEncode` is not satisfied +error[E0277]: the trait bound `Result<(), &contract::Error>: Encode` is not satisfied --> tests/ui/contract/fail/constructor-return-result-non-codec-error.rs:13:9 | 13 | pub fn constructor() -> Result { - | ^^^ the trait `WrapperTypeEncode` is not implemented for `contract::Error` + | ^^^ the trait `Encode` is not implemented for `Result<(), &contract::Error>` | - = help: the following other types implement trait `WrapperTypeEncode`: - &T - &mut T - Arc - Box - Cow<'a, T> - Rc - String - Vec - parity_scale_codec::Ref<'a, T, U> - = note: required for `contract::Error` to implement `Encode` -note: required by a bound in `execute_constructor` - --> src/codegen/dispatch/execution.rs + = help: the trait `Encode` is implemented for `Result` +note: required by a bound in `return_value` + --> $WORKSPACE/crates/env/src/api.rs | - | as ConstructorReturnType>::Error: Encode, - | ^^^^^^ required by this bound in `execute_constructor` + | R: scale::Encode, + | ^^^^^^^^^^^^^ required by this bound in `return_value` error[E0277]: the trait bound `contract::Error: TypeInfo` is not satisfied - --> tests/ui/contract/fail/constructor-return-result-non-codec-error.rs:1:1 + --> tests/ui/contract/fail/constructor-return-result-non-codec-error.rs:4:16 | -1 | #[ink::contract] - | ^^^^^^^^^^^^^^^^ the trait `TypeInfo` is not implemented for `contract::Error` +4 | pub struct Contract {} + | ^^^^^^^^ the trait `TypeInfo` is not implemented for `contract::Error` | = help: the following other types implement trait `TypeInfo`: &T @@ -36,6 +26,10 @@ error[E0277]: the trait bound `contract::Error: TypeInfo` is not satisfied (A, B, C, D) (A, B, C, D, E) (A, B, C, D, E, F) - and 64 others - = note: required for `Result<(), contract::Error>` to implement `ConstructorReturnSpec` - = note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info) + and $N others + = note: required for `Result<(), contract::Error>` to implement `TypeInfo` +note: required by a bound in `TypeSpec::with_name_str` + --> $WORKSPACE/crates/metadata/src/specs.rs + | + | T: TypeInfo + 'static, + | ^^^^^^^^ required by this bound in `TypeSpec::with_name_str`