Skip to content

Commit 2211600

Browse files
committed
Fix clippy warnings about variables in format! string
No behavioural changes intended. Example message: error: variables can be used directly in the `format!` string --> x11rb-protocol/src/errors.rs:111:17 | 111 | write!(f, "Failed to parse value '{}'", dpy) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args = note: `-D clippy::uninlined-format-args` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::uninlined_format_args)]` help: change this to | 111 - write!(f, "Failed to parse value '{}'", dpy) 111 + write!(f, "Failed to parse value '{dpy}'") | Signed-off-by: Uli Schlachter <[email protected]>
1 parent 07fe145 commit 2211600

File tree

15 files changed

+37
-39
lines changed

15 files changed

+37
-39
lines changed

generator/src/generator/requests_replies.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ fn generate_request_naming(out: &mut Output) {
148148
out.indented(|out| {
149149
outln!(out, "RequestInfo::Xproto(request) => request.into(),");
150150
outln!(out, "RequestInfo::KnownExt(ext_and_request) => ext_and_request.into(),");
151-
outln!(out, "RequestInfo::UnknownRequest(None, opcode) => alloc::format!(\"xproto::opcode {{}}\", opcode).into(),");
152-
outln!(out, "RequestInfo::UnknownRequest(Some(ext), opcode) => alloc::format!(\"{{}}::opcode {{}}\", ext, opcode).into(),");
151+
outln!(out, "RequestInfo::UnknownRequest(None, opcode) => alloc::format!(\"xproto::opcode {{opcode}}\").into(),");
152+
outln!(out, "RequestInfo::UnknownRequest(Some(ext), opcode) => alloc::format!(\"{{ext}}::opcode {{opcode}}\").into(),");
153153
outln!(out, "RequestInfo::UnknownExtension(major_opcode, minor_opcode) => match ext_name {{");
154154
out.indented(|out| {
155-
outln!(out, "None => alloc::format!(\"ext {{}}::opcode {{}}\", major_opcode, minor_opcode).into(),");
156-
outln!(out, "Some(ext_name) => alloc::format!(\"ext {{}}::opcode {{}}\", ext_name, minor_opcode).into(),");
155+
outln!(out, "None => alloc::format!(\"ext {{major_opcode}}::opcode {{minor_opcode}}\").into(),");
156+
outln!(out, "Some(ext_name) => alloc::format!(\"ext {{ext_name}}::opcode {{minor_opcode}}\").into(),");
157157
});
158158
outln!(out, "}}");
159159
});

x11rb-protocol/src/errors.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl fmt::Display for DisplayParsingError {
108108
)
109109
}
110110
DisplayParsingError::MalformedValue(dpy) => {
111-
write!(f, "Failed to parse value '{}'", dpy)
111+
write!(f, "Failed to parse value '{dpy}'")
112112
}
113113
DisplayParsingError::NotUnicode => {
114114
write!(f, "The value of $DISPLAY is not valid unicode")
@@ -181,8 +181,8 @@ impl fmt::Display for ConnectError {
181181
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
182182
fn display(f: &mut fmt::Formatter<'_>, prefix: &str, value: &[u8]) -> fmt::Result {
183183
match core::str::from_utf8(value).ok() {
184-
Some(value) => write!(f, "{}: '{}'", prefix, value),
185-
None => write!(f, "{}: {:?} [message is not utf8]", prefix, value),
184+
Some(value) => write!(f, "{prefix}: '{value}'"),
185+
None => write!(f, "{prefix}: {value:?} [message is not utf8]"),
186186
}
187187
}
188188
match self {
@@ -200,8 +200,7 @@ impl fmt::Display for ConnectError {
200200
}
201201
ConnectError::Incomplete { expected, received } => write!(
202202
f,
203-
"Not enough data received to complete the handshake. Expected {}, received {}",
204-
expected, received
203+
"Not enough data received to complete the handshake. Expected {expected}, received {received}"
205204
),
206205
}
207206
}

x11rb-protocol/src/parse_display/connect_instruction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(super) fn connect_addresses(p: &ParsedDisplay) -> impl Iterator<Item = Conne
3939
targets.push(ConnectAddress::Hostname(host, TCP_PORT_BASE + display));
4040
} else {
4141
if protocol.is_none() || protocol.as_deref() == Some("unix") {
42-
let file_name = format!("/tmp/.X11-unix/X{}", display);
42+
let file_name = format!("/tmp/.X11-unix/X{display}");
4343
targets.push(ConnectAddress::Socket(file_name));
4444
}
4545

x11rb-protocol/src/protocol/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,11 +1001,11 @@ pub fn get_request_name(
10011001
match info {
10021002
RequestInfo::Xproto(request) => request.into(),
10031003
RequestInfo::KnownExt(ext_and_request) => ext_and_request.into(),
1004-
RequestInfo::UnknownRequest(None, opcode) => alloc::format!("xproto::opcode {}", opcode).into(),
1005-
RequestInfo::UnknownRequest(Some(ext), opcode) => alloc::format!("{}::opcode {}", ext, opcode).into(),
1004+
RequestInfo::UnknownRequest(None, opcode) => alloc::format!("xproto::opcode {opcode}").into(),
1005+
RequestInfo::UnknownRequest(Some(ext), opcode) => alloc::format!("{ext}::opcode {opcode}").into(),
10061006
RequestInfo::UnknownExtension(major_opcode, minor_opcode) => match ext_name {
1007-
None => alloc::format!("ext {}::opcode {}", major_opcode, minor_opcode).into(),
1008-
Some(ext_name) => alloc::format!("ext {}::opcode {}", ext_name, minor_opcode).into(),
1007+
None => alloc::format!("ext {major_opcode}::opcode {minor_opcode}").into(),
1008+
Some(ext_name) => alloc::format!("ext {ext_name}::opcode {minor_opcode}").into(),
10091009
}
10101010
}
10111011
}

x11rb/examples/check_unchecked_requests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4949
// We can check for errors explicitly
5050
match conn.destroy_window(INVALID_WINDOW)?.check() {
5151
Err(ReplyError::X11Error(_)) => {}
52-
e => panic!("{:?} unexpected", e),
52+
e => panic!("{e:?} unexpected"),
5353
}
5454

5555
// We can silently ignore the error
@@ -71,7 +71,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
7171
let (event, seq2) = conn.wait_for_event_with_sequence()?;
7272
match event {
7373
Event::Error(_) => {}
74-
event => panic!("Unexpectedly got {:?} instead of an X11 error", event),
74+
event => panic!("Unexpectedly got {event:?} instead of an X11 error"),
7575
}
7676
assert_eq!(seq, seq2);
7777
}

x11rb/examples/hypnomoire.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ where
254254
return Ok(());
255255
}
256256
Event::Error(err) => {
257-
eprintln!("Got an X11 error: {:?}", err);
257+
eprintln!("Got an X11 error: {err:?}");
258258
}
259259
_ => {}
260260
}

x11rb/examples/integration_test_util/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ mod util {
3939
);
4040

4141
if let Err(err) = conn.send_event(false, window, EventMask::NO_EVENT, event) {
42-
eprintln!("Error while sending event: {:?}", err);
42+
eprintln!("Error while sending event: {err:?}");
4343
}
4444
if let Err(err) = conn.send_event(
4545
false,
4646
window,
4747
EventMask::SUBSTRUCTURE_REDIRECT,
4848
event,
4949
) {
50-
eprintln!("Error while sending event: {:?}", err);
50+
eprintln!("Error while sending event: {err:?}");
5151
}
5252
conn.flush().unwrap();
5353
});

x11rb/examples/simple_window_manager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'a, C: Connection> WmState<'a, C> {
122122
win: Window,
123123
geom: &GetGeometryReply,
124124
) -> Result<(), ReplyOrIdError> {
125-
println!("Managing window {:?}", win);
125+
println!("Managing window {win:?}");
126126
let screen = &self.conn.setup().roots[self.screen_num];
127127
assert!(self.find_window_by_id(win).is_none());
128128

@@ -263,7 +263,7 @@ impl<'a, C: Connection> WmState<'a, C> {
263263
}
264264
}
265265

266-
println!("Got event {:?}", event);
266+
println!("Got event {event:?}");
267267
if should_ignore {
268268
println!(" [ignored]");
269269
return Ok(());
@@ -306,7 +306,7 @@ impl<'a, C: Connection> WmState<'a, C> {
306306
let aux = ConfigureWindowAux::from_configure_request(&event)
307307
.sibling(None)
308308
.stack_mode(None);
309-
println!("Configure: {:?}", aux);
309+
println!("Configure: {aux:?}");
310310
self.conn.configure_window(event.window, &aux)?;
311311
Ok(())
312312
}

x11rb/examples/tutorial.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,15 @@ fn example1() -> Result<(), Box<dyn Error>> {
209209
let mut atoms = [Into::<u32>::into(AtomEnum::NONE); COUNT];
210210

211211
// Init names
212-
let names = (0..COUNT).map(|i| format!("NAME{}", i)).collect::<Vec<_>>();
212+
let names = (0..COUNT).map(|i| format!("NAME{i}")).collect::<Vec<_>>();
213213

214214
// Bad use
215215
let start = Instant::now();
216216
for i in 0..COUNT {
217217
atoms[i] = conn.intern_atom(false, names[i].as_bytes())?.reply()?.atom;
218218
}
219219
let diff = start.elapsed();
220-
println!("bad use time: {:?}", diff);
220+
println!("bad use time: {diff:?}");
221221

222222
// Good use
223223
let start = Instant::now();
@@ -231,7 +231,7 @@ fn example1() -> Result<(), Box<dyn Error>> {
231231
atoms[i] = atom?.reply()?.atom;
232232
}
233233
let diff2 = start.elapsed();
234-
println!("good use time: {:?}", diff2);
234+
println!("good use time: {diff2:?}");
235235
println!(
236236
"ratio: {:?}",
237237
diff.as_nanos() as f64 / diff2.as_nanos() as f64
@@ -1238,7 +1238,7 @@ pub struct RenamedKeyPressEvent {
12381238
// those which have been described above.
12391239

12401240
fn print_modifiers(mask: x11rb::protocol::xproto::KeyButMask) {
1241-
println!("Modifier mask: {:#?}", mask);
1241+
println!("Modifier mask: {mask:#?}");
12421242
}
12431243

12441244
fn example7() -> Result<(), Box<dyn Error>> {
@@ -1344,7 +1344,7 @@ fn example7() -> Result<(), Box<dyn Error>> {
13441344
}
13451345
_ => {
13461346
// Unknown event type, ignore it
1347-
println!("Unknown event: {:?}", event);
1347+
println!("Unknown event: {event:?}");
13481348
}
13491349
}
13501350
}
@@ -2670,7 +2670,7 @@ fn example_get_visual2<C: Connection>(conn: &C, screen_num: usize) {
26702670
for depth in &screen.allowed_depths {
26712671
for visualtype in &depth.visuals {
26722672
if visualtype.visual_id == screen.root_visual {
2673-
println!("Found: {:?}", visualtype);
2673+
println!("Found: {visualtype:?}");
26742674
}
26752675
}
26762676
}

x11rb/examples/xclock_utc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
231231
loop {
232232
poll_with_timeout(&poller, conn, Duration::from_millis(1_000))?;
233233
while let Some(event) = conn.poll_for_event()? {
234-
println!("{:?})", event);
234+
println!("{event:?})");
235235
match event {
236236
Event::ConfigureNotify(event) => {
237237
width = event.width;

0 commit comments

Comments
 (0)