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

explicit prelude + fixing test error messages #1503

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions crates/ink/codegen/src/generator/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>()?;
Expand Down
4 changes: 2 additions & 2 deletions crates/ink/codegen/src/generator/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -348,7 +348,7 @@ impl Metadata<'_> {
)
)
} else {
None
::core::option::Option::None
}
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
error[E0277]: the trait bound `codegen::dispatch::execution::private::Seal<Result<u8, contract::Error>>: codegen::dispatch::execution::ConstructorReturnType<Contract>` is not satisfied
error[E0277]: the trait bound `ConstructorOutputValue<Result<u8, contract::Error>>: ConstructorOutput<Contract>` is not satisfied
--> tests/ui/contract/fail/constructor-return-result-invalid.rs:14:9
|
14 | pub fn constructor() -> Result<u8, Error> {
| ^^^ the trait `codegen::dispatch::execution::ConstructorReturnType<Contract>` is not implemented for `codegen::dispatch::execution::private::Seal<Result<u8, contract::Error>>`
| ^^^ the trait `ConstructorOutput<Contract>` is not implemented for `ConstructorOutputValue<Result<u8, contract::Error>>`
|
= help: the following other types implement trait `codegen::dispatch::execution::ConstructorReturnType<C>`:
codegen::dispatch::execution::private::Seal<C>
codegen::dispatch::execution::private::Seal<Result<C, E>>
note: required by a bound in `execute_constructor`
--> src/codegen/dispatch/execution.rs
|
| private::Seal<R>: ConstructorReturnType<Contract>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `execute_constructor`
= help: the following other types implement trait `ConstructorOutput<C>`:
ConstructorOutputValue<C>
ConstructorOutputValue<Result<C, E>>
Original file line number Diff line number Diff line change
@@ -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<Self, Error> {
| ^^^ 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<T>
Box<T>
Cow<'a, T>
Rc<T>
String
Vec<T>
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<T, E>`
note: required by a bound in `return_value`
--> $WORKSPACE/crates/env/src/api.rs
|
| <private::Seal<R> as ConstructorReturnType<Contract>>::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
Expand All @@ -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`