diff --git a/.github/rust-info/action.yml b/.github/rust-info/action.yml index 76fd89b76a9..bd0ce42c3e4 100644 --- a/.github/rust-info/action.yml +++ b/.github/rust-info/action.yml @@ -10,4 +10,15 @@ runs: cargo +nightly --version cargo spellcheck --version bash --version + substrate-contracts-node --version + + # TODO: The installation of `cargo-contract` here can be removed after + # a new image of https://hub.docker.com/r/paritytech/ci-unified/tags has + # been published. At the time of this commit the Docker image is from + # Sep 11, 2024. This means that the `cargo-contract` binary in the image + # is also that old. There was a bug with `cargo-contract` erring on + # newer Rust versions (https://github.com/use-ink/cargo-contract/pull/1786), + # hence we make sure to use the latest `cargo-contract` here. + cargo install --git https://github.com/paritytech/cargo-contract --locked --branch master --force + cargo-contract --version shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fb05d907ce..b45836ae5e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ on: - 'FILE_HEADER' env: - IMAGE: paritytech/ci-unified:bullseye-1.75.0 + IMAGE: paritytech/ci-unified:bullseye-1.81.0 CARGO_TARGET_DIR: /ci-cache/${{ github.repository }}/targets/${{ github.ref_name }}/${{ github.job }} CARGO_INCREMENTAL: 0 PURELY_STD_CRATES: ink/codegen metadata engine e2e e2e/macro ink/ir @@ -270,6 +270,7 @@ jobs: # we are using a toolchain file in this directory # add required components for CI rustup component add rustfmt clippy + rustup component add rust-src rustc-dev llvm-tools-preview cargo check --verbose cargo +nightly fmt --all -- --check cargo clippy -- -D warnings; @@ -504,7 +505,7 @@ jobs: env: # Fix linking of `linkme`: https://github.com/dtolnay/linkme/issues/49 RUSTFLAGS: -Clink-arg=-z -Clink-arg=nostart-stop-gc - uses: docker://paritytech/ci-unified:bullseye-1.75.0 + uses: docker://paritytech/ci-unified:bullseye-1.81.0 with: # run all tests with --all-features, which will run the e2e-tests feature if present args: /bin/bash -c "scripts/for_all_contracts_exec.sh --path integration-tests --ignore public/static-buffer --partition ${{ matrix.partition }}/6 -- cargo test \ diff --git a/.github/workflows/measurements.yml b/.github/workflows/measurements.yml index a8e9e4fe67e..f5184c5a0ed 100644 --- a/.github/workflows/measurements.yml +++ b/.github/workflows/measurements.yml @@ -14,7 +14,7 @@ jobs: run: shell: bash container: - image: paritytech/ci-unified:bullseye-1.75.0 + image: paritytech/ci-unified:bullseye-1.81.0 strategy: fail-fast: false matrix: diff --git a/Cargo.lock b/Cargo.lock index 1722ee08163..a1a7d31649f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -879,7 +879,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] @@ -1275,12 +1275,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.8" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "darling_core 0.20.8", - "darling_macro 0.20.8", + "darling_core 0.20.10", + "darling_macro 0.20.10", ] [[package]] @@ -1299,15 +1299,15 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.8" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim 0.11.1", "syn 2.0.58", ] @@ -1324,11 +1324,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.8" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ - "darling_core 0.20.8", + "darling_core 0.20.10", "quote", "syn 2.0.58", ] @@ -2624,7 +2624,7 @@ dependencies = [ name = "ink_e2e_macro" version = "5.0.0" dependencies = [ - "darling 0.20.8", + "darling 0.20.10", "derive_more", "ink", "ink_e2e", @@ -6058,9 +6058,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -6202,7 +6202,7 @@ version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98dc84d7e6a0abd7ed407cce0bf60d7d58004f699460cffb979640717d1ab506" dependencies = [ - "darling 0.20.8", + "darling 0.20.10", "parity-scale-codec", "proc-macro-error", "quote", diff --git a/Cargo.toml b/Cargo.toml index de2485ba935..dcb7f9b7947 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ blake2 = { version = "0.10" } cargo_metadata = { version = "0.18.0" } cfg-if = { version = "1.0" } contract-build = { version = "4.1.1" } -darling = { version = "0.20.8" } +darling = { version = "0.20.10" } derive_more = { version = "0.99.17", default-features = false } either = { version = "1.12", default-features = false } funty = { version = "2.0.0" } diff --git a/crates/allocator/src/bump.rs b/crates/allocator/src/bump.rs index 6f0159ffda8..16db4bf7434 100644 --- a/crates/allocator/src/bump.rs +++ b/crates/allocator/src/bump.rs @@ -199,10 +199,9 @@ impl InnerAlloc { /// of a layout in the linear memory. /// - Initially `self.next` is `0`` and aligned /// - `layout.align() - 1` accounts for `0` as the first index. - /// - the binary with the inverse of the align creates a - /// bitmask that is used to zero out bits, ensuring alignment according to type - /// requirements and ensures that the next allocated pointer address is of the - /// power of 2. + /// - the binary with the inverse of the align creates a bitmask that is used to zero + /// out bits, ensuring alignment according to type requirements and ensures that the + /// next allocated pointer address is of the power of 2. fn align_ptr(&self, layout: &Layout) -> usize { (self.next + layout.align() - 1) & !(layout.align() - 1) } diff --git a/crates/e2e/src/error.rs b/crates/e2e/src/error.rs index bce499749ef..f043607f8a5 100644 --- a/crates/e2e/src/error.rs +++ b/crates/e2e/src/error.rs @@ -79,6 +79,7 @@ pub struct SandboxErr { impl SandboxErr { /// Create a new `SandboxErr` with the given message. + #[allow(dead_code)] pub fn new(msg: String) -> Self { Self { msg } } diff --git a/crates/e2e/src/xts.rs b/crates/e2e/src/xts.rs index 0c998314d89..0b2a43fdd03 100644 --- a/crates/e2e/src/xts.rs +++ b/crates/e2e/src/xts.rs @@ -333,12 +333,11 @@ where }) .submit_and_watch() .await - .map(|tx_progress| { + .inspect(|tx_progress| { log_info(&format!( "signed and submitted tx with hash {:?}", tx_progress.extrinsic_hash() )); - tx_progress }) .unwrap_or_else(|err| { panic!("error on call `submit_and_watch`: {err:?}"); diff --git a/crates/engine/src/database.rs b/crates/engine/src/database.rs index 8e743a0b645..84604a60355 100644 --- a/crates/engine/src/database.rs +++ b/crates/engine/src/database.rs @@ -70,7 +70,7 @@ impl Database { key: &[u8], ) -> Option<&Vec> { let hashed_key = storage_of_contract_key(account_id, key); - self.hmap.get(&hashed_key.to_vec()) + self.hmap.get(hashed_key.as_slice()) } /// Inserts `value` into the contract storage of `account_id` at storage key `key`. @@ -91,7 +91,7 @@ impl Database { key: &[u8], ) -> Option> { let hashed_key = storage_of_contract_key(account_id, key); - self.hmap.remove(&hashed_key.to_vec()) + self.hmap.remove(hashed_key.as_slice()) } /// Removes a key from the storage, returning the value at the key if the key diff --git a/crates/env/src/arithmetic.rs b/crates/env/src/arithmetic.rs index 8ee2416054b..07707ef1a7c 100644 --- a/crates/env/src/arithmetic.rs +++ b/crates/env/src/arithmetic.rs @@ -136,6 +136,7 @@ impl AtLeast32BitUnsigned for T where T: AtLeast32Bit + Unsigned {} /// Saturating arithmetic operations, returning maximum or minimum values instead of /// overflowing. +#[allow(dead_code)] pub trait Saturating { /// Saturating addition. Compute `self + rhs`, saturating at the numeric bounds /// instead of overflowing. @@ -194,53 +195,26 @@ mod tests { #[test] fn saturating_add() { - assert_eq!( - u64::max_value(), - Saturating::saturating_add(u64::max_value(), 1) - ) + assert_eq!(u64::MAX, Saturating::saturating_add(u64::MAX, 1)) } #[test] fn saturatiung_sub() { - assert_eq!( - u64::min_value(), - Saturating::saturating_sub(u64::min_value(), 1) - ) + assert_eq!(u64::MIN, Saturating::saturating_sub(u64::MIN, 1)) } #[test] fn saturating_mul() { - assert_eq!( - u64::max_value(), - Saturating::saturating_mul(u64::max_value(), 2) - ); - assert_eq!( - i64::max_value(), - Saturating::saturating_mul(i64::max_value(), 2) - ); - assert_eq!( - i64::min_value(), - Saturating::saturating_mul(i64::min_value(), 2) - ); - assert_eq!( - i64::min_value(), - Saturating::saturating_mul(2, i64::min_value()) - ); + assert_eq!(u64::MAX, Saturating::saturating_mul(u64::MAX, 2)); + assert_eq!(i64::MAX, Saturating::saturating_mul(i64::MAX, 2)); + assert_eq!(i64::MIN, Saturating::saturating_mul(i64::MIN, 2)); + assert_eq!(i64::MIN, Saturating::saturating_mul(2, i64::MIN)); } #[test] fn saturating_pow() { - assert_eq!( - u64::max_value(), - Saturating::saturating_pow(u64::max_value(), 2) - ); - assert_eq!( - i64::max_value(), - Saturating::saturating_pow(i64::min_value(), 2) - ); - assert_eq!( - i64::min_value(), - Saturating::saturating_pow(i64::min_value(), 3) - ); + assert_eq!(u64::MAX, Saturating::saturating_pow(u64::MAX, 2)); + assert_eq!(i64::MAX, Saturating::saturating_pow(i64::MIN, 2)); + assert_eq!(i64::MIN, Saturating::saturating_pow(i64::MIN, 3)); } } diff --git a/crates/env/src/chain_extension.rs b/crates/env/src/chain_extension.rs index b7b82ceaed8..e2ef7280f17 100644 --- a/crates/env/src/chain_extension.rs +++ b/crates/env/src/chain_extension.rs @@ -68,7 +68,7 @@ pub trait FromStatusCode: Sized { /// The type states for type parameter `O` and `ErrorCode` represent 4 different states: /// /// 1. The chain extension method makes use of the chain extension's error code: -/// `HandleErrorCode(E)` +/// `HandleErrorCode(E)` /// - **A:** The chain extension method returns a `Result` type, i.e. /// `IS_RESULT` is set to `true`. /// - **B:** The chain extension method returns a type `O` that is not a `Result` diff --git a/crates/env/src/engine/mod.rs b/crates/env/src/engine/mod.rs index 666e7b50de2..08a72ff4379 100644 --- a/crates/env/src/engine/mod.rs +++ b/crates/env/src/engine/mod.rs @@ -161,6 +161,8 @@ mod decode_instantiate_result_tests { struct ContractError(String); type AccountId = ::AccountId; + // The `allow(dead_code)` is for the `AccountId` in the struct. + #[allow(dead_code)] struct TestContractRef(AccountId); impl crate::ContractEnv for TestContractRef { diff --git a/crates/env/src/engine/on_chain/mod.rs b/crates/env/src/engine/on_chain/mod.rs index 9f107fe7573..274384174b7 100644 --- a/crates/env/src/engine/on_chain/mod.rs +++ b/crates/env/src/engine/on_chain/mod.rs @@ -44,6 +44,7 @@ impl OnInstance for EnvInstance { static mut INSTANCE: EnvInstance = EnvInstance { buffer: StaticBuffer::new(), }; + #[allow(static_mut_refs)] f(unsafe { &mut INSTANCE }) } } diff --git a/crates/ink/codegen/src/generator/item_impls.rs b/crates/ink/codegen/src/generator/item_impls.rs index 3d46ab10fd5..f982dd7911b 100644 --- a/crates/ink/codegen/src/generator/item_impls.rs +++ b/crates/ink/codegen/src/generator/item_impls.rs @@ -227,8 +227,14 @@ impl ItemImpls<'_> { /// /// # Developer Note /// - /// The `__ink_dylint_Constructor` config attribute is used here to convey the + /// The `dragonfly` config attribute is used here to convey the /// information that the generated function is an ink! constructor to `dylint`. + /// + /// + /// We decided on this attribute to mark the function, as it has to be a + /// key-value pair that is well known to `cargo`. dragonfly seems like an + /// obscure target which it is highly unlikely that someone will ever + /// compile a contract for. fn generate_inherent_constructor(constructor: &ir::Constructor) -> TokenStream2 { let span = constructor.span(); let attrs = constructor.attrs(); @@ -239,7 +245,7 @@ impl ItemImpls<'_> { let output = constructor.output(); quote_spanned!(span => #( #attrs )* - #[cfg(not(feature = "__ink_dylint_Constructor"))] + #[cfg(not(target_os = "dragonfly"))] #vis fn #ident( #( #inputs ),* ) -> #output { #( #statements )* } diff --git a/crates/ink/codegen/src/generator/storage.rs b/crates/ink/codegen/src/generator/storage.rs index 0db3d386987..6dd2cbbce83 100644 --- a/crates/ink/codegen/src/generator/storage.rs +++ b/crates/ink/codegen/src/generator/storage.rs @@ -81,8 +81,13 @@ impl Storage<'_> { /// /// # Developer Note /// - /// The `__ink_dylint_Storage` config attribute is used here to convey the + /// The `fortanix` config attribute is used here to convey the /// information that the generated struct is an ink! storage struct to `dylint`. + /// + /// We decided on this attribute to mark the function, as it has to be a + /// key-value pair that is well known to `cargo`. `fortanix` seems like an obscure + /// vendor, for which it is highly unlikely that someone will ever compile + /// a contract for. fn generate_storage_struct(&self) -> TokenStream2 { let storage = self.contract.module().storage(); let span = storage.span(); @@ -94,7 +99,7 @@ impl Storage<'_> { #(#attrs)* #[::ink::storage_item] #[cfg_attr(test, derive(::core::fmt::Debug))] - #[cfg(not(feature = "__ink_dylint_Storage"))] + #[cfg(not(target_vendor = "fortanix"))] pub struct #ident #generics { #( #fields ),* } diff --git a/crates/ink/ir/src/error.rs b/crates/ink/ir/src/error.rs index 5fdaeaefd85..b1d5e1ca47c 100644 --- a/crates/ink/ir/src/error.rs +++ b/crates/ink/ir/src/error.rs @@ -40,8 +40,7 @@ impl ExtError for syn::Error { /// /// On stable Rust this might yield higher quality error span information to the user /// than [`format_err`](`crate::format_err`). -/// - Source: -/// [`syn::Error::new_spanned`](https://docs.rs/syn/1.0.33/syn/struct.Error.html#method.new_spanned) +/// - Source: [`syn::Error::new_spanned`](https://docs.rs/syn/1.0.33/syn/struct.Error.html#method.new_spanned) /// - Tracking issue: [`#54725`](https://github.com/rust-lang/rust/issues/54725) #[macro_export] macro_rules! format_err_spanned { @@ -81,8 +80,7 @@ macro_rules! format_err_spanned_value { /// /// On stable Rust this might yield worse error span information to the user /// than [`format_err_spanned`]. -/// - Source: -/// [`syn::Error::new_spanned`](https://docs.rs/syn/1.0.33/syn/struct.Error.html#method.new_spanned) +/// - Source: [`syn::Error::new_spanned`](https://docs.rs/syn/1.0.33/syn/struct.Error.html#method.new_spanned) /// - Tracking issue: [`#54725`](https://github.com/rust-lang/rust/issues/54725) #[macro_export] macro_rules! format_err { diff --git a/crates/ink/ir/src/ir/item_impl/callable.rs b/crates/ink/ir/src/ir/item_impl/callable.rs index 4e8259c6311..ea10d9230b9 100644 --- a/crates/ink/ir/src/ir/item_impl/callable.rs +++ b/crates/ink/ir/src/ir/item_impl/callable.rs @@ -309,9 +309,9 @@ pub trait Callable { /// /// These recommendation mainly apply to trait implementation blocks: /// -/// - The recommendation by the ink! team is to use the full-path approach -/// wherever possible; OR import the trait and use only its identifier with -/// an additional namespace if required to disambiguate selectors. +/// - The recommendation by the ink! team is to use the full-path approach wherever +/// possible; OR import the trait and use only its identifier with an additional +/// namespace if required to disambiguate selectors. /// - Try not to intermix the above recommendations. /// - Avoid directly setting the selector of an ink! message or constructor. Only do this /// if nothing else helps and you need a very specific selector, e.g. in case of diff --git a/crates/ink/ir/src/ir/item_mod.rs b/crates/ink/ir/src/ir/item_mod.rs index 1635696bf97..9754a934b28 100644 --- a/crates/ink/ir/src/ir/item_mod.rs +++ b/crates/ink/ir/src/ir/item_mod.rs @@ -240,10 +240,10 @@ impl ItemMod { } /// Ensures that: - /// - At most one wildcard selector exists among ink! messages, as well as - /// ink! constructors. - /// - Where a wildcard selector is defined for a message, at most one other - /// message is defined which must have a well known selector. + /// - At most one wildcard selector exists among ink! messages, as well as ink! + /// constructors. + /// - Where a wildcard selector is defined for a message, at most one other message is + /// defined which must have a well known selector. fn ensure_valid_wildcard_selector_usage( items: &[ir::Item], ) -> Result<(), syn::Error> { diff --git a/crates/ink/ir/src/ir/selector.rs b/crates/ink/ir/src/ir/selector.rs index 88b634a66a6..3ed8761a1e1 100644 --- a/crates/ink/ir/src/ir/selector.rs +++ b/crates/ink/ir/src/ir/selector.rs @@ -89,8 +89,8 @@ impl Selector { /// For inherent implementation blocks, when `trait_prefix` is `None` the composed /// selector is computed as follows: /// - /// 1. Apply `BLAKE2` 256-bit hash `H` on the bytes of the ASCII representation of - /// the `fn_ident` identifier. + /// 1. Apply `BLAKE2` 256-bit hash `H` on the bytes of the ASCII representation of the + /// `fn_ident` identifier. /// 1. The first 4 bytes of `H` make up the selector. /// /// # Trait Implementation Blocks diff --git a/crates/ink/macro/src/lib.rs b/crates/ink/macro/src/lib.rs index 82b7413ee9f..b180506e5b1 100644 --- a/crates/ink/macro/src/lib.rs +++ b/crates/ink/macro/src/lib.rs @@ -143,18 +143,18 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// ``` /// /// **Allowed attributes by default:** `cfg`, `cfg_attr`, `allow`, `warn`, `deny`, -/// `forbid`, `deprecated`, `must_use`, `doc`, `rustfmt`. +/// `forbid`, `deprecated`, `must_use`, `doc`, `rustfmt`. /// /// - `env: impl Environment` /// /// Tells the ink! code generator which environment to use for the ink! smart -/// contract. The environment must implement the `Environment` (defined in `ink_env`) -/// trait and provides all the necessary fundamental type definitions for `Balance`, -/// `AccountId` etc. +/// contract. The environment must implement the `Environment` (defined in `ink_env`) +/// trait and provides all the necessary fundamental type definitions for `Balance`, +/// `AccountId` etc. /// /// When using a custom `Environment` implementation for a smart contract all types /// that it exposes to the ink! smart contract and the mirrored types used in the -/// runtime must be aligned with respect to SCALE encoding and semantics. +/// runtime must be aligned with respect to SCALE encoding and semantics. /// /// **Usage Example:** /// @@ -174,7 +174,7 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// } /// ``` /// A user might implement their ink! smart contract using the above custom -/// `Environment` implementation as demonstrated below: +/// `Environment` implementation as demonstrated below: /// ``` /// #[ink::contract(env = MyEnvironment)] /// mod my_contract { @@ -215,9 +215,9 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// - There must be exactly one `#[ink(storage)]` struct. /// /// This struct defines the layout of the storage that the ink! smart contract -/// operates on. The user is able to use a variety of built-in facilities, combine -/// them in various ways or even provide their own implementations of storage data -/// structures. +/// operates on. The user is able to use a variety of built-in facilities, combine +/// them in various ways or even provide their own implementations of storage data +/// structures. /// /// For more information visit the `ink::storage` crate documentation. /// @@ -242,9 +242,9 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// - There must be at least one `#[ink(constructor)]` defined method. /// /// Methods flagged with `#[ink(constructor)]` are special in that they are -/// dispatchable upon contract instantiation. A contract may define multiple such -/// constructors which allow users of the contract to instantiate a contract in -/// multiple different ways. +/// dispatchable upon contract instantiation. A contract may define multiple such +/// constructors which allow users of the contract to instantiate a contract in +/// multiple different ways. /// /// **Example:** /// @@ -273,7 +273,7 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// /// Methods flagged with `#[ink(message)]` are special in that they are dispatchable /// upon contract invocation. The set of ink! messages defined for an ink! smart -/// contract define its API surface with which users are allowed to interact. +/// contract define its API surface with which users are allowed to interact. /// /// An ink! smart contract can have multiple such ink! messages defined. /// @@ -285,7 +285,7 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// **Example:** /// /// Given the `Flipper` contract definition above we add some `#[ink(message)]` -/// definitions as follows: +/// definitions as follows: /// /// ``` /// # #[ink::contract] @@ -317,11 +317,11 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// **Payable Messages:** /// /// An ink! message by default will reject calls that additional fund the smart -/// contract. Authors of ink! smart contracts can make an ink! message payable by -/// adding the `payable` flag to it. An example below: +/// contract. Authors of ink! smart contracts can make an ink! message payable by +/// adding the `payable` flag to it. An example below: /// /// Note that ink! constructors are always implicitly payable and thus cannot be -/// flagged as such. +/// flagged as such. /// /// ``` /// # #[ink::contract] @@ -647,7 +647,7 @@ pub fn contract(attr: TokenStream, item: TokenStream) -> TokenStream { /// ``` /// /// **Allowed attributes by default:** `cfg`, `cfg_attr`, `allow`, `warn`, `deny`, -/// `forbid`, `deprecated`, `must_use`, `doc`, `rustfmt`. +/// `forbid`, `deprecated`, `must_use`, `doc`, `rustfmt`. #[proc_macro_attribute] pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream { trait_def::analyze(attr.into(), item.into()).into() diff --git a/crates/ink/src/chain_extension.rs b/crates/ink/src/chain_extension.rs index 254b36f520d..c03f9233424 100644 --- a/crates/ink/src/chain_extension.rs +++ b/crates/ink/src/chain_extension.rs @@ -33,6 +33,7 @@ pub trait ChainExtensionInstance { /// /// Every chain extension defines a set of chain extension methods /// that share a common error code type. +#[allow(dead_code)] pub trait ChainExtension { /// The error code that determines whether a chain extension method call was /// successful. diff --git a/crates/ink/src/codegen/is_same_type.rs b/crates/ink/src/codegen/is_same_type.rs index 594617080c4..9236d563c66 100644 --- a/crates/ink/src/codegen/is_same_type.rs +++ b/crates/ink/src/codegen/is_same_type.rs @@ -43,3 +43,9 @@ impl IsSameType { } } } + +impl Default for IsSameType { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/ink/src/codegen/utils/same_type.rs b/crates/ink/src/codegen/utils/same_type.rs index c2a75d215de..1587754d39c 100644 --- a/crates/ink/src/codegen/utils/same_type.rs +++ b/crates/ink/src/codegen/utils/same_type.rs @@ -43,3 +43,9 @@ impl IsSameType { } } } + +impl Default for IsSameType { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr b/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr index 32869d879c5..0d7c0c816ab 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr @@ -2,12 +2,12 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied --> tests/ui/contract/fail/constructor-input-non-codec.rs:11:28 | 11 | pub fn constructor(_input: NonCodecType) -> Self { - | ^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType` + | ^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`, which is required by `NonCodecType: ink::parity_scale_codec::Decode` | = help: the following other types implement trait `WrapperTypeDecode`: + Arc Box Rc - Arc = note: required for `NonCodecType` to implement `ink::parity_scale_codec::Decode` note: required by a bound in `DispatchInput` --> src/codegen/dispatch/type_check.rs @@ -18,25 +18,25 @@ note: required by a bound in `DispatchInput` | T: scale::Decode + 'static; | ^^^^^^^^^^^^^ required by this bound in `DispatchInput` -error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied +error[E0277]: the trait bound `NonCodecType: ink::parity_scale_codec::Decode` is not satisfied --> tests/ui/contract/fail/constructor-input-non-codec.rs:11:9 | 11 | / pub fn constructor(_input: NonCodecType) -> Self { 12 | | Self {} 13 | | } - | |_________^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType` + | |_________^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`, which is required by `NonCodecType: ink::parity_scale_codec::Decode` | = help: the following other types implement trait `WrapperTypeDecode`: + Arc Box Rc - Arc = note: required for `NonCodecType` to implement `ink::parity_scale_codec::Decode` -error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied +error[E0277]: the trait bound `NonCodecType: Encode` is not satisfied --> tests/ui/contract/fail/constructor-input-non-codec.rs:1:1 | 1 | #[ink::contract] - | ^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType` + | ^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType`, which is required by `NonCodecType: Encode` ... 11 | / pub fn constructor(_input: NonCodecType) -> Self { 12 | | Self {} @@ -44,15 +44,15 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied | |_________- required by a bound introduced by this call | = help: the following other types implement trait `WrapperTypeEncode`: + &T + &mut T + Arc Box Cow<'a, T> - ink::parity_scale_codec::Ref<'a, T, U> Rc - Arc - Vec String - &T - &mut T + Vec + ink::parity_scale_codec::Ref<'a, T, U> = note: required for `NonCodecType` to implement `Encode` note: required by a bound in `ExecutionInput::>::push_arg` --> $WORKSPACE/crates/env/src/call/execution.rs 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 13b4f57ea6b..7df2f3bbc2d 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 @@ -7,5 +7,38 @@ error[E0277]: the trait bound `ConstructorOutputValue` is not implemented for `ConstructorOutputValue>` | = help: the following other types implement trait `ConstructorOutput`: - ConstructorOutputValue> ConstructorOutputValue + ConstructorOutputValue> + +error[E0277]: the trait bound `Result: ConstructorReturnType` is not satisfied + --> tests/ui/contract/fail/constructor-return-result-invalid.rs:14:33 + | +14 | pub fn constructor() -> Result { + | - ^^^^^^^^^^^^^^^^^ the trait `ConstructorReturnType` is not implemented for `Result` + | _________| + | | +15 | | Ok(5_u8) +16 | | } + | |_________- required by a bound introduced by this call + | + = help: the following other types implement trait `ConstructorReturnType`: + `Result` implements `ConstructorReturnType` + `Result` implements `ConstructorReturnType` +note: required by a bound in `CreateBuilder::>>::returns` + --> $WORKSPACE/crates/env/src/call/create_builder.rs + | + | pub fn returns( + | ------- required by a bound in this associated function +... + | R: ConstructorReturnType, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `CreateBuilder::>>::returns` + +error[E0277]: the trait bound `ConstructorOutputValue>: ConstructorOutput` is not satisfied + --> tests/ui/contract/fail/constructor-return-result-invalid.rs:4:16 + | +4 | pub struct Contract {} + | ^^^^^^^^ the trait `ConstructorOutput` is not implemented for `ConstructorOutputValue>` + | + = 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 ce7891f77f5..712e55efa02 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 @@ -20,7 +20,7 @@ error[E0277]: the trait bound `contract::Error: WrapperTypeDecode` is not satisf --> tests/ui/contract/fail/constructor-return-result-non-codec-error.rs:13:33 | 13 | pub fn constructor() -> Result { - | - ^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `contract::Error` + | - ^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `contract::Error`, which is required by `Result: ConstructorReturnType` | _________| | | 14 | | Ok(Self {}) @@ -28,9 +28,9 @@ error[E0277]: the trait bound `contract::Error: WrapperTypeDecode` is not satisf | |_________- required by a bound introduced by this call | = help: the following other types implement trait `WrapperTypeDecode`: + Arc Box Rc - Arc = note: required for `contract::Error` to implement `ink::parity_scale_codec::Decode` = note: required for `Result` to implement `ConstructorReturnType` note: required by a bound in `CreateBuilder::>>::returns` @@ -46,17 +46,17 @@ error[E0277]: the trait bound `contract::Error: TypeInfo` is not satisfied --> tests/ui/contract/fail/constructor-return-result-non-codec-error.rs:4:16 | 4 | pub struct Contract {} - | ^^^^^^^^ the trait `TypeInfo` is not implemented for `contract::Error` + | ^^^^^^^^ the trait `TypeInfo` is not implemented for `contract::Error`, which is required by `Result, LangError>: TypeInfo` | = help: the following other types implement trait `TypeInfo`: - bool - char - i8 - i16 - i32 - i64 - i128 - u8 + &T + &mut T + () + (A, B) + (A, B, C) + (A, B, C, D) + (A, B, C, D, E) + (A, B, C, D, E, F) and $N others = note: required for `Result<(), contract::Error>` to implement `TypeInfo` = note: 1 redundant requirement hidden diff --git a/crates/ink/tests/ui/contract/fail/constructor-self-receiver-03.stderr b/crates/ink/tests/ui/contract/fail/constructor-self-receiver-03.stderr index 874d0aae592..3ae07a86640 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-self-receiver-03.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-self-receiver-03.stderr @@ -1,8 +1,8 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here +error: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type --> tests/ui/contract/fail/constructor-self-receiver-03.rs:8:34 | 8 | pub fn constructor(this: &Self) -> Self { - | ^ explicit lifetime name needed here + | ^ this lifetime must come from the implemented type error[E0411]: cannot find type `Self` in this scope --> tests/ui/contract/fail/constructor-self-receiver-03.rs:8:35 @@ -22,16 +22,10 @@ error[E0411]: cannot find type `Self` in this scope 8 | pub fn constructor(this: &Self) -> Self { | ^^^^ `Self` is only available in impls, traits, and type definitions -error[E0277]: the trait bound `&Contract: WrapperTypeDecode` is not satisfied - --> tests/ui/contract/fail/constructor-self-receiver-03.rs:8:9 - | -8 | / pub fn constructor(this: &Self) -> Self { -9 | | Self {} -10 | | } - | |_________^ the trait `WrapperTypeDecode` is not implemented for `&Contract` - | - = help: the following other types implement trait `WrapperTypeDecode`: - Box - Rc - Arc - = note: required for `&Contract` to implement `ink::parity_scale_codec::Decode` +warning: unused variable: `this` + --> tests/ui/contract/fail/constructor-self-receiver-03.rs:8:28 + | +8 | pub fn constructor(this: &Self) -> Self { + | ^^^^ help: if this is intentional, prefix it with an underscore: `_this` + | + = note: `#[warn(unused_variables)]` on by default diff --git a/crates/ink/tests/ui/contract/fail/impl-block-for-non-storage-01.stderr b/crates/ink/tests/ui/contract/fail/impl-block-for-non-storage-01.stderr index afe52ca0748..007126214ec 100644 --- a/crates/ink/tests/ui/contract/fail/impl-block-for-non-storage-01.stderr +++ b/crates/ink/tests/ui/contract/fail/impl-block-for-non-storage-01.stderr @@ -20,10 +20,8 @@ error[E0599]: no function or associated item named `constructor_2` found for str ... | 19 | | #[ink(constructor)] 20 | | pub fn constructor_2() -> Self { - | | -^^^^^^^^^^^^^ - | | || - | | |function or associated item not found in `Contract` - | |_______________|help: there is an associated function with a similar name: `constructor_1` + | | -^^^^^^^^^^^^^ function or associated item not found in `Contract` + | |_______________| | | note: if you're trying to build a new `Contract`, consider using `contract::_::::constructor_1` which returns `Contract` @@ -31,6 +29,10 @@ note: if you're trying to build a new `Contract`, consider using `contract::_::< | 8 | pub fn constructor_1() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: there is an associated function `constructor_1` with a similar name + | +20 | pub fn constructor_1() -> Self { + | ~~~~~~~~~~~~~ error[E0599]: no function or associated item named `message_2` found for struct `Contract` in the current scope --> tests/ui/contract/fail/impl-block-for-non-storage-01.rs:25:16 @@ -45,10 +47,8 @@ error[E0599]: no function or associated item named `message_2` found for struct ... | 24 | | #[ink(message)] 25 | | pub fn message_2(&self) {} - | | -^^^^^^^^^ - | | || - | | |function or associated item not found in `Contract` - | |_______________|help: there is a method with a similar name: `message_1` + | | -^^^^^^^^^ function or associated item not found in `Contract` + | |_______________| | | note: if you're trying to build a new `Contract`, consider using `contract::_::::constructor_1` which returns `Contract` @@ -56,3 +56,8 @@ note: if you're trying to build a new `Contract`, consider using `contract::_::< | 8 | pub fn constructor_1() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: there is a method `message_1` with a similar name, but with different arguments + --> tests/ui/contract/fail/impl-block-for-non-storage-01.rs:13:9 + | +13 | pub fn message_1(&self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/ink/tests/ui/contract/fail/impl-block-using-env-no-marker.stderr b/crates/ink/tests/ui/contract/fail/impl-block-using-env-no-marker.stderr index cc74017436f..0897fb1a54c 100644 --- a/crates/ink/tests/ui/contract/fail/impl-block-using-env-no-marker.stderr +++ b/crates/ink/tests/ui/contract/fail/impl-block-using-env-no-marker.stderr @@ -5,7 +5,7 @@ error[E0599]: no method named `env` found for reference `&Contract` in the curre | ^^^ method not found in `&Contract` | = help: items from traits can only be used if the trait is in scope -help: the following trait is implemented but not in scope; perhaps add a `use` for it: +help: trait `Env` which provides `env` is implemented but not in scope; perhaps you want to import it | 1 + use ink::codegen::Env; | diff --git a/crates/ink/tests/ui/contract/fail/impl-block-using-static-env-no-marker.stderr b/crates/ink/tests/ui/contract/fail/impl-block-using-static-env-no-marker.stderr index 82ca51e2862..4e6c38bc762 100644 --- a/crates/ink/tests/ui/contract/fail/impl-block-using-static-env-no-marker.stderr +++ b/crates/ink/tests/ui/contract/fail/impl-block-using-static-env-no-marker.stderr @@ -18,7 +18,7 @@ note: if you're trying to build a new `Contract` consider using one of the follo 19 | fn constructor_impl() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: items from traits can only be used if the trait is in scope -help: the following trait is implemented but not in scope; perhaps add a `use` for it: +help: trait `StaticEnv` which provides `env` is implemented but not in scope; perhaps you want to import it | 1 + use ink::codegen::StaticEnv; | diff --git a/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr b/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr index e0044f00afd..b9b0ba7e17a 100644 --- a/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr @@ -2,12 +2,12 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied --> tests/ui/contract/fail/message-input-non-codec.rs:16:31 | 16 | pub fn message(&self, _input: NonCodecType) {} - | ^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType` + | ^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`, which is required by `NonCodecType: ink::parity_scale_codec::Decode` | = help: the following other types implement trait `WrapperTypeDecode`: + Arc Box Rc - Arc = note: required for `NonCodecType` to implement `ink::parity_scale_codec::Decode` note: required by a bound in `DispatchInput` --> src/codegen/dispatch/type_check.rs @@ -18,37 +18,37 @@ note: required by a bound in `DispatchInput` | T: scale::Decode + 'static; | ^^^^^^^^^^^^^ required by this bound in `DispatchInput` -error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied +error[E0277]: the trait bound `NonCodecType: ink::parity_scale_codec::Decode` is not satisfied --> tests/ui/contract/fail/message-input-non-codec.rs:16:9 | 16 | pub fn message(&self, _input: NonCodecType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`, which is required by `NonCodecType: ink::parity_scale_codec::Decode` | = help: the following other types implement trait `WrapperTypeDecode`: + Arc Box Rc - Arc = note: required for `NonCodecType` to implement `ink::parity_scale_codec::Decode` -error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied +error[E0277]: the trait bound `NonCodecType: Encode` is not satisfied --> tests/ui/contract/fail/message-input-non-codec.rs:1:1 | 1 | #[ink::contract] - | ^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType` + | ^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType`, which is required by `NonCodecType: Encode` ... 16 | pub fn message(&self, _input: NonCodecType) {} | ---------------------------------------------- required by a bound introduced by this call | = help: the following other types implement trait `WrapperTypeEncode`: + &T + &mut T + Arc Box Cow<'a, T> - ink::parity_scale_codec::Ref<'a, T, U> Rc - Arc - Vec String - &T - &mut T + Vec + ink::parity_scale_codec::Ref<'a, T, U> = note: required for `NonCodecType` to implement `Encode` note: required by a bound in `ExecutionInput::>::push_arg` --> $WORKSPACE/crates/env/src/call/execution.rs @@ -63,12 +63,13 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder tests/ui/contract/fail/message-input-non-codec.rs:16:9 | 16 | pub fn message(&self, _input: NonCodecType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called due to unsatisfied trait bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ::: $WORKSPACE/crates/env/src/call/execution.rs | | pub struct ArgumentList { | ----------------------------------- doesn't satisfy `_: Encode` | + = note: consider using `--verbose` to print the full type name to the console = note: the following trait bounds were not satisfied: `ArgumentList, ArgumentList>: Encode` diff --git a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr index a1a4dc2841c..7c9f94acc12 100644 --- a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr @@ -2,18 +2,18 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied --> tests/ui/contract/fail/message-returns-non-codec.rs:16:34 | 16 | pub fn message(&self) -> NonCodecType { - | ^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType` + | ^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType`, which is required by `NonCodecType: Encode` | = help: the following other types implement trait `WrapperTypeEncode`: + &T + &mut T + Arc Box Cow<'a, T> - ink::parity_scale_codec::Ref<'a, T, U> Rc - Arc - Vec String - &T - &mut T + Vec + ink::parity_scale_codec::Ref<'a, T, U> = note: required for `NonCodecType` to implement `Encode` note: required by a bound in `DispatchOutput` --> src/codegen/dispatch/type_check.rs @@ -46,17 +46,19 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder tests/ui/contract/fail/message-returns-non-codec.rs:16:9 | 4 | pub struct NonCodecType; - | ----------------------- doesn't satisfy `NonCodecType: ink::parity_scale_codec::Decode` + | ----------------------- doesn't satisfy `NonCodecType: WrapperTypeDecode` or `NonCodecType: ink::parity_scale_codec::Decode` ... 16 | / pub fn message(&self) -> NonCodecType { 17 | | NonCodecType 18 | | } - | |_________^ method cannot be called due to unsatisfied trait bounds + | |_________^ | + = note: consider using `--verbose` to print the full type name to the console = note: the following trait bounds were not satisfied: - `NonCodecType: ink::parity_scale_codec::Decode` -note: the trait `ink::parity_scale_codec::Decode` must be implemented + `NonCodecType: WrapperTypeDecode` + which is required by `NonCodecType: ink::parity_scale_codec::Decode` +note: the trait `WrapperTypeDecode` must be implemented --> $CARGO/parity-scale-codec-3.6.9/src/codec.rs | - | pub trait Decode: Sized { - | ^^^^^^^^^^^^^^^^^^^^^^^ + | pub trait WrapperTypeDecode: Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/ink/tests/ui/contract/fail/module-missing-constructor.stderr b/crates/ink/tests/ui/contract/fail/module-missing-constructor.stderr index 5af1026c08f..4f07a523ddf 100644 --- a/crates/ink/tests/ui/contract/fail/module-missing-constructor.stderr +++ b/crates/ink/tests/ui/contract/fail/module-missing-constructor.stderr @@ -4,7 +4,6 @@ error: missing ink! constructor 2 | / mod contract { 3 | | #[ink(storage)] 4 | | pub struct Contract {} -5 | | ... | 9 | | } 10 | | } diff --git a/crates/ink/tests/ui/contract/fail/module-missing-message.stderr b/crates/ink/tests/ui/contract/fail/module-missing-message.stderr index 84d45a91b0a..06fd0a83793 100644 --- a/crates/ink/tests/ui/contract/fail/module-missing-message.stderr +++ b/crates/ink/tests/ui/contract/fail/module-missing-message.stderr @@ -4,7 +4,6 @@ error: missing ink! message 2 | / mod contract { 3 | | #[ink(storage)] 4 | | pub struct Contract {} -5 | | ... | 11 | | } 12 | | } diff --git a/crates/ink/tests/ui/contract/fail/module-missing-storage.stderr b/crates/ink/tests/ui/contract/fail/module-missing-storage.stderr index 7484faf031e..fa33734f448 100644 --- a/crates/ink/tests/ui/contract/fail/module-missing-storage.stderr +++ b/crates/ink/tests/ui/contract/fail/module-missing-storage.stderr @@ -4,7 +4,6 @@ error: missing ink! storage struct 2 | / mod contract { 3 | | // #[ink(storage)] 4 | | pub struct Contract {} -5 | | ... | 12 | | } 13 | | } diff --git a/crates/ink/tests/ui/contract/fail/module-multiple-storages.stderr b/crates/ink/tests/ui/contract/fail/module-multiple-storages.stderr index 2ee9c921f63..dd635dc707a 100644 --- a/crates/ink/tests/ui/contract/fail/module-multiple-storages.stderr +++ b/crates/ink/tests/ui/contract/fail/module-multiple-storages.stderr @@ -4,7 +4,6 @@ error: encountered multiple ink! storage structs, expected exactly one 2 | / mod contract { 3 | | #[ink(storage)] 4 | | pub struct Contract {} -5 | | ... | 27 | | } 28 | | } diff --git a/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-1.stderr b/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-1.stderr index 229df39f15c..1520d4d85f8 100644 --- a/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-1.stderr +++ b/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-1.stderr @@ -21,3 +21,75 @@ error[E0119]: conflicting implementations of trait `TraitCallForwarderFor<108389 41 | | fn message(&self) {} 42 | | } | |_____^ conflicting implementation for `contract::_::CallBuilder` + +error[E0283]: type annotations needed + --> tests/ui/contract/fail/trait-message-selector-overlap-1.rs:17:1 + | +17 | #[ink::contract] + | ^^^^^^^^^^^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::messageOutput` + | + = note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate: + - impl ImpliesReturn for Execution; + - impl ImpliesReturn<()> for ink::ink_env::call::CallBuilder, Set>, Set<()>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for ink::ink_env::call::CallBuilder, Set>, Set>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for T; + = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` +note: required by a bound in `foo1::TraitDefinition::messageOutput` + --> tests/ui/contract/fail/trait-message-selector-overlap-1.rs:4:9 + | +2 | #[ink::trait_definition] + | ------------------------ required by a bound in this associated type +3 | pub trait TraitDefinition { +4 | / #[ink(message)] +5 | | fn message(&self); + | |__________________________^ required by this bound in `TraitDefinition::messageOutput` + = note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0283]: type annotations needed + --> tests/ui/contract/fail/trait-message-selector-overlap-1.rs:17:1 + | +17 | #[ink::contract] + | ^^^^^^^^^^^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::messageOutput` + | + = note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate: + - impl ImpliesReturn for Execution; + - impl ImpliesReturn<()> for ink::ink_env::call::CallBuilder, Set>, Set<()>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for ink::ink_env::call::CallBuilder, Set>, Set>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for T; + = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` +note: required by a bound in `foo2::TraitDefinition::messageOutput` + --> tests/ui/contract/fail/trait-message-selector-overlap-1.rs:12:9 + | +10 | #[ink::trait_definition] + | ------------------------ required by a bound in this associated type +11 | pub trait TraitDefinition { +12 | / #[ink(message)] +13 | | fn message(&self); + | |__________________________^ required by this bound in `TraitDefinition::messageOutput` + = note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: this function depends on never type fallback being `()` + --> tests/ui/contract/fail/trait-message-selector-overlap-1.rs:25:5 + | +25 | pub struct Contract {} + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #123748 + = help: specify the types explicitly +note: in edition 2024, the requirement `!: WrapperTypeDecode` will fail + --> tests/ui/contract/fail/trait-message-selector-overlap-1.rs:36:9 + | +36 | fn message(&self) {} + | ^^^^^^^^^^^^^^^^^^^^ + = note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default diff --git a/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-2.stderr b/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-2.stderr index 3c923d7b8f5..395c19177c9 100644 --- a/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-2.stderr +++ b/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-2.stderr @@ -21,3 +21,75 @@ error[E0119]: conflicting implementations of trait `TraitCallForwarderFor<151820 41 | | fn message(&self) {} 42 | | } | |_____^ conflicting implementation for `contract::_::CallBuilder` + +error[E0283]: type annotations needed + --> tests/ui/contract/fail/trait-message-selector-overlap-2.rs:17:1 + | +17 | #[ink::contract] + | ^^^^^^^^^^^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::messageOutput` + | + = note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate: + - impl ImpliesReturn for Execution; + - impl ImpliesReturn<()> for ink::ink_env::call::CallBuilder, Set>, Set<()>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for ink::ink_env::call::CallBuilder, Set>, Set>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for T; + = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` +note: required by a bound in `foo1::TraitDefinition::messageOutput` + --> tests/ui/contract/fail/trait-message-selector-overlap-2.rs:4:9 + | +2 | #[ink::trait_definition(namespace = "same")] + | -------------------------------------------- required by a bound in this associated type +3 | pub trait TraitDefinition { +4 | / #[ink(message)] +5 | | fn message(&self); + | |__________________________^ required by this bound in `TraitDefinition::messageOutput` + = note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0283]: type annotations needed + --> tests/ui/contract/fail/trait-message-selector-overlap-2.rs:17:1 + | +17 | #[ink::contract] + | ^^^^^^^^^^^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::messageOutput` + | + = note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate: + - impl ImpliesReturn for Execution; + - impl ImpliesReturn<()> for ink::ink_env::call::CallBuilder, Set>, Set<()>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for ink::ink_env::call::CallBuilder, Set>, Set>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for T; + = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` +note: required by a bound in `foo2::TraitDefinition::messageOutput` + --> tests/ui/contract/fail/trait-message-selector-overlap-2.rs:12:9 + | +10 | #[ink::trait_definition(namespace = "same")] + | -------------------------------------------- required by a bound in this associated type +11 | pub trait TraitDefinition { +12 | / #[ink(message)] +13 | | fn message(&self); + | |__________________________^ required by this bound in `TraitDefinition::messageOutput` + = note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: this function depends on never type fallback being `()` + --> tests/ui/contract/fail/trait-message-selector-overlap-2.rs:25:5 + | +25 | pub struct Contract {} + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #123748 + = help: specify the types explicitly +note: in edition 2024, the requirement `!: WrapperTypeDecode` will fail + --> tests/ui/contract/fail/trait-message-selector-overlap-2.rs:36:9 + | +36 | fn message(&self) {} + | ^^^^^^^^^^^^^^^^^^^^ + = note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default diff --git a/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-3.stderr b/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-3.stderr index 284acc45005..7ae1cf120f7 100644 --- a/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-3.stderr +++ b/crates/ink/tests/ui/contract/fail/trait-message-selector-overlap-3.stderr @@ -21,3 +21,75 @@ error[E0119]: conflicting implementations of trait `TraitCallForwarderFor<42>` f 41 | | fn message2(&self) {} 42 | | } | |_____^ conflicting implementation for `contract::_::CallBuilder` + +error[E0283]: type annotations needed + --> tests/ui/contract/fail/trait-message-selector-overlap-3.rs:17:1 + | +17 | #[ink::contract] + | ^^^^^^^^^^^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::message1Output` + | + = note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate: + - impl ImpliesReturn for Execution; + - impl ImpliesReturn<()> for ink::ink_env::call::CallBuilder, Set>, Set<()>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for ink::ink_env::call::CallBuilder, Set>, Set>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for T; + = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` +note: required by a bound in `TraitDefinition1::message1Output` + --> tests/ui/contract/fail/trait-message-selector-overlap-3.rs:4:9 + | +2 | #[ink::trait_definition] + | ------------------------ required by a bound in this associated type +3 | pub trait TraitDefinition1 { +4 | / #[ink(message, selector = 42)] +5 | | fn message1(&self); + | |___________________________^ required by this bound in `TraitDefinition1::message1Output` + = note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0283]: type annotations needed + --> tests/ui/contract/fail/trait-message-selector-overlap-3.rs:17:1 + | +17 | #[ink::contract] + | ^^^^^^^^^^^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::message2Output` + | + = note: multiple `impl`s satisfying `_: ImpliesReturn<()>` found in the `ink` crate: + - impl ImpliesReturn for Execution; + - impl ImpliesReturn<()> for ink::ink_env::call::CallBuilder, Set>, Set<()>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for ink::ink_env::call::CallBuilder, Set>, Set>> + where E: ink::ink_env::Environment; + - impl ImpliesReturn for T; + = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` +note: required by a bound in `TraitDefinition2::message2Output` + --> tests/ui/contract/fail/trait-message-selector-overlap-3.rs:12:9 + | +10 | #[ink::trait_definition] + | ------------------------ required by a bound in this associated type +11 | pub trait TraitDefinition2 { +12 | / #[ink(message, selector = 42)] +13 | | fn message2(&self); + | |___________________________^ required by this bound in `TraitDefinition2::message2Output` + = note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: this function depends on never type fallback being `()` + --> tests/ui/contract/fail/trait-message-selector-overlap-3.rs:25:5 + | +25 | pub struct Contract {} + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #123748 + = help: specify the types explicitly +note: in edition 2024, the requirement `!: WrapperTypeDecode` will fail + --> tests/ui/contract/fail/trait-message-selector-overlap-3.rs:36:9 + | +36 | fn message1(&self) {} + | ^^^^^^^^^^^^^^^^^^^^^ + = note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default diff --git a/crates/ink/tests/ui/storage_item/fail/collections_only_packed_1.stderr b/crates/ink/tests/ui/storage_item/fail/collections_only_packed_1.stderr index 75dbb12921c..61f3715be90 100644 --- a/crates/ink/tests/ui/storage_item/fail/collections_only_packed_1.stderr +++ b/crates/ink/tests/ui/storage_item/fail/collections_only_packed_1.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `Vec: ink::parity_scale_codec::Decode` is not satisfied +error[E0277]: the trait bound `Vec: Packed` is not satisfied --> tests/ui/storage_item/fail/collections_only_packed_1.rs:11:8 | 11 | a: Vec, - | ^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec` + | ^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec`, which is required by `Vec: AutoStorableHint>` | = help: the trait `ink::parity_scale_codec::Decode` is implemented for `Vec` = note: required for `Vec` to implement `Packed` @@ -13,7 +13,7 @@ error[E0277]: the trait bound `[NonPacked]: Encode` is not satisfied --> tests/ui/storage_item/fail/collections_only_packed_1.rs:11:8 | 11 | a: Vec, - | ^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]` + | ^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]`, which is required by `Vec: AutoStorableHint>` | = help: the following other types implement trait `Encode`: [T; N] @@ -27,7 +27,52 @@ error[E0277]: the trait bound `Vec: ink::parity_scale_codec::Decode` --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 | 10 | struct Contract { - | ^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec` + | ^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec`, which is required by `Contract: Sized` + | + = help: the trait `ink::parity_scale_codec::Decode` is implemented for `Vec` + = note: required for `Vec` to implement `Packed` + = note: required for `Vec` to implement `StorableHint<()>` + = note: required for `Vec` to implement `AutoStorableHint>` +note: required because it appears within the type `Contract` + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 + | +10 | struct Contract { + | ^^^^^^^^ +note: required by a bound in `ink_storage::ink_storage_traits::StorableHint::Type` + --> $WORKSPACE/crates/storage/traits/src/storage.rs + | + | type Type: Storable; + | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `StorableHint::Type` + +error[E0277]: the trait bound `[NonPacked]: Encode` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 + | +10 | struct Contract { + | ^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]`, which is required by `Contract: Sized` + | + = help: the following other types implement trait `Encode`: + [T; N] + [T] + = note: required for `Vec` to implement `Encode` + = note: required for `Vec` to implement `Packed` + = note: required for `Vec` to implement `StorableHint<()>` + = note: required for `Vec` to implement `AutoStorableHint>` +note: required because it appears within the type `Contract` + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 + | +10 | struct Contract { + | ^^^^^^^^ +note: required by a bound in `ink_storage::ink_storage_traits::StorableHint::Type` + --> $WORKSPACE/crates/storage/traits/src/storage.rs + | + | type Type: Storable; + | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `StorableHint::Type` + +error[E0277]: the trait bound `Vec: ink::parity_scale_codec::Decode` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 + | +10 | struct Contract { + | ^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec`, which is required by `Contract: Sized` | = help: the trait `ink::parity_scale_codec::Decode` is implemented for `Vec` = note: required for `Vec` to implement `Packed` @@ -48,7 +93,7 @@ error[E0277]: the trait bound `[NonPacked]: Encode` is not satisfied --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 | 10 | struct Contract { - | ^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]` + | ^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]`, which is required by `Contract: Sized` | = help: the following other types implement trait `Encode`: [T; N] @@ -72,7 +117,7 @@ error[E0277]: the trait bound `Vec: ink::parity_scale_codec::Decode` --> tests/ui/storage_item/fail/collections_only_packed_1.rs:9:1 | 9 | #[ink::storage_item] - | ^^^^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec` + | ^^^^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec`, which is required by `Contract: Sized` | = help: the trait `ink::parity_scale_codec::Decode` is implemented for `Vec` = note: required for `Vec` to implement `Packed` @@ -83,18 +128,18 @@ note: required because it appears within the type `Contract` | 10 | struct Contract { | ^^^^^^^^ -note: required by a bound in `Result` +note: required by an implicit `Sized` bound in `Result` --> $RUST/core/src/result.rs | | pub enum Result { - | ^ required by this bound in `Result` + | ^ required by the implicit `Sized` requirement on this type parameter in `Result` = note: this error originates in the derive macro `::ink::storage::traits::Storable` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `[NonPacked]: Encode` is not satisfied --> tests/ui/storage_item/fail/collections_only_packed_1.rs:9:1 | 9 | #[ink::storage_item] - | ^^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]`, which is required by `Contract: Sized` | = help: the following other types implement trait `Encode`: [T; N] @@ -108,39 +153,29 @@ note: required because it appears within the type `Contract` | 10 | struct Contract { | ^^^^^^^^ -note: required by a bound in `Result` +note: required by an implicit `Sized` bound in `Result` --> $RUST/core/src/result.rs | | pub enum Result { - | ^ required by this bound in `Result` + | ^ required by the implicit `Sized` requirement on this type parameter in `Result` = note: this error originates in the derive macro `::ink::storage::traits::Storable` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `Vec: ink::parity_scale_codec::Decode` is not satisfied - --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 +error[E0277]: the trait bound `Vec: Packed` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:11:5 | -10 | struct Contract { - | ^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec` +11 | a: Vec, + | ^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec`, which is required by `Vec: AutoStorableHint>` | = help: the trait `ink::parity_scale_codec::Decode` is implemented for `Vec` = note: required for `Vec` to implement `Packed` = note: required for `Vec` to implement `StorableHint<()>` = note: required for `Vec` to implement `AutoStorableHint>` -note: required because it appears within the type `Contract` - --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 - | -10 | struct Contract { - | ^^^^^^^^ -note: required by a bound in `ink_storage::ink_storage_traits::StorableHint::Type` - --> $WORKSPACE/crates/storage/traits/src/storage.rs - | - | type Type: Storable; - | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `StorableHint::Type` error[E0277]: the trait bound `[NonPacked]: Encode` is not satisfied - --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:11:5 | -10 | struct Contract { - | ^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]` +11 | a: Vec, + | ^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]`, which is required by `Vec: AutoStorableHint>` | = help: the following other types implement trait `Encode`: [T; N] @@ -149,13 +184,64 @@ error[E0277]: the trait bound `[NonPacked]: Encode` is not satisfied = note: required for `Vec` to implement `Packed` = note: required for `Vec` to implement `StorableHint<()>` = note: required for `Vec` to implement `AutoStorableHint>` -note: required because it appears within the type `Contract` - --> tests/ui/storage_item/fail/collections_only_packed_1.rs:10:8 + +error[E0277]: the trait bound `Vec: Packed` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:9:1 + | +9 | #[ink::storage_item] + | ^^^^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `Vec`, which is required by `Vec: AutoStorableHint>` + | + = help: the trait `ink::parity_scale_codec::Decode` is implemented for `Vec` + = note: required for `Vec` to implement `Packed` + = note: required for `Vec` to implement `StorableHint<()>` + = note: required for `Vec` to implement `AutoStorableHint>` + = note: this error originates in the derive macro `::ink::storage::traits::Storable` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `[NonPacked]: Encode` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:9:1 + | +9 | #[ink::storage_item] + | ^^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `[NonPacked]`, which is required by `Vec: AutoStorableHint>` + | + = help: the following other types implement trait `Encode`: + [T; N] + [T] + = note: required for `Vec` to implement `Encode` + = note: required for `Vec` to implement `Packed` + = note: required for `Vec` to implement `StorableHint<()>` + = note: required for `Vec` to implement `AutoStorableHint>` + = note: this error originates in the derive macro `::ink::storage::traits::Storable` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `NonPacked: WrapperTypeDecode` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:11:8 | -10 | struct Contract { - | ^^^^^^^^ -note: required by a bound in `ink_storage::ink_storage_traits::StorableHint::Type` - --> $WORKSPACE/crates/storage/traits/src/storage.rs +11 | a: Vec, + | ^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonPacked`, which is required by `Vec: StorageLayout` + | + = help: the following other types implement trait `WrapperTypeDecode`: + Arc + Box + Rc + = note: required for `NonPacked` to implement `ink::parity_scale_codec::Decode` + = note: required for `NonPacked` to implement `Packed` + = note: required for `Vec` to implement `StorageLayout` + +error[E0277]: the trait bound `NonPacked: WrapperTypeEncode` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_1.rs:11:8 | - | type Type: Storable; - | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `StorableHint::Type` +11 | a: Vec, + | ^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonPacked`, which is required by `Vec: StorageLayout` + | + = help: the following other types implement trait `WrapperTypeEncode`: + &T + &mut T + Arc + Box + Cow<'a, T> + Rc + String + Vec + ink::parity_scale_codec::Ref<'a, T, U> + = note: required for `NonPacked` to implement `Encode` + = note: required for `NonPacked` to implement `Packed` + = note: required for `Vec` to implement `StorageLayout` diff --git a/crates/ink/tests/ui/storage_item/fail/collections_only_packed_2.stderr b/crates/ink/tests/ui/storage_item/fail/collections_only_packed_2.stderr index 33c98c16deb..b0f4df3a1ce 100644 --- a/crates/ink/tests/ui/storage_item/fail/collections_only_packed_2.stderr +++ b/crates/ink/tests/ui/storage_item/fail/collections_only_packed_2.stderr @@ -1,30 +1,72 @@ -error[E0277]: the trait bound `BTreeMap: ink::parity_scale_codec::Decode` is not satisfied +error[E0277]: the trait bound `BTreeMap: Packed` is not satisfied --> tests/ui/storage_item/fail/collections_only_packed_2.rs:11:8 | 11 | a: BTreeMap, - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap`, which is required by `BTreeMap: AutoStorableHint>` | = help: the trait `ink::parity_scale_codec::Decode` is implemented for `BTreeMap` = note: required for `BTreeMap` to implement `Packed` = note: required for `BTreeMap` to implement `StorableHint<()>` = note: required for `BTreeMap` to implement `AutoStorableHint>` -error[E0277]: the trait bound `BTreeMap: Encode` is not satisfied +error[E0277]: the trait bound `BTreeMap: Packed` is not satisfied --> tests/ui/storage_item/fail/collections_only_packed_2.rs:11:8 | 11 | a: BTreeMap, - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap`, which is required by `BTreeMap: AutoStorableHint>` + | + = help: the trait `Encode` is implemented for `BTreeMap` + = note: required for `BTreeMap` to implement `Packed` + = note: required for `BTreeMap` to implement `StorableHint<()>` + = note: required for `BTreeMap` to implement `AutoStorableHint>` + +error[E0277]: the trait bound `BTreeMap: ink::parity_scale_codec::Decode` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 + | +10 | struct Contract { + | ^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap`, which is required by `Contract: Sized` + | + = help: the trait `ink::parity_scale_codec::Decode` is implemented for `BTreeMap` + = note: required for `BTreeMap` to implement `Packed` + = note: required for `BTreeMap` to implement `StorableHint<()>` + = note: required for `BTreeMap` to implement `AutoStorableHint>` +note: required because it appears within the type `Contract` + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 + | +10 | struct Contract { + | ^^^^^^^^ +note: required by a bound in `ink_storage::ink_storage_traits::StorableHint::Type` + --> $WORKSPACE/crates/storage/traits/src/storage.rs + | + | type Type: Storable; + | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `StorableHint::Type` + +error[E0277]: the trait bound `BTreeMap: Encode` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 + | +10 | struct Contract { + | ^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap`, which is required by `Contract: Sized` | = help: the trait `Encode` is implemented for `BTreeMap` = note: required for `BTreeMap` to implement `Packed` = note: required for `BTreeMap` to implement `StorableHint<()>` = note: required for `BTreeMap` to implement `AutoStorableHint>` +note: required because it appears within the type `Contract` + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 + | +10 | struct Contract { + | ^^^^^^^^ +note: required by a bound in `ink_storage::ink_storage_traits::StorableHint::Type` + --> $WORKSPACE/crates/storage/traits/src/storage.rs + | + | type Type: Storable; + | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `StorableHint::Type` error[E0277]: the trait bound `BTreeMap: ink::parity_scale_codec::Decode` is not satisfied --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 | 10 | struct Contract { - | ^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap` + | ^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap`, which is required by `Contract: Sized` | = help: the trait `ink::parity_scale_codec::Decode` is implemented for `BTreeMap` = note: required for `BTreeMap` to implement `Packed` @@ -45,7 +87,7 @@ error[E0277]: the trait bound `BTreeMap: Encode` is not satisfi --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 | 10 | struct Contract { - | ^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap` + | ^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap`, which is required by `Contract: Sized` | = help: the trait `Encode` is implemented for `BTreeMap` = note: required for `BTreeMap` to implement `Packed` @@ -66,7 +108,7 @@ error[E0277]: the trait bound `BTreeMap: ink::parity_scale_code --> tests/ui/storage_item/fail/collections_only_packed_2.rs:9:1 | 9 | #[ink::storage_item] - | ^^^^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap` + | ^^^^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap`, which is required by `Contract: Sized` | = help: the trait `ink::parity_scale_codec::Decode` is implemented for `BTreeMap` = note: required for `BTreeMap` to implement `Packed` @@ -77,18 +119,18 @@ note: required because it appears within the type `Contract` | 10 | struct Contract { | ^^^^^^^^ -note: required by a bound in `Result` +note: required by an implicit `Sized` bound in `Result` --> $RUST/core/src/result.rs | | pub enum Result { - | ^ required by this bound in `Result` + | ^ required by the implicit `Sized` requirement on this type parameter in `Result` = note: this error originates in the derive macro `::ink::storage::traits::Storable` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `BTreeMap: Encode` is not satisfied --> tests/ui/storage_item/fail/collections_only_packed_2.rs:9:1 | 9 | #[ink::storage_item] - | ^^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap`, which is required by `Contract: Sized` | = help: the trait `Encode` is implemented for `BTreeMap` = note: required for `BTreeMap` to implement `Packed` @@ -99,51 +141,89 @@ note: required because it appears within the type `Contract` | 10 | struct Contract { | ^^^^^^^^ -note: required by a bound in `Result` +note: required by an implicit `Sized` bound in `Result` --> $RUST/core/src/result.rs | | pub enum Result { - | ^ required by this bound in `Result` + | ^ required by the implicit `Sized` requirement on this type parameter in `Result` = note: this error originates in the derive macro `::ink::storage::traits::Storable` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `BTreeMap: ink::parity_scale_codec::Decode` is not satisfied - --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 +error[E0277]: the trait bound `BTreeMap: Packed` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:11:5 | -10 | struct Contract { - | ^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap` +11 | a: BTreeMap, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap`, which is required by `BTreeMap: AutoStorableHint>` | = help: the trait `ink::parity_scale_codec::Decode` is implemented for `BTreeMap` = note: required for `BTreeMap` to implement `Packed` = note: required for `BTreeMap` to implement `StorableHint<()>` = note: required for `BTreeMap` to implement `AutoStorableHint>` -note: required because it appears within the type `Contract` - --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 - | -10 | struct Contract { - | ^^^^^^^^ -note: required by a bound in `ink_storage::ink_storage_traits::StorableHint::Type` - --> $WORKSPACE/crates/storage/traits/src/storage.rs - | - | type Type: Storable; - | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `StorableHint::Type` -error[E0277]: the trait bound `BTreeMap: Encode` is not satisfied - --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 +error[E0277]: the trait bound `BTreeMap: Packed` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:11:5 | -10 | struct Contract { - | ^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap` +11 | a: BTreeMap, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap`, which is required by `BTreeMap: AutoStorableHint>` | = help: the trait `Encode` is implemented for `BTreeMap` = note: required for `BTreeMap` to implement `Packed` = note: required for `BTreeMap` to implement `StorableHint<()>` = note: required for `BTreeMap` to implement `AutoStorableHint>` -note: required because it appears within the type `Contract` - --> tests/ui/storage_item/fail/collections_only_packed_2.rs:10:8 + +error[E0277]: the trait bound `BTreeMap: Packed` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:9:1 + | +9 | #[ink::storage_item] + | ^^^^^^^^^^^^^^^^^^^^ the trait `ink::parity_scale_codec::Decode` is not implemented for `BTreeMap`, which is required by `BTreeMap: AutoStorableHint>` + | + = help: the trait `ink::parity_scale_codec::Decode` is implemented for `BTreeMap` + = note: required for `BTreeMap` to implement `Packed` + = note: required for `BTreeMap` to implement `StorableHint<()>` + = note: required for `BTreeMap` to implement `AutoStorableHint>` + = note: this error originates in the derive macro `::ink::storage::traits::Storable` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `BTreeMap: Packed` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:9:1 + | +9 | #[ink::storage_item] + | ^^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `BTreeMap`, which is required by `BTreeMap: AutoStorableHint>` + | + = help: the trait `Encode` is implemented for `BTreeMap` + = note: required for `BTreeMap` to implement `Packed` + = note: required for `BTreeMap` to implement `StorableHint<()>` + = note: required for `BTreeMap` to implement `AutoStorableHint>` + = note: this error originates in the derive macro `::ink::storage::traits::Storable` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `NonPacked: WrapperTypeDecode` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:11:8 | -10 | struct Contract { - | ^^^^^^^^ -note: required by a bound in `ink_storage::ink_storage_traits::StorableHint::Type` - --> $WORKSPACE/crates/storage/traits/src/storage.rs +11 | a: BTreeMap, + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonPacked`, which is required by `BTreeMap: StorageLayout` + | + = help: the following other types implement trait `WrapperTypeDecode`: + Arc + Box + Rc + = note: required for `NonPacked` to implement `ink::parity_scale_codec::Decode` + = note: required for `NonPacked` to implement `Packed` + = note: required for `BTreeMap` to implement `StorageLayout` + +error[E0277]: the trait bound `NonPacked: WrapperTypeEncode` is not satisfied + --> tests/ui/storage_item/fail/collections_only_packed_2.rs:11:8 | - | type Type: Storable; - | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `StorableHint::Type` +11 | a: BTreeMap, + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonPacked`, which is required by `BTreeMap: StorageLayout` + | + = help: the following other types implement trait `WrapperTypeEncode`: + &T + &mut T + Arc + Box + Cow<'a, T> + Rc + String + Vec + ink::parity_scale_codec::Ref<'a, T, U> + = note: required for `NonPacked` to implement `Encode` + = note: required for `NonPacked` to implement `Packed` + = note: required for `BTreeMap` to implement `StorageLayout` diff --git a/crates/ink/tests/ui/storage_item/fail/packed_is_not_derived_automatically.stderr b/crates/ink/tests/ui/storage_item/fail/packed_is_not_derived_automatically.stderr index 4863fb334bc..ec6854506f2 100644 --- a/crates/ink/tests/ui/storage_item/fail/packed_is_not_derived_automatically.stderr +++ b/crates/ink/tests/ui/storage_item/fail/packed_is_not_derived_automatically.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `NonPacked: WrapperTypeDecode` is not satisfied +error[E0277]: the trait bound `NonPacked: Packed` is not satisfied --> tests/ui/storage_item/fail/packed_is_not_derived_automatically.rs:15:30 | 15 | let _ = consume_packed::(); - | ^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonPacked` + | ^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonPacked`, which is required by `NonPacked: Packed` | = help: the following other types implement trait `WrapperTypeDecode`: + Arc Box Rc - Arc = note: required for `NonPacked` to implement `ink::parity_scale_codec::Decode` = note: required for `NonPacked` to implement `Packed` note: required by a bound in `consume_packed` @@ -16,22 +16,22 @@ note: required by a bound in `consume_packed` 12 | fn consume_packed() {} | ^^^^^^ required by this bound in `consume_packed` -error[E0277]: the trait bound `NonPacked: WrapperTypeEncode` is not satisfied +error[E0277]: the trait bound `NonPacked: Packed` is not satisfied --> tests/ui/storage_item/fail/packed_is_not_derived_automatically.rs:15:30 | 15 | let _ = consume_packed::(); - | ^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonPacked` + | ^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonPacked`, which is required by `NonPacked: Packed` | = help: the following other types implement trait `WrapperTypeEncode`: + &T + &mut T + Arc Box Cow<'a, T> - ink::parity_scale_codec::Ref<'a, T, U> Rc - Arc - Vec String - &T - &mut T + Vec + ink::parity_scale_codec::Ref<'a, T, U> = note: required for `NonPacked` to implement `Encode` = note: required for `NonPacked` to implement `Packed` note: required by a bound in `consume_packed` diff --git a/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr b/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr index feea5916fb7..59edb180856 100644 --- a/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr +++ b/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr @@ -2,12 +2,12 @@ error[E0277]: the trait bound `NonCodec: WrapperTypeDecode` is not satisfied --> tests/ui/trait_def/fail/message_input_non_codec.rs:6:23 | 6 | fn message(&self, input: NonCodec); - | ^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodec` + | ^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodec`, which is required by `NonCodec: ink::parity_scale_codec::Decode` | = help: the following other types implement trait `WrapperTypeDecode`: + Arc Box Rc - Arc = note: required for `NonCodec` to implement `ink::parity_scale_codec::Decode` note: required by a bound in `DispatchInput` --> src/codegen/dispatch/type_check.rs @@ -18,26 +18,26 @@ note: required by a bound in `DispatchInput` | T: scale::Decode + 'static; | ^^^^^^^^^^^^^ required by this bound in `DispatchInput` -error[E0277]: the trait bound `NonCodec: WrapperTypeEncode` is not satisfied +error[E0277]: the trait bound `NonCodec: Encode` is not satisfied --> tests/ui/trait_def/fail/message_input_non_codec.rs:3:1 | 3 | #[ink::trait_definition] - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodec` + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodec`, which is required by `NonCodec: Encode` 4 | pub trait TraitDefinition { 5 | / #[ink(message)] 6 | | fn message(&self, input: NonCodec); | |_______________________________________- required by a bound introduced by this call | = help: the following other types implement trait `WrapperTypeEncode`: + &T + &mut T + Arc Box Cow<'a, T> - ink::parity_scale_codec::Ref<'a, T, U> Rc - Arc - Vec String - &T - &mut T + Vec + ink::parity_scale_codec::Ref<'a, T, U> = note: required for `NonCodec` to implement `Encode` note: required by a bound in `ExecutionInput::>::push_arg` --> $WORKSPACE/crates/env/src/call/execution.rs @@ -66,6 +66,10 @@ note: required by a bound in `Execution::::new` ... | pub fn new(input: ExecutionInput) -> Self { | --- required by a bound in this associated function +help: consider removing this method call, as the receiver has type `ExecutionInput>` and `ExecutionInput>: Encode` trivially holds + | +6 | fn message(&self, input: NonCodec); + | error[E0599]: the method `try_invoke` exists for struct `CallBuilder>, Set, ...>>>, ...>`, but its trait bounds were not satisfied --> tests/ui/trait_def/fail/message_input_non_codec.rs:5:5 @@ -73,12 +77,13 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder { | ----------------------------------- doesn't satisfy `_: Encode` | + = note: consider using `--verbose` to print the full type name to the console = note: the following trait bounds were not satisfied: `ArgumentList, ArgumentList>: Encode` diff --git a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr index d15348a8aaa..c6a8d0961b2 100644 --- a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr +++ b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr @@ -2,18 +2,18 @@ error[E0277]: the trait bound `NonCodec: WrapperTypeEncode` is not satisfied --> tests/ui/trait_def/fail/message_output_non_codec.rs:6:26 | 6 | fn message(&self) -> NonCodec; - | ^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodec` + | ^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodec`, which is required by `NonCodec: Encode` | = help: the following other types implement trait `WrapperTypeEncode`: + &T + &mut T + Arc Box Cow<'a, T> - ink::parity_scale_codec::Ref<'a, T, U> Rc - Arc - Vec String - &T - &mut T + Vec + ink::parity_scale_codec::Ref<'a, T, U> = note: required for `NonCodec` to implement `Encode` note: required by a bound in `DispatchOutput` --> src/codegen/dispatch/type_check.rs @@ -24,17 +24,17 @@ note: required by a bound in `DispatchOutput` | T: scale::Encode + 'static; | ^^^^^^^^^^^^^ required by this bound in `DispatchOutput` -error[E0277]: the trait bound `NonCodec: WrapperTypeDecode` is not satisfied +error[E0277]: the trait bound `NonCodec: ink::parity_scale_codec::Decode` is not satisfied --> tests/ui/trait_def/fail/message_output_non_codec.rs:5:5 | 5 | / #[ink(message)] 6 | | fn message(&self) -> NonCodec; - | |__________________________________^ the trait `WrapperTypeDecode` is not implemented for `NonCodec` + | |__________________________________^ the trait `WrapperTypeDecode` is not implemented for `NonCodec`, which is required by `NonCodec: ink::parity_scale_codec::Decode` | = help: the following other types implement trait `WrapperTypeDecode`: + Arc Box Rc - Arc = note: required for `NonCodec` to implement `ink::parity_scale_codec::Decode` note: required by a bound in `Execution::::new` --> $WORKSPACE/crates/env/src/call/execution.rs @@ -49,17 +49,18 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder tests/ui/trait_def/fail/message_output_non_codec.rs:5:5 | 1 | pub struct NonCodec; - | ------------------- doesn't satisfy `NonCodec: ink::parity_scale_codec::Decode` + | ------------------- doesn't satisfy `NonCodec: WrapperTypeDecode` or `NonCodec: ink::parity_scale_codec::Decode` ... 5 | #[ink(message)] | _____^ 6 | | fn message(&self) -> NonCodec; - | |__________________________________^ method cannot be called due to unsatisfied trait bounds + | |__________________________________^ | = note: the following trait bounds were not satisfied: - `NonCodec: ink::parity_scale_codec::Decode` -note: the trait `ink::parity_scale_codec::Decode` must be implemented + `NonCodec: WrapperTypeDecode` + which is required by `NonCodec: ink::parity_scale_codec::Decode` +note: the trait `WrapperTypeDecode` must be implemented --> $CARGO/parity-scale-codec-3.6.9/src/codec.rs | - | pub trait Decode: Sized { - | ^^^^^^^^^^^^^^^^^^^^^^^ + | pub trait WrapperTypeDecode: Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/primitives/src/key.rs b/crates/primitives/src/key.rs index d842f66a2ad..0262b194456 100644 --- a/crates/primitives/src/key.rs +++ b/crates/primitives/src/key.rs @@ -62,9 +62,9 @@ impl KeyComposer { /// /// 1. Compute the ASCII byte representation of `struct_name` and call it `S`. /// 1. If `variant_name` is not empty then computes the ASCII byte representation and - /// call it `V`. 1. Compute the ASCII byte representation of `field_name` and call - /// it `F`. 1. Concatenate (`S` and `F`) or (`S`, `V` and `F`) using `::` as - /// separator and call it `C`. 1. The `XXH32` hash of `C` is the storage key. + /// call it `V`. 1. Compute the ASCII byte representation of `field_name` and call + /// it `F`. 1. Concatenate (`S` and `F`) or (`S`, `V` and `F`) using `::` as + /// separator and call it `C`. 1. The `XXH32` hash of `C` is the storage key. /// /// # Note /// diff --git a/integration-tests/public/runtime-call-contract/sandbox-runtime/pallet-contract-caller/Cargo.toml b/integration-tests/public/runtime-call-contract/sandbox-runtime/pallet-contract-caller/Cargo.toml index 9726520d1e2..1a510f16c0a 100644 --- a/integration-tests/public/runtime-call-contract/sandbox-runtime/pallet-contract-caller/Cargo.toml +++ b/integration-tests/public/runtime-call-contract/sandbox-runtime/pallet-contract-caller/Cargo.toml @@ -34,3 +34,4 @@ std = [ "pallet-contracts/std", "ink/std" ] +try-runtime = [] diff --git a/linting/extra/Cargo.toml b/linting/extra/Cargo.toml index 8f1e0a9861c..44c735c5299 100644 --- a/linting/extra/Cargo.toml +++ b/linting/extra/Cargo.toml @@ -17,15 +17,17 @@ include = ["Cargo.toml", "*.rs", "LICENSE"] crate-type = ["cdylib"] [dependencies] -dylint_linting = "2.6.0" +dylint_linting = "3.2.0" if_chain = "1.0.2" log = "0.4.14" regex = "1.5.4" ink_linting_utils = { workspace = true } ink_env = { version = "=5.0.0", path = "../../crates/env", default-features = false } +#rustc_middle = {path = "/Users/michi/.rustup/toolchains/nightly-2024-09-05-aarch64-apple-darwin/lib/rustlib/rustc-src/rust/compiler/rustc_middle", optional = true} + [dev-dependencies] -dylint_testing = "2.6.0" +dylint_testing = "3.2.0" # The ink! dependencies used to build the `ui` tests and to compile the linting # library with `--default-features=std` (see the `features` section bellow). diff --git a/linting/extra/src/non_fallible_api.rs b/linting/extra/src/non_fallible_api.rs index 98549b02232..529b32ad272 100644 --- a/linting/extra/src/non_fallible_api.rs +++ b/linting/extra/src/non_fallible_api.rs @@ -55,7 +55,7 @@ use rustc_session::{ declare_lint, declare_lint_pass, }; -use rustc_type_ir::ty_kind::TyKind; +use rustc_type_ir::TyKind; declare_lint! { /// ## What it does @@ -200,8 +200,8 @@ impl<'a, 'tcx> APIUsageChecker<'a, 'tcx> { ty::Array(inner_ty, len_const) => { if_chain! { if self.is_statically_known(inner_ty); - if let ConstKind::Value(ty::ValTree::Leaf(elements_count)) = len_const.kind(); - if let Ok(elements_size) = elements_count.try_to_target_usize(self.cx.tcx); + if let ConstKind::Value(_, ty::ValTree::Leaf(elements_count)) = len_const.kind(); + let elements_size = elements_count.to_target_usize(self.cx.tcx); if elements_size < (ink_env::BUFFER_SIZE as u64); then { true } else { false } } @@ -231,7 +231,7 @@ impl<'a, 'tcx> APIUsageChecker<'a, 'tcx> { "using a non-fallible `{:?}::{}` with an argument that may not fit into the static buffer", receiver_ty, method_name, - ).as_str(), + ).as_str().to_owned(), |diag| { diag.span_suggestion( method_path.ident.span, @@ -277,7 +277,7 @@ impl<'a, 'tcx> Visitor<'tcx> for APIUsageChecker<'a, 'tcx> { walk_expr(self, e); } - fn visit_body(&mut self, body: &'tcx Body<'_>) { + fn visit_body(&mut self, body: &Body<'tcx>) { let old_maybe_typeck_results = self .maybe_typeck_results .replace(self.cx.tcx.typeck_body(body.id())); diff --git a/linting/extra/src/strict_balance_equality.rs b/linting/extra/src/strict_balance_equality.rs index 7a361b7a472..ad14f5a49c7 100644 --- a/linting/extra/src/strict_balance_equality.rs +++ b/linting/extra/src/strict_balance_equality.rs @@ -295,7 +295,6 @@ impl Visitor<'_> for TransferFunction<'_, '_> { // Direct comparison with the balance or propagation to a value tainted with // some operation with the balance Rvalue::BinaryOp(binop, box (lhs, rhs)) - | Rvalue::CheckedBinaryOp(binop, box (lhs, rhs)) if self.binop_strict_eq(binop) || self.binop_other(binop) => { if tainted_with_balance(self.state, lhs).is_some() diff --git a/linting/extra/ui/fail/non_fallible_api.stderr b/linting/extra/ui/fail/non_fallible_api.stderr index 319cdda6803..810e2c9136e 100644 --- a/linting/extra/ui/fail/non_fallible_api.stderr +++ b/linting/extra/ui/fail/non_fallible_api.stderr @@ -1,14 +1,13 @@ -error: using a non-fallible `Mapping::insert` with an argument that may not fit into the static buffer +warning: using a non-fallible `Mapping::insert` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:47:32 | LL | let _ = self.map_1.insert(a.clone(), &b); | ^^^^^^ help: consider using `try_insert` | = help: for further information visit https://use.ink/linter/rules/non_fallible_api - = note: `-D non-fallible-api` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(non_fallible_api)]` + = note: `#[warn(non_fallible_api)]` on by default -error: using a non-fallible `Mapping::get` with an argument that may not fit into the static buffer +warning: using a non-fallible `Mapping::get` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:48:32 | LL | let _ = self.map_1.get(a.clone()); @@ -16,7 +15,7 @@ LL | let _ = self.map_1.get(a.clone()); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `Mapping::take` with an argument that may not fit into the static buffer +warning: using a non-fallible `Mapping::take` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:49:32 | LL | let _ = self.map_1.take(a.clone()); @@ -24,7 +23,7 @@ LL | let _ = self.map_1.take(a.clone()); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `Mapping::insert` with an argument that may not fit into the static buffer +warning: using a non-fallible `Mapping::insert` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:52:32 | LL | let _ = self.map_2.insert(42, &v); @@ -32,7 +31,7 @@ LL | let _ = self.map_2.insert(42, &v); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `Lazy::get` with an argument that may not fit into the static buffer +warning: using a non-fallible `Lazy::get` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:55:33 | LL | let _ = self.lazy_1.get(); @@ -40,7 +39,7 @@ LL | let _ = self.lazy_1.get(); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `Lazy::set` with an argument that may not fit into the static buffer +warning: using a non-fallible `Lazy::set` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:56:25 | LL | self.lazy_1.set(&a); @@ -48,7 +47,7 @@ LL | self.lazy_1.set(&a); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `Lazy::set` with an argument that may not fit into the static buffer +warning: using a non-fallible `Lazy::set` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:57:25 | LL | self.lazy_2.set(&(a.clone(), a.clone())); @@ -56,7 +55,7 @@ LL | self.lazy_2.set(&(a.clone(), a.clone())); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `StorageVec::peek` with an argument that may not fit into the static buffer +warning: using a non-fallible `StorageVec::peek` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:60:32 | LL | let _ = self.vec_1.peek(); @@ -64,7 +63,7 @@ LL | let _ = self.vec_1.peek(); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `StorageVec::get` with an argument that may not fit into the static buffer +warning: using a non-fallible `StorageVec::get` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:61:32 | LL | let _ = self.vec_1.get(0); @@ -72,7 +71,7 @@ LL | let _ = self.vec_1.get(0); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `StorageVec::set` with an argument that may not fit into the static buffer +warning: using a non-fallible `StorageVec::set` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:62:24 | LL | self.vec_1.set(0, &a.clone()); @@ -80,7 +79,7 @@ LL | self.vec_1.set(0, &a.clone()); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `StorageVec::pop` with an argument that may not fit into the static buffer +warning: using a non-fallible `StorageVec::pop` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:63:32 | LL | let _ = self.vec_1.pop(); @@ -88,7 +87,7 @@ LL | let _ = self.vec_1.pop(); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: using a non-fallible `StorageVec::push` with an argument that may not fit into the static buffer +warning: using a non-fallible `StorageVec::push` with an argument that may not fit into the static buffer --> $DIR/non_fallible_api.rs:64:24 | LL | self.vec_1.push(&a.clone()); @@ -96,5 +95,5 @@ LL | self.vec_1.push(&a.clone()); | = help: for further information visit https://use.ink/linter/rules/non_fallible_api -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/linting/extra/ui/fail/primitive_topic.stderr b/linting/extra/ui/fail/primitive_topic.stderr index e4fdf200b43..23ad8ff54bd 100644 --- a/linting/extra/ui/fail/primitive_topic.stderr +++ b/linting/extra/ui/fail/primitive_topic.stderr @@ -1,14 +1,13 @@ -error: using `#[ink(topic)]` for a field with a primitive number type +warning: using `#[ink(topic)]` for a field with a primitive number type --> $DIR/primitive_topic.rs:13:9 | LL | value_1: u8, | ^^^^^^^^^^^ help: consider removing `#[ink(topic)]`: `value_1: u8` | = help: for further information visit https://use.ink/linter/rules/primitive_topic - = note: `-D primitive-topic` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(primitive_topic)]` + = note: `#[warn(primitive_topic)]` on by default -error: using `#[ink(topic)]` for a field with a primitive number type +warning: using `#[ink(topic)]` for a field with a primitive number type --> $DIR/primitive_topic.rs:16:9 | LL | value_2: Balance, @@ -16,7 +15,7 @@ LL | value_2: Balance, | = help: for further information visit https://use.ink/linter/rules/primitive_topic -error: using `#[ink(topic)]` for a field with a primitive number type +warning: using `#[ink(topic)]` for a field with a primitive number type --> $DIR/primitive_topic.rs:19:9 | LL | value_3: crate::TyAlias1, @@ -24,7 +23,7 @@ LL | value_3: crate::TyAlias1, | = help: for further information visit https://use.ink/linter/rules/primitive_topic -error: using `#[ink(topic)]` for a field with a primitive number type +warning: using `#[ink(topic)]` for a field with a primitive number type --> $DIR/primitive_topic.rs:22:9 | LL | value_4: crate::TyAlias2, @@ -32,5 +31,5 @@ LL | value_4: crate::TyAlias2, | = help: for further information visit https://use.ink/linter/rules/primitive_topic -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/linting/extra/ui/fail/strict_balance_equality.stderr b/linting/extra/ui/fail/strict_balance_equality.stderr index 9050525733f..979fa012162 100644 --- a/linting/extra/ui/fail/strict_balance_equality.stderr +++ b/linting/extra/ui/fail/strict_balance_equality.stderr @@ -1,14 +1,13 @@ -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:59:16 | LL | if self.env().balance() == 10 { /* ... */ } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality - = note: `-D strict-balance-equality` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(strict_balance_equality)]` + = note: `#[warn(strict_balance_equality)]` on by default -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:60:16 | LL | if value == 11 { /* ... */ } @@ -16,7 +15,7 @@ LL | if value == 11 { /* ... */ } | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:61:16 | LL | if self.env().balance() == threshold { /* ... */ } @@ -24,7 +23,7 @@ LL | if self.env().balance() == threshold { /* ... */ } | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:64:16 | LL | if self.get_balance_1() == 10 { /* ... */ } @@ -32,7 +31,7 @@ LL | if self.get_balance_1() == 10 { /* ... */ } | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:65:16 | LL | if self.get_balance_2() == 10 { /* ... */ } @@ -40,15 +39,7 @@ LL | if self.get_balance_2() == 10 { /* ... */ } | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: dangerous strict balance equality - --> $DIR/strict_balance_equality.rs:66:16 - | -LL | if self.get_balance_3() == 10 { /* ... */ } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>` - | - = help: for further information visit https://use.ink/linter/rules/strict_balance_equality - -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:67:16 | LL | if self.get_balance_recursive(&10) == 10 { /* ... */ } @@ -56,7 +47,7 @@ LL | if self.get_balance_recursive(&10) == 10 { /* ... */ } | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:71:16 | LL | if self.cmp_balance_1(&10) { /* ... */ } @@ -64,7 +55,7 @@ LL | if self.cmp_balance_1(&10) { /* ... */ } | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:72:16 | LL | if self.cmp_balance_2(&self.env().balance(), &threshold) { /* ... */ } @@ -72,7 +63,7 @@ LL | if self.cmp_balance_2(&self.env().balance(), &threshold) { /* . | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:73:16 | LL | if self.cmp_balance_3(self.env().balance(), threshold) { /* ... */ } @@ -80,7 +71,7 @@ LL | if self.cmp_balance_3(self.env().balance(), threshold) { /* ... | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:78:16 | LL | if res_1 == 10 { /* ... */ } @@ -88,7 +79,7 @@ LL | if res_1 == 10 { /* ... */ } | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: dangerous strict balance equality +warning: dangerous strict balance equality --> $DIR/strict_balance_equality.rs:81:16 | LL | if res_2 == 10 { /* ... */ } @@ -96,5 +87,5 @@ LL | if res_2 == 10 { /* ... */ } | = help: for further information visit https://use.ink/linter/rules/strict_balance_equality -error: aborting due to 12 previous errors +warning: 11 warnings emitted diff --git a/linting/mandatory/Cargo.toml b/linting/mandatory/Cargo.toml index 325674f5c72..e6e7cb9e9d2 100644 --- a/linting/mandatory/Cargo.toml +++ b/linting/mandatory/Cargo.toml @@ -17,14 +17,14 @@ include = ["Cargo.toml", "*.rs", "LICENSE"] crate-type = ["cdylib"] [dependencies] -dylint_linting = "2.6.0" +dylint_linting = "3.2.0" if_chain = "1.0.2" log = "0.4.14" regex = "1.5.4" ink_linting_utils = { workspace = true } [dev-dependencies] -dylint_testing = "2.6.0" +dylint_testing = "3.2.0" # The ink! dependencies used to build the `ui` tests and to compile the linting # library with `--default-features=std` (see the `features` section bellow). diff --git a/linting/rust-toolchain.toml b/linting/rust-toolchain.toml index 52abcef67d0..49c342491c9 100644 --- a/linting/rust-toolchain.toml +++ b/linting/rust-toolchain.toml @@ -2,5 +2,5 @@ # https://github.com/trailofbits/dylint/blob/ef7210cb08aac920c18d2141604efe210029f2a2/internal/template/rust-toolchain [toolchain] -channel = "nightly-2024-02-08" +channel = "nightly-2024-09-05" components = ["llvm-tools-preview", "rustc-dev"] diff --git a/linting/utils/Cargo.toml b/linting/utils/Cargo.toml index 6cd892f1a04..d6e10bf9fb3 100644 --- a/linting/utils/Cargo.toml +++ b/linting/utils/Cargo.toml @@ -15,7 +15,7 @@ include = ["Cargo.toml", "*.rs", "LICENSE"] [dependencies] if_chain = "1.0.2" -parity_clippy_utils = { package = "clippy_utils", git = "https://github.com/rust-lang/rust-clippy", rev = "2ca6c8419432b18474516a3b62d6d1ea46b9df78" } +parity_clippy_utils = { package = "clippy_utils", git = "https://github.com/rust-lang/rust-clippy", rev = "a95afe2d0a2051d97b723b0b197393b7811bc4e4" } [package.metadata.rust-analyzer] rustc_private = true diff --git a/linting/utils/src/lib.rs b/linting/utils/src/lib.rs index 3b1bbe945db..40a86dbc5cc 100644 --- a/linting/utils/src/lib.rs +++ b/linting/utils/src/lib.rs @@ -47,10 +47,31 @@ use rustc_hir::{ use rustc_lint::LateContext; /// Returns `true` iff the ink storage attribute is defined for the given HIR +/// +/// # Developer Note +/// +/// The ink! 5.0.0 our code generation added the annotation +/// `#[cfg(not(feature = "__ink_dylint_Storage"))] to contracts. This +/// allowed dylint to identify the storage struct in a contract. +/// +/// Starting with Rust 1.81, `cargo` throws a warning for features that +/// are not declared in the `Cargo.toml` and also for not well-known +/// key-value pairs. +/// +/// We don't want to burden contract developers with putting features that +/// are just for internal use there. The only alternative we found is to +/// use an obscure `cfg` condition, that is highly unlikely to be ever +/// annotated in a contract by a developer. Hence, we decided to use +/// `#[cfg(not(target_vendor = "fortanix"))]`, as it seems unlikely that a +/// contract will ever be compiled for this target. +/// +/// We have to continue checking for the `__ink_dylint_Storage` attribute +/// here, as the linting will otherwise stop working for ink! 5.0.0 contracts. fn has_storage_attr(cx: &LateContext, hir: HirId) -> bool { - const INK_STORAGE: &str = "__ink_dylint_Storage"; + const INK_STORAGE_1: &str = "__ink_dylint_Storage"; + const INK_STORAGE_2: &str = "fortanix"; let attrs = format!("{:?}", cx.tcx.hir().attrs(hir)); - attrs.contains(INK_STORAGE) + attrs.contains(INK_STORAGE_1) || attrs.contains(INK_STORAGE_2) } /// Returns `ItemId` of the structure annotated with `#[ink(storage)]`