Skip to content

[jsonrpc-derive]: don't work on traits with anonymous params (rust vs rust2018 incompatibility) #510

Open
@niklasad1

Description

@niklasad1

If this is tried in legacy rust (not rust 2018)

#[rpc(server)]
pub trait Foo {
	/// RPC Metadata
	type Metadata;

	fn bar(&self, u64) -> Result<u64>;
}

You will end with a similar error as follows:

26 | #[rpc(server)]                                                                                                                                                                                         
   | ^^^^^^^^^^^^^^                                                                                                                                                                                         
                                                                                                                                                                                                            
error: expected `:`        

To fix it you can do:

#[rpc(server)]
pub trait Foo {
	/// RPC Metadata
	type Metadata;

	fn bar(&self, _: u64) -> Result<u64>;
}

// or
#[rpc(server)]
pub trait Foo {
	/// RPC Metadata
	type Metadata;

	fn bar(&self, b: u64) -> Result<u64>;
}

For further information, see https://rust-lang.github.io/rfcs/1685-deprecate-anonymous-parameters.html

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions