Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
I
ink
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
parity
ink
Compare Revisions
a96f594d475f0e3261c68158075157339541747d...a778b9f318ccd0928d7a5666ad2e1821026e1de9
Source
a778b9f318ccd0928d7a5666ad2e1821026e1de9
Select Git revision
...
Target
a96f594d475f0e3261c68158075157339541747d
Select Git revision
Compare
Commits (4)
[lang2/macro] add ui test for storage-impl conflict
· 71f62058
Robin Freyler
authored
Nov 10, 2019
71f62058
[lang2/macro] implement check that ink! impls are on #[ink(storage)] structs
· 31e94586
Robin Freyler
authored
Nov 10, 2019
31e94586
[lang2/macro] fix some success tests
· aa918996
Robin Freyler
authored
Nov 10, 2019
aa918996
[lang2/macro] add expected output for failure UI test 16
· a778b9f3
Robin Freyler
authored
Nov 10, 2019
a778b9f3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
2 deletions
+54
-2
lang2/macro/src/ir/into_hir.rs
lang2/macro/src/ir/into_hir.rs
+9
-0
lang2/macro/tests/compile_tests.rs
lang2/macro/tests/compile_tests.rs
+1
-0
lang2/macro/tests/ui/fail/16-storage-impl-ident-conflict.rs
lang2/macro/tests/ui/fail/16-storage-impl-ident-conflict.rs
+37
-0
lang2/macro/tests/ui/fail/16-storage-impl-ident-conflict.stderr
...macro/tests/ui/fail/16-storage-impl-ident-conflict.stderr
+5
-0
lang2/macro/tests/ui/pass/03-incrementer-contract.rs
lang2/macro/tests/ui/pass/03-incrementer-contract.rs
+1
-1
lang2/macro/tests/ui/pass/04-erc20-contract.rs
lang2/macro/tests/ui/pass/04-erc20-contract.rs
+1
-1
No files found.
lang2/macro/src/ir/into_hir.rs
View file @
a778b9f3
...
@@ -665,6 +665,15 @@ fn split_items(
...
@@ -665,6 +665,15 @@ fn split_items(
}
}
}
}
});
});
let
storage_ident
=
&
storage
.ident
;
for
item_impl
in
&
impl_blocks
{
if
item_impl
.self_ty
!=
storage_ident
.to_string
()
{
bail!
(
item_impl
.self_ty
,
"ink! impl blocks need to be implemented for the #[ink(storage)] struct"
)
}
}
let
functions
=
impl_blocks
let
functions
=
impl_blocks
.into_iter
()
.into_iter
()
.map
(|
impl_block
|
impl_block
.functions
)
.map
(|
impl_block
|
impl_block
.functions
)
...
...
lang2/macro/tests/compile_tests.rs
View file @
a778b9f3
...
@@ -39,4 +39,5 @@ fn compile_tests() {
...
@@ -39,4 +39,5 @@ fn compile_tests() {
t
.compile_fail
(
"tests/ui/fail/13-abi-constructor.rs"
);
t
.compile_fail
(
"tests/ui/fail/13-abi-constructor.rs"
);
t
.compile_fail
(
"tests/ui/fail/14-missing-storage-struct.rs"
);
t
.compile_fail
(
"tests/ui/fail/14-missing-storage-struct.rs"
);
t
.compile_fail
(
"tests/ui/fail/15-multiple-storage-structs.rs"
);
t
.compile_fail
(
"tests/ui/fail/15-multiple-storage-structs.rs"
);
t
.compile_fail
(
"tests/ui/fail/16-storage-impl-ident-conflict.rs"
);
}
}
lang2/macro/tests/ui/fail/16-storage-impl-ident-conflict.rs
0 → 100644
View file @
a778b9f3
#![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
()
{}
lang2/macro/tests/ui/fail/16-storage-impl-ident-conflict.stderr
0 → 100644
View file @
a778b9f3
error: ink! impl blocks need to be implemented for the #[ink(storage)] struct
--> $DIR/16-storage-impl-ident-conflict.rs:28:10
|
28 | impl NonStorageStruct {
| ^^^^^^^^^^^^^^^^
lang2/macro/tests/ui/pass/03-incrementer-contract.rs
View file @
a778b9f3
...
@@ -18,7 +18,7 @@ mod incrementer {
...
@@ -18,7 +18,7 @@ mod incrementer {
by
:
i32
,
by
:
i32
,
}
}
impl
Flipp
er
{
impl
Increment
er
{
#[ink(constructor)]
#[ink(constructor)]
fn
new
(
&
mut
self
,
init_value
:
i32
)
{
fn
new
(
&
mut
self
,
init_value
:
i32
)
{
self
.value
.set
(
init_value
as
i64
);
self
.value
.set
(
init_value
as
i64
);
...
...
lang2/macro/tests/ui/pass/04-erc20-contract.rs
View file @
a778b9f3
...
@@ -32,7 +32,7 @@ mod erc20 {
...
@@ -32,7 +32,7 @@ mod erc20 {
amount
:
Balance
,
amount
:
Balance
,
}
}
impl
Flipper
{
impl
Erc20
{
#[ink(constructor)]
#[ink(constructor)]
fn
new
(
&
mut
self
,
initial_supply
:
Balance
)
{
fn
new
(
&
mut
self
,
initial_supply
:
Balance
)
{
let
caller
=
self
.env
()
.caller
();
let
caller
=
self
.env
()
.caller
();
...
...