Skip to content

Commit ed3417c

Browse files
authored
Migrate varlink_generator to syn 2.0.x (rust-lang#104)
Since the varlink_generator doesn't make use of anything that broke after syn was updated to 2.0.x, all it took was changing the version in the Cargo.toml file.
2 parents 04129b7 + fc6e943 commit ed3417c

File tree

9 files changed

+35
-15
lines changed

9 files changed

+35
-15
lines changed

examples/more/src/org_example_more.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ impl From<&varlink::Reply> for ErrorKind {
120120
}
121121
}
122122
}
123+
#[allow(dead_code)]
123124
pub trait VarlinkCallError: varlink::CallTrait {
124125
fn reply_test_more_error(&mut self, r#reason: String) -> varlink::Result<()> {
125126
self.reply_struct(varlink::Reply::error(
@@ -151,6 +152,7 @@ impl varlink::VarlinkReply for Ping_Reply {}
151152
pub struct Ping_Args {
152153
pub r#ping: String,
153154
}
155+
#[allow(dead_code)]
154156
pub trait Call_Ping: VarlinkCallError {
155157
fn reply(&mut self, r#pong: String) -> varlink::Result<()> {
156158
self.reply_struct(Ping_Reply { r#pong }.into())
@@ -162,6 +164,7 @@ pub struct StopServing_Reply {}
162164
impl varlink::VarlinkReply for StopServing_Reply {}
163165
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
164166
pub struct StopServing_Args {}
167+
#[allow(dead_code)]
165168
pub trait Call_StopServing: VarlinkCallError {
166169
fn reply(&mut self) -> varlink::Result<()> {
167170
self.reply_struct(varlink::Reply::parameters(None))
@@ -177,12 +180,14 @@ impl varlink::VarlinkReply for TestMore_Reply {}
177180
pub struct TestMore_Args {
178181
pub r#n: i64,
179182
}
183+
#[allow(dead_code)]
180184
pub trait Call_TestMore: VarlinkCallError {
181185
fn reply(&mut self, r#state: State) -> varlink::Result<()> {
182186
self.reply_struct(TestMore_Reply { r#state }.into())
183187
}
184188
}
185189
impl<'a> Call_TestMore for varlink::Call<'a> {}
190+
#[allow(dead_code)]
186191
pub trait VarlinkInterface {
187192
fn ping(&self, call: &mut dyn Call_Ping, r#ping: String) -> varlink::Result<()>;
188193
fn stop_serving(&self, call: &mut dyn Call_StopServing) -> varlink::Result<()>;
@@ -195,6 +200,7 @@ pub trait VarlinkInterface {
195200
Ok(Vec::new())
196201
}
197202
}
203+
#[allow(dead_code)]
198204
pub trait VarlinkClientInterface {
199205
fn ping(&mut self, r#ping: String) -> varlink::MethodCall<Ping_Args, Ping_Reply, Error>;
200206
fn stop_serving(&mut self) -> varlink::MethodCall<StopServing_Args, StopServing_Reply, Error>;

examples/ping/src/org_example_ping.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ impl From<&varlink::Reply> for ErrorKind {
120120
}
121121
}
122122
}
123+
#[allow(dead_code)]
123124
pub trait VarlinkCallError: varlink::CallTrait {
124125
fn reply_ping_error(&mut self, r#parameter: i64) -> varlink::Result<()> {
125126
self.reply_struct(varlink::Reply::error(
@@ -145,6 +146,7 @@ impl varlink::VarlinkReply for Ping_Reply {}
145146
pub struct Ping_Args {
146147
pub r#ping: String,
147148
}
149+
#[allow(dead_code)]
148150
pub trait Call_Ping: VarlinkCallError {
149151
fn reply(&mut self, r#pong: String) -> varlink::Result<()> {
150152
self.reply_struct(Ping_Reply { r#pong }.into())
@@ -156,12 +158,14 @@ pub struct Upgrade_Reply {}
156158
impl varlink::VarlinkReply for Upgrade_Reply {}
157159
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
158160
pub struct Upgrade_Args {}
161+
#[allow(dead_code)]
159162
pub trait Call_Upgrade: VarlinkCallError {
160163
fn reply(&mut self) -> varlink::Result<()> {
161164
self.reply_struct(varlink::Reply::parameters(None))
162165
}
163166
}
164167
impl<'a> Call_Upgrade for varlink::Call<'a> {}
168+
#[allow(dead_code)]
165169
pub trait VarlinkInterface {
166170
fn ping(&self, call: &mut dyn Call_Ping, r#ping: String) -> varlink::Result<()>;
167171
fn upgrade(&self, call: &mut dyn Call_Upgrade) -> varlink::Result<()>;
@@ -173,6 +177,7 @@ pub trait VarlinkInterface {
173177
Ok(Vec::new())
174178
}
175179
}
180+
#[allow(dead_code)]
176181
pub trait VarlinkClientInterface {
177182
fn ping(&mut self, r#ping: String) -> varlink::MethodCall<Ping_Args, Ping_Reply, Error>;
178183
fn upgrade(&mut self) -> varlink::MethodCall<Upgrade_Args, Upgrade_Reply, Error>;

varlink-cli/src/proxy.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ where
8585
}
8686
};
8787
}
88-
last_iface = iface.clone();
88+
last_iface.clone_from(&iface);
8989
}
9090

9191
let mut stream = match varlink_connect(&address) {
@@ -220,10 +220,10 @@ where
220220
Ok(upgraded)
221221
}
222222

223-
pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<u64>
223+
pub fn copy<R, W>(reader: &mut R, writer: &mut W) -> io::Result<u64>
224224
where
225-
R: Read,
226-
W: Write,
225+
R: Read + ?Sized,
226+
W: Write + ?Sized,
227227
{
228228
use std::io::ErrorKind;
229229

varlink-cli/src/watchclose_epoll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ fn cvt<T: IsMinusOne>(t: T) -> crate::io::Result<T> {
9898

9999
fn max_len() -> usize {
100100
if cfg!(target_os = "macos") {
101-
<c_int>::max_value() as usize - 1
101+
<c_int>::MAX as usize - 1
102102
} else {
103-
<ssize_t>::max_value() as usize
103+
<ssize_t>::MAX as usize
104104
}
105105
}
106106

varlink/src/test.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn test_listen() -> Result<()> {
3838
assert_eq!(&info.version, "0.1");
3939
assert_eq!(&info.url, "http://varlink.org");
4040
assert_eq!(
41-
info.interfaces.get(0).unwrap().as_ref(),
41+
info.interfaces.first().unwrap().as_ref(),
4242
"org.varlink.service"
4343
);
4444
}
@@ -161,13 +161,14 @@ fn test_handle() -> Result<()> {
161161

162162
let mut buf = Vec::<u8>::new();
163163

164-
for mut i in vec![a, b, c] {
164+
for mut i in [a, b, c] {
165165
buf.append(&mut i);
166166

167-
match {
167+
let res = {
168168
let mut br = buf.as_slice();
169169
service.handle(&mut br, &mut w, None)?
170-
} {
170+
};
171+
match res {
171172
(_, Some(iface)) => {
172173
panic!("Unexpected handle return value {}", iface);
173174
}

varlink_generator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ varlink_parser = { version = "4.3", path = "../varlink_parser" }
2828
quote = "1.0.2"
2929
proc-macro2 = "1.0.6"
3030
getopts = "0.2.21"
31-
syn = "1.0.8"
31+
syn = "2.0"
3232
chainerror = "0.8.0"
3333

3434
[dev-dependencies]

varlink_generator/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ fn varlink_to_rust(idl: &IDL, options: &GeneratorOptions, tosource: bool) -> Res
378378
let field_types_1 = out_field_types.iter();
379379
if !t.output.elts.is_empty() {
380380
ts.extend(quote!(
381+
#[allow(dead_code)]
381382
pub trait #call_name: VarlinkCallError {
382383
fn reply(&mut self, #(#field_names_1: #field_types_1),*) -> varlink::Result<()> {
383384
self.reply_struct(#out_struct_name { #(#field_names_2),* }.into())
@@ -386,6 +387,7 @@ fn varlink_to_rust(idl: &IDL, options: &GeneratorOptions, tosource: bool) -> Res
386387
));
387388
} else {
388389
ts.extend(quote!(
390+
#[allow(dead_code)]
389391
pub trait #call_name: VarlinkCallError {
390392
fn reply(&mut self) -> varlink::Result<()> {
391393
self.reply_struct(varlink::Reply::parameters(None))
@@ -467,13 +469,16 @@ fn varlink_to_rust(idl: &IDL, options: &GeneratorOptions, tosource: bool) -> Res
467469
}
468470

469471
ts.extend(quote!(
472+
#[allow(dead_code)]
470473
pub trait VarlinkInterface {
471474
#server_method_decls
472475

473476
fn call_upgraded(&self, _call: &mut varlink::Call, _bufreader: &mut dyn BufRead) -> varlink::Result<Vec<u8>> {
474477
Ok(Vec::new())
475478
}
476479
}
480+
481+
#[allow(dead_code)]
477482
pub trait VarlinkClientInterface {
478483
#client_method_decls
479484
}
@@ -776,6 +781,7 @@ fn generate_error_code(
776781
}
777782
ts.extend(quote!(
778783
#error_structs_and_enums
784+
#[allow(dead_code)]
779785
pub trait VarlinkCallError: varlink::CallTrait {
780786
#funcs
781787
}
@@ -880,7 +886,7 @@ pub fn cargo_build<T: AsRef<Path> + ?Sized>(input_path: &T) {
880886
/// }
881887
/// ```
882888
///
883-
pub fn cargo_build_many<T: AsRef<Path> + ?Sized>(input_paths: &[T])
889+
pub fn cargo_build_many<T>(input_paths: &[T])
884890
where
885891
T: std::marker::Sized,
886892
T: AsRef<Path>,

varlink_generator/tests/org.example.complex.rs_out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ pub enum r#ErrorFoo_Args_bar {
147147
r#if,
148148
r#let,
149149
}
150+
#[allow(dead_code)]
150151
pub trait VarlinkCallError: varlink::CallTrait {
151152
fn reply_error_bar(&mut self) -> varlink::Result<()> {
152153
self.reply_struct(varlink::Reply::error("org.example.complex.ErrorBar", None))
@@ -256,6 +257,7 @@ pub struct Bar_Reply {}
256257
impl varlink::VarlinkReply for Bar_Reply {}
257258
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
258259
pub struct Bar_Args {}
260+
#[allow(dead_code)]
259261
pub trait Call_Bar: VarlinkCallError {
260262
fn reply(&mut self) -> varlink::Result<()> {
261263
self.reply_struct(varlink::Reply::parameters(None))
@@ -285,6 +287,7 @@ pub struct Foo_Args {
285287
pub r#foo: TypeFoo,
286288
pub r#interface: Interface,
287289
}
290+
#[allow(dead_code)]
288291
pub trait Call_Foo: VarlinkCallError {
289292
fn reply(
290293
&mut self,
@@ -303,6 +306,7 @@ pub trait Call_Foo: VarlinkCallError {
303306
}
304307
}
305308
impl<'a> Call_Foo for varlink::Call<'a> {}
309+
#[allow(dead_code)]
306310
pub trait VarlinkInterface {
307311
fn bar(&self, call: &mut dyn Call_Bar) -> varlink::Result<()>;
308312
fn foo(
@@ -320,6 +324,7 @@ pub trait VarlinkInterface {
320324
Ok(Vec::new())
321325
}
322326
}
327+
#[allow(dead_code)]
323328
pub trait VarlinkClientInterface {
324329
fn bar(&mut self) -> varlink::MethodCall<Bar_Args, Bar_Reply, Error>;
325330
fn foo(

varlink_parser/src/format.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,6 @@ impl<'a> FormatColored for IDL<'a> {
625625
if !t.doc.is_empty() {
626626
f += &t
627627
.doc
628-
.to_string()
629628
.split('\n')
630629
.map(|s| format!("{:indent$}{}", "", s.blue(), indent = indent))
631630
.collect::<Vec<String>>()
@@ -661,7 +660,6 @@ impl<'a> FormatColored for IDL<'a> {
661660
if !m.doc.is_empty() {
662661
f += &m
663662
.doc
664-
.to_string()
665663
.split('\n')
666664
.map(|s| format!("{:indent$}{}", "", s.blue(), indent = indent))
667665
.collect::<Vec<String>>()
@@ -726,7 +724,6 @@ impl<'a> FormatColored for IDL<'a> {
726724
if !t.doc.is_empty() {
727725
f += &t
728726
.doc
729-
.to_string()
730727
.split('\n')
731728
.map(|s| format!("{:indent$}{}", "", s.blue(), indent = indent))
732729
.collect::<Vec<String>>()

0 commit comments

Comments
 (0)