16-storage-impl-ident-conflict.rs 883 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#![feature(proc_macro_hygiene)]

use ink_lang2 as ink;

#[ink::contract(version = "0.1.0")]
mod noop {
    // This test ensures that ink! impl blocks are always
    // implemented on the only storage struct definition.

    #[ink(storage)]
    struct StorageStruct {}

    // This ink! impl block is okay.
    impl StorageStruct {
        #[ink(constructor)]
        fn new1(&mut self) {}

        #[ink(message)]
        fn do_something1(&self) {}
    }

    // Missing the #[ink(storage)] attribute on purpose.
    struct NonStorageStruct {}

    // This ink! impl block is invalid in that it implement
    // the messages and constructors for a non-existing ink!
    // storage struct. We expect a failure here.
    impl NonStorageStruct {
        #[ink(constructor)]
        fn new2(&mut self) {}

        #[ink(message)]
        fn do_something2(&self) {}
    }
}

fn main() {}