Emirhan-Cavusoglu-sftw 1532a3b0a4 call first function
2024-10-13 00:06:20 +01:00

4 lines
9.0 KiB
Plaintext

{"$message_type":"diagnostic","message":"the trait bound `soroban_sdk::xdr::ScVal: TryFrom<&core::option::Option<soroban_sdk::String>>` is not satisfied","code":{"code":"E0277","explanation":"You tried to use a type which doesn't implement some trait in a place which\nexpected that trait.\n\nErroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n foo.bar();\n}\n\nfn main() {\n // we now call the method with the i32 type, which doesn't implement\n // the Foo trait\n some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n fn bar(&self);\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n fn bar(&self) {}\n}\n\nfn some_func<T: Foo>(foo: T) {\n foo.bar(); // we can now use this method since i32 implements the\n // Foo trait\n}\n\nfn main() {\n some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n // implemented for the type `T`\n}\n\nfn main() {\n // We now call the method with the i32 type,\n // which *does* implement the Debug trait.\n some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function. Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function. It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n println!(\"{:?}\", foo);\n}\n\nfn main() {\n // Calling the method is still fine, as i32 implements Debug.\n some_func(5i32);\n\n // This would fail to compile now:\n // struct WithoutDebug;\n // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","spans":[{"file_name":"escrow/src/lib.rs","byte_start":301,"byte_end":316,"line_start":21,"line_end":21,"column_start":1,"column_end":16,"is_primary":true,"text":[{"text":"#[contracttype]","highlight_start":1,"highlight_end":16}],"label":"the trait `From<soroban_sdk::String>` is not implemented for `soroban_sdk::xdr::ScVal`, which is required by `&core::option::Option<soroban_sdk::String>: TryInto<_>`","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"escrow/src/lib.rs","byte_start":301,"byte_end":316,"line_start":21,"line_end":21,"column_start":1,"column_end":16,"is_primary":false,"text":[{"text":"#[contracttype]","highlight_start":1,"highlight_end":16}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"#[contracttype]","def_site_span":{"file_name":"/home/arhan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-sdk-macros-20.5.0/src/lib.rs","byte_start":11266,"byte_end":11343,"line_start":377,"line_end":377,"column_start":1,"column_end":78,"is_primary":false,"text":[{"text":"pub fn contracttype(metadata: TokenStream, input: TokenStream) -> TokenStream {","highlight_start":1,"highlight_end":78}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"the following other types implement trait `From<T>`:\n <&'a soroban_sdk::xdr::ScVal as From<soroban_env_common::object::ScValObjRef<'a>>>\n <soroban_sdk::xdr::ScVal as From<&()>>\n <soroban_sdk::xdr::ScVal as From<&bool>>\n <soroban_sdk::xdr::ScVal as From<&core::option::Option<T>>>\n <soroban_sdk::xdr::ScVal as From<&i128>>\n <soroban_sdk::xdr::ScVal as From<&i32>>\n <soroban_sdk::xdr::ScVal as From<&i64>>\n <soroban_sdk::xdr::ScVal as From<&u128>>\nand 16 others","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"required for `soroban_sdk::String` to implement `Into<soroban_sdk::xdr::ScVal>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required for `soroban_sdk::xdr::ScVal` to implement `From<&core::option::Option<soroban_sdk::String>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"1 redundant requirement hidden","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required for `&core::option::Option<soroban_sdk::String>` to implement `Into<soroban_sdk::xdr::ScVal>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required for `soroban_sdk::xdr::ScVal` to implement `TryFrom<&core::option::Option<soroban_sdk::String>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"required for `&core::option::Option<soroban_sdk::String>` to implement `TryInto<soroban_sdk::xdr::ScVal>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0277]\u001b[0m\u001b[0m\u001b[1m: the trait bound `soroban_sdk::xdr::ScVal: TryFrom<&core::option::Option<soroban_sdk::String>>` is not satisfied\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0mescrow/src/lib.rs:21:1\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m21\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m#[contracttype]\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mthe trait `From<soroban_sdk::String>` is not implemented for `soroban_sdk::xdr::ScVal`, which is required by `&core::option::Option<soroban_sdk::String>: TryInto<_>`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: the following other types implement trait `From<T>`:\u001b[0m\n\u001b[0m <&'a soroban_sdk::xdr::ScVal as From<soroban_env_common::object::ScValObjRef<'a>>>\u001b[0m\n\u001b[0m <soroban_sdk::xdr::ScVal as From<&()>>\u001b[0m\n\u001b[0m <soroban_sdk::xdr::ScVal as From<&bool>>\u001b[0m\n\u001b[0m <soroban_sdk::xdr::ScVal as From<&core::option::Option<T>>>\u001b[0m\n\u001b[0m <soroban_sdk::xdr::ScVal as From<&i128>>\u001b[0m\n\u001b[0m <soroban_sdk::xdr::ScVal as From<&i32>>\u001b[0m\n\u001b[0m <soroban_sdk::xdr::ScVal as From<&i64>>\u001b[0m\n\u001b[0m <soroban_sdk::xdr::ScVal as From<&u128>>\u001b[0m\n\u001b[0m and 16 others\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: required for `soroban_sdk::String` to implement `Into<soroban_sdk::xdr::ScVal>`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: required for `soroban_sdk::xdr::ScVal` to implement `From<&core::option::Option<soroban_sdk::String>>`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: 1 redundant requirement hidden\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: required for `&core::option::Option<soroban_sdk::String>` to implement `Into<soroban_sdk::xdr::ScVal>`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: required for `soroban_sdk::xdr::ScVal` to implement `TryFrom<&core::option::Option<soroban_sdk::String>>`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: required for `&core::option::Option<soroban_sdk::String>` to implement `TryInto<soroban_sdk::xdr::ScVal>`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this error originates in the attribute macro `contracttype` (in Nightly builds, run with -Z macro-backtrace for more info)\u001b[0m\n\n"}
{"$message_type":"diagnostic","message":"aborting due to 1 previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to 1 previous error\u001b[0m\n\n"}
{"$message_type":"diagnostic","message":"For more information about this error, try `rustc --explain E0277`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1mFor more information about this error, try `rustc --explain E0277`.\u001b[0m\n"}