Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
ink
Commits
fad25bd7
Unverified
Commit
fad25bd7
authored
Mar 27, 2019
by
Robin Freyler
Browse files
[chores] Fix clippy warnings
parent
1b07f4d6
Changes
13
Hide whitespace changes
Inline
Side-by-side
core/src/env/api.rs
View file @
fad25bd7
...
...
@@ -53,7 +53,7 @@ pub unsafe fn r#return<T>(value: T) -> !
where
T
:
parity_codec
::
Encode
,
{
ContractEnv
::
r
#
return
(
&
mut
&
value
.encode
()[
..
])
ContractEnv
::
r
#
return
(
&
value
.encode
()[
..
])
}
/// Stores the given value under the specified key in the contract storage.
...
...
core/src/storage/alloc/cc_alloc.rs
View file @
fad25bd7
...
...
@@ -78,8 +78,8 @@ impl AllocateUsing for CellChunkAlloc {
Self
{
cells
:
AllocateUsing
::
allocate_using
(
alloc
),
chunks
:
AllocateUsing
::
allocate_using
(
alloc
),
cells_off
:
alloc
.alloc
(
u32
::
max_value
()
as
u64
),
chunks_off
:
alloc
.alloc
(
u32
::
max_value
()
as
u64
),
cells_off
:
alloc
.alloc
(
u32
::
max_value
()
.into
()
),
chunks_off
:
alloc
.alloc
(
u32
::
max_value
()
.into
()
),
}
}
}
...
...
@@ -201,7 +201,7 @@ impl CellChunkAlloc {
impl
Allocate
for
CellChunkAlloc
{
/// Can only allocate sizes of up to `u32::MAX`.
fn
alloc
(
&
mut
self
,
size
:
u64
)
->
Key
{
assert!
(
size
<=
u32
::
max_value
as
u64
);
assert!
(
size
<=
u64
::
from
(
u32
::
max_value
())
);
if
size
==
0
{
log
::
warn!
(
target
:
CC_ALLOC_LOG_TARGET
,
...
...
core/src/storage/alloc/dyn_alloc.rs
View file @
fad25bd7
...
...
@@ -53,8 +53,8 @@ impl AllocateUsing for DynAlloc {
Self
{
free_cells
:
AllocateUsing
::
allocate_using
(
alloc
),
free_chunks
:
AllocateUsing
::
allocate_using
(
alloc
),
cells_origin
:
alloc
.alloc
(
u32
::
max_value
()
as
u64
),
chunks_origin
:
alloc
.alloc
(
u32
::
max_value
()
as
u64
),
cells_origin
:
alloc
.alloc
(
u32
::
max_value
()
.into
()
),
chunks_origin
:
alloc
.alloc
(
u32
::
max_value
()
.into
()
),
}
}
}
...
...
@@ -133,7 +133,7 @@ impl DynAlloc {
fn
dealloc_chunk
(
&
mut
self
,
key
:
Key
)
{
debug_assert!
(
key
>=
self
.chunks_origin
);
debug_assert!
(
key
<
self
.chunks_origin
+
((
1
<<
32
)
*
self
.free_chunks
.len
()
as
u64
)
key
<
self
.chunks_origin
+
((
1
<<
32
)
*
u64
::
from
(
self
.free_chunks
.len
()
)
)
);
let
position
=
self
.key_to_chunk_position
(
key
);
self
.free_chunks
.set
(
position
,
true
);
...
...
@@ -166,7 +166,7 @@ impl DynAlloc {
impl
Allocate
for
DynAlloc
{
/// Can only allocate sizes of up to `u32::MAX`.
fn
alloc
(
&
mut
self
,
size
:
u64
)
->
Key
{
assert!
(
size
<=
u32
::
max_value
as
u64
);
assert!
(
size
<=
u32
::
max_value
()
.into
()
);
assert!
(
size
!=
0
);
if
size
==
1
{
self
.alloc_cell
()
...
...
core/src/storage/chunk/raw_chunk.rs
View file @
fad25bd7
...
...
@@ -95,7 +95,7 @@ impl AllocateUsing for RawChunk {
where
A
:
Allocate
,
{
Self
::
new_unchecked
(
alloc
.alloc
(
u32
::
max_value
()
as
u64
))
Self
::
new_unchecked
(
alloc
.alloc
(
u32
::
max_value
()
.into
()
))
}
}
...
...
core/src/storage/collections/bitvec/pack.rs
View file @
fad25bd7
...
...
@@ -55,7 +55,7 @@ impl BitPack {
}
/// Returns the value of the n-th bit.
pub
fn
get
(
&
self
,
n
:
u32
)
->
bool
{
pub
fn
get
(
self
,
n
:
u32
)
->
bool
{
Self
::
validate_index
(
n
)
.map
(|
n
|
(
self
.bits
&
(
0x1
<<
(
Self
::
BITS
-
n
-
1
)))
!=
0
)
.unwrap
()
...
...
@@ -84,7 +84,7 @@ impl BitPack {
}
/// Returns the position of the first set bit if any.
pub
fn
first_set_position
(
&
self
)
->
Option
<
u32
>
{
pub
fn
first_set_position
(
self
)
->
Option
<
u32
>
{
if
self
.bits
==
0x0
{
return
None
}
...
...
core/src/storage/collections/bitvec/vec.rs
View file @
fad25bd7
...
...
@@ -172,7 +172,7 @@ impl BitVec {
/// Removes the last bit from the bit vector and returns it,
/// or `None` if the bit vector is empty.
pub
fn
pop
(
&
mut
self
)
->
Option
<
bool
>
{
if
self
.
len
()
==
0
{
if
self
.
is_empty
()
{
return
None
}
let
len
=
self
.len
();
...
...
@@ -306,7 +306,7 @@ impl<'a> Iterator for BlockIter<'a> {
; so there has to be a block here; qed"
,
);
self
.begin
+=
1
;
return
Some
(
next
)
Some
(
next
)
}
fn
size_hint
(
&
self
)
->
(
usize
,
Option
<
usize
>
)
{
...
...
@@ -359,7 +359,7 @@ impl<'a> Iterator for Iter<'a> {
}
let
next
=
self
.bitvec
.get
(
self
.begin
);
self
.begin
+=
1
;
return
next
next
}
fn
size_hint
(
&
self
)
->
(
usize
,
Option
<
usize
>
)
{
...
...
core/src/storage/collections/vec/impls.rs
View file @
fad25bd7
...
...
@@ -305,9 +305,7 @@ where
if
self
.is_empty
()
{
return
None
}
if
self
.within_bounds
(
n
)
.is_none
()
{
return
None
}
self
.within_bounds
(
n
)
?
;
let
popped
=
self
.pop
()
.expect
(
"[pdsl_core::Vec::swap_remove] Error:
\
expected `Some` value since vector is not empty"
,
...
...
lang/src/errors.rs
View file @
fad25bd7
...
...
@@ -54,7 +54,7 @@ impl From<SynError> for Errors {
impl
From
<
Vec
<
Errors
>>
for
Errors
{
fn
from
(
err
:
Vec
<
Errors
>
)
->
Errors
{
let
result
=
err
.into_iter
()
.flat_map
(|
v
|
v
.errors
)
.collect
::
<
Vec
<
_
>>
();
assert!
(
result
.
len
()
>
0
);
assert!
(
!
result
.
is_empty
()
);
Errors
{
errors
:
result
}
}
}
...
...
lang/src/gen.rs
View file @
fad25bd7
...
...
@@ -210,7 +210,7 @@ fn codegen_for_message_impls(tokens: &mut TokenStream, contract: &hir::Contract)
inputs_with_env
.push
(
ast
::
FnArg
::
Captured
(
custom_arg_captured
.into_arg_captured
(),
));
while
let
Some
(
input
)
=
inputs_iter
.next
()
{
for
input
in
inputs_iter
{
inputs_with_env
.push
(
input
.clone
())
}
inputs_with_env
...
...
@@ -317,7 +317,7 @@ fn codegen_for_messages(tokens: &mut TokenStream, contract: &hir::Contract) {
}
let
msg_selector
=
message
.selector
();
let
msg_id
=
syn
::
LitInt
::
new
(
msg_selector
as
u64
,
msg_selector
.into
()
,
syn
::
IntSuffix
::
None
,
Span
::
call_site
(),
);
...
...
lang/src/hir.rs
View file @
fad25bd7
...
...
@@ -122,7 +122,7 @@ impl Contract {
}
let
inputs
=
&
msg
.sig.decl.inputs
;
{
match
inputs
.first
()
.map
(
|
arg
|
arg
.
into_value
()
)
{
match
inputs
.first
()
.map
(
syn
::
punctuated
::
Pair
::
into_value
)
{
None
=>
{
bail!
(
msg
.sig.ident
,
...
...
lang/src/lib.rs
View file @
fad25bd7
...
...
@@ -65,7 +65,7 @@ pub(crate) fn contract_gen_impl2(
let
hir_contract
=
hir
::
Contract
::
from_ast
(
&
ast_contract
)
?
;
generate_api_description
(
&
hir_contract
)
?
;
let
tokens
=
gen
::
codegen
(
&
hir_contract
);
Ok
(
tokens
.into
()
)
Ok
(
tokens
)
}
#[cfg(feature
=
"generate-api-description"
)]
...
...
lang/src/parser.rs
View file @
fad25bd7
...
...
@@ -34,7 +34,7 @@ pub mod keywords {
}
pub
fn
parse_contract
(
token_stream
:
proc_macro2
::
TokenStream
)
->
Result
<
ast
::
Contract
>
{
syn
::
parse2
(
token_stream
)
.map_err
(
|
e
|
e
.
into
()
)
syn
::
parse2
(
token_stream
)
.map_err
(
Into
::
into
)
}
impl
Parse
for
ast
::
Contract
{
...
...
model/src/contract.rs
View file @
fad25bd7
...
...
@@ -415,7 +415,7 @@ where
/// and returns the resulting value back to the caller.
fn
call_with_and_return
(
&
mut
self
,
call_data
:
CallData
)
{
let
encoded_result
=
self
.call_with
(
call_data
);
if
encoded_result
.
len
()
>
0
{
if
!
encoded_result
.
is_empty
()
{
unsafe
{
self
.env.r
#
return
(
encoded_result
)
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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