Reduce compiler warnings in rlp (#674)

This commit is contained in:
andri lim 2024-02-13 19:34:27 +07:00 committed by GitHub
parent 8ab060b19f
commit bb1ab544fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 5 deletions

View File

@ -393,7 +393,7 @@ proc readImpl(rlp: var Rlp, T: type[object|tuple],
template getUnderlyingType[T](_: Option[T]): untyped = T
template getUnderlyingType[T](_: Opt[T]): untyped = T
template op(RecordType, fieldName, field) =
template op(RecordType, fieldName, field) {.used.} =
type FieldType {.used.} = type field
when hasCustomPragmaFixed(RecordType, fieldName, rlpCustomSerialization):
field = rlp.read(result, FieldType)

View File

@ -11,7 +11,7 @@ template rlpCustomSerialization* {.pragma.}
## a reference to the object holding the field.
template enumerateRlpFields*[T](x: T, op: untyped) =
type RecordType = type x
type RecordType {.used.} = type x
for fieldName, field in fieldPairs(x):
when not hasCustomPragmaFixed(RecordType, fieldName, rlpIgnore):
op(RecordType, fieldName, field)
@ -21,7 +21,7 @@ proc rlpFieldsCount*(T: type): int =
proc helper: int =
var dummy: T
template countFields(RT, n, x) = inc result
template countFields(RT, n, x) {.used.} = inc result
enumerateRlpFields(dummy, countFields)
const res = helper()

View File

@ -173,7 +173,7 @@ proc hasOptionalFields(T: type): bool =
proc helper: bool =
var dummy: T
result = false
template detectOptionalField(RT, n, x) =
template detectOptionalField(RT, n, x) {.used.} =
when x is Option or x is Opt:
return true
enumerateRlpFields(dummy, detectOptionalField)
@ -286,7 +286,7 @@ proc appendRecordType*(self: var RlpWriter, obj: object|tuple, wrapInList = wrap
else:
self.startList(fieldsCount)
template op(RecordType, fieldName, field) =
template op(RecordType, fieldName, field) {.used.} =
when hasCustomPragmaFixed(RecordType, fieldName, rlpCustomSerialization):
append(self, obj, field)
elif (field is Option or field is Opt) and hasOptional: