Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
I
ink
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
parity
ink
Commits
1f081ff7
Unverified
Commit
1f081ff7
authored
Nov 10, 2019
by
Robin Freyler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[lang2/macro] improve diagnostics for missing a #[ink(storage)] struct
parent
4613943a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
15 deletions
+26
-15
lang2/macro/src/ir/into_hir.rs
lang2/macro/src/ir/into_hir.rs
+26
-15
No files found.
lang2/macro/src/ir/into_hir.rs
View file @
1f081ff7
...
...
@@ -23,7 +23,7 @@ use crate::{
use
core
::
convert
::
TryFrom
;
use
either
::
Either
;
use
itertools
::
Itertools
as
_
;
use
proc_macro2
::
Ident
;
use
proc_macro2
::
{
Span
,
Ident
}
;
use
std
::
collections
::
HashSet
;
use
syn
::{
parse
::{
...
...
@@ -616,7 +616,7 @@ impl TryFrom<syn::Item> for ir::Item {
///
/// # Erros
///
/// - When there is no storage struct.
/// - When there is no
t exactly one
storage struct.
/// - When a contract item is invalid.
fn
split_items
(
items
:
Vec
<
ir
::
InkItem
>
,
...
...
@@ -628,19 +628,30 @@ fn split_items(
other
=>
Either
::
Right
(
other
),
}
});
let
storage
=
if
storages
.len
()
!=
1
{
Err
(
storages
.iter
()
.map
(|
storage
|
format_err!
(
storage
.ident
,
"conflicting storage struct found"
))
.fold1
(|
mut
err1
,
err2
|
{
err1
.combine
(
err2
);
err1
})
.expect
(
"there must be at least 2 conflicting storages; qed"
))
}
else
{
Ok
(
storages
.pop
()
.expect
(
"there must be exactly one storage in `storages`"
))
let
storage
=
match
storages
.len
()
{
0
=>
{
Err
(
format_err_span!
(
Span
::
call_site
(),
"no #[ink(storage)] struct found but expected exactly 1"
))
}
1
=>
{
Ok
(
storages
.pop
()
.expect
(
"there must be exactly one storage in `storages`"
))
}
n
=>
{
Err
(
storages
.iter
()
.map
(|
storage
|
{
format_err!
(
storage
.ident
,
"{} conflicting storage struct found"
,
n
)
})
.fold1
(|
mut
err1
,
err2
|
{
err1
.combine
(
err2
);
err1
})
.expect
(
"there must be at least 2 conflicting storages; qed"
))
}
}
?
;
let
(
events
,
impl_blocks
):
(
Vec
<
ir
::
ItemEvent
>
,
Vec
<
ir
::
ItemImpl
>
)
=
non_storage_items
.into_iter
()
.partition_map
(|
item
|
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment