cln-rpc: Allow access to deprecated fields in conversions

This silences a compilation warning about accessing a deprecated
field. This was triggering on each build and we'll notice when they go
away, so why upset users with it?
This commit is contained in:
Christian Decker 2023-01-26 14:25:25 +01:00
parent 557cd183ac
commit 53b37ca1c1
2 changed files with 229 additions and 218 deletions

432
cln-grpc/src/convert.rs generated

File diff suppressed because it is too large Load diff

View file

@ -247,9 +247,17 @@ class GrpcConverterGenerator(IGenerator):
self.generate_composite(prefix, f)
pbname = self.to_camel_case(field.typename)
# If any of the field accesses would result in a deprecated
# warning we mark the construction here to allow deprecated
# fields being access.
has_deprecated = any([f.deprecated for f in field.fields])
deprecated = ",deprecated" if has_deprecated else ""
# And now we can convert the current field:
self.write(f"""\
#[allow(unused_variables,deprecated)]
#[allow(unused_variables{deprecated})]
impl From<{prefix}::{field.typename}> for pb::{pbname} {{
fn from(c: {prefix}::{field.typename}) -> Self {{
Self {{
@ -406,10 +414,13 @@ class GrpcUnconverterGenerator(GrpcConverterGenerator):
elif isinstance(f, CompositeField):
self.generate_composite(prefix, f)
has_deprecated = any([f.deprecated for f in field.fields])
deprecated = ",deprecated" if has_deprecated else ""
pbname = self.to_camel_case(field.typename)
# And now we can convert the current field:
self.write(f"""\
#[allow(unused_variables,deprecated)]
#[allow(unused_variables{deprecated})]
impl From<pb::{pbname}> for {prefix}::{field.typename} {{
fn from(c: pb::{pbname}) -> Self {{
Self {{