Skip to content

Commit 3959fc4

Browse files
committed
Run cargo clippy --fix --all --all-targets to perform some small cleanups
1 parent 354f7ff commit 3959fc4

File tree

35 files changed

+191
-178
lines changed

35 files changed

+191
-178
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ members = [
1313
"tests/test_webgl_stdweb",
1414
"khronos_api",
1515
]
16+
17+
[workspace.lints.clippy]
18+
uninlined_format_args = "deny"

gl/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ gl_generator = { version = "0.14.0", path = "../gl_generator" }
2121

2222
[dev-dependencies]
2323
glutin = "0.24"
24+
25+
[lints]
26+
workspace = true

gl/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::path::Path;
2121

2222
fn main() {
2323
let dest = env::var("OUT_DIR").unwrap();
24-
let mut file = File::create(&Path::new(&dest).join("bindings.rs")).unwrap();
24+
let mut file = File::create(Path::new(&dest).join("bindings.rs")).unwrap();
2525

2626
Registry::new(Api::Gl, (4, 6), Profile::Core, Fallbacks::All, [])
2727
.write_bindings(GlobalGenerator, &mut file)

gl/examples/basic.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ fn main() {
3333
use glutin::event_loop::ControlFlow;
3434
*control_flow = ControlFlow::Wait;
3535
match event {
36-
Event::LoopDestroyed => return,
37-
Event::WindowEvent { event, .. } => match event {
38-
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
39-
_ => (),
40-
},
36+
Event::LoopDestroyed => (),
37+
Event::WindowEvent { event, .. } => if event == WindowEvent::CloseRequested { *control_flow = ControlFlow::Exit },
4138
Event::RedrawRequested(_) => {
4239
unsafe {
4340
gl::ClearColor(0.3, 0.3, 0.3, 1.0);

gl/examples/triangle.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ use std::str;
2525
static VERTEX_DATA: [GLfloat; 6] = [0.0, 0.5, 0.5, -0.5, -0.5, -0.5];
2626

2727
// Shader sources
28-
static VS_SRC: &'static str = "
28+
static VS_SRC: &str = "
2929
#version 150
3030
in vec2 position;
3131
3232
void main() {
3333
gl_Position = vec4(position, 0.0, 1.0);
3434
}";
3535

36-
static FS_SRC: &'static str = "
36+
static FS_SRC: &str = "
3737
#version 150
3838
out vec4 out_color;
3939
@@ -168,20 +168,17 @@ fn main() {
168168
use glutin::event_loop::ControlFlow;
169169
*control_flow = ControlFlow::Wait;
170170
match event {
171-
Event::LoopDestroyed => return,
172-
Event::WindowEvent { event, .. } => match event {
173-
WindowEvent::CloseRequested => {
174-
// Cleanup
175-
unsafe {
176-
gl::DeleteProgram(program);
177-
gl::DeleteShader(fs);
178-
gl::DeleteShader(vs);
179-
gl::DeleteBuffers(1, &vbo);
180-
gl::DeleteVertexArrays(1, &vao);
181-
}
182-
*control_flow = ControlFlow::Exit
183-
},
184-
_ => (),
171+
Event::LoopDestroyed => (),
172+
Event::WindowEvent { event, .. } => if event == WindowEvent::CloseRequested {
173+
// Cleanup
174+
unsafe {
175+
gl::DeleteProgram(program);
176+
gl::DeleteShader(fs);
177+
gl::DeleteShader(vs);
178+
gl::DeleteBuffers(1, &vbo);
179+
gl::DeleteVertexArrays(1, &vao);
180+
}
181+
*control_flow = ControlFlow::Exit
185182
},
186183
Event::RedrawRequested(_) => {
187184
unsafe {

gl_generator/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ unstable_generator_utils = []
2626
khronos_api = { version = "3.1.0", path = "../khronos_api" }
2727
log = "0.4"
2828
xml-rs = "0.8"
29+
30+
[lints]
31+
workspace = true

gl_generator/generators/debug_struct_gen.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ where
215215
fallbacks = match registry.aliases.get(&cmd.proto.ident) {
216216
Some(fbs) => fbs
217217
.iter()
218-
.map(|name| format!("\"{}\"", super::gen_symbol_name(registry.api, &name)))
218+
.map(|name| format!("\"{}\"", super::gen_symbol_name(registry.api, name)))
219219
.collect::<Vec<_>>()
220220
.join(", "),
221-
None => format!(""),
221+
None => String::new(),
222222
},
223223
)?
224224
}
@@ -234,22 +234,18 @@ where
234234
let idents = super::gen_parameters(cmd, true, false);
235235
let typed_params = super::gen_parameters(cmd, false, true);
236236
let println = format!(
237-
"println!(\"[OpenGL] {}({})\" {});",
237+
"println!(\"[OpenGL] {}({})\");",
238238
cmd.proto.ident,
239-
(0..idents.len())
240-
.map(|_| "{:?}".to_string())
241-
.collect::<Vec<_>>()
242-
.join(", "),
243239
idents
244240
.iter()
245241
.zip(typed_params.iter())
246242
.map(|(name, ty)| if ty.contains("GLDEBUGPROC") {
247-
format!(", \"<callback>\"")
243+
"<callback>".to_string()
248244
} else {
249-
format!(", {}", name)
245+
format!("{{{name}:?}}")
250246
})
251247
.collect::<Vec<_>>()
252-
.concat()
248+
.join(", "),
253249
);
254250

255251
writeln!(dest,
@@ -271,12 +267,11 @@ where
271267
registry
272268
.cmds
273269
.iter()
274-
.find(|cmd| cmd.proto.ident == "GetError")
275-
.is_some() {
276-
format!(r#"match __gl_imports::mem::transmute::<_, extern "system" fn() -> u32>
277-
(self.GetError.f)() {{ 0 => (), r => println!("[OpenGL] ^ GL error triggered: {{}}", r) }}"#)
270+
.any(|cmd| cmd.proto.ident == "GetError") {
271+
r#"match __gl_imports::mem::transmute::<_, extern "system" fn() -> u32>
272+
(self.GetError.f)() { 0 => (), r => println!("[OpenGL] ^ GL error triggered: {r}") }"#.to_string()
278273
} else {
279-
format!("")
274+
String::new()
280275
})?
281276
}
282277

gl_generator/generators/global_gen.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,7 @@ where
247247
}}
248248
}}
249249
}}
250-
"##,
251-
fnname = fnname,
252-
fallbacks = fallbacks,
253-
symbol = symbol
250+
"##
254251
)?;
255252
}
256253

gl_generator/generators/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn gen_parameters(cmd: &Cmd, with_idents: bool, with_types: bool) -> Vec<Str
9898
} else if with_types {
9999
format!("{}", binding.ty)
100100
} else if with_idents {
101-
format!("{}", binding.ident)
101+
binding.ident.to_string()
102102
} else {
103103
panic!()
104104
}
@@ -111,9 +111,9 @@ pub fn gen_parameters(cmd: &Cmd, with_idents: bool, with_types: bool) -> Vec<Str
111111
/// Example results: `"glClear"`, `"wglCreateContext"`, etc.
112112
pub fn gen_symbol_name(api: Api, cmd: &str) -> String {
113113
match api {
114-
Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 | Api::Glsc2 => format!("gl{}", cmd),
115-
Api::Glx => format!("glX{}", cmd),
116-
Api::Wgl => format!("wgl{}", cmd),
117-
Api::Egl => format!("egl{}", cmd),
114+
Api::Gl | Api::GlCore | Api::Gles1 | Api::Gles2 | Api::Glsc2 => format!("gl{cmd}"),
115+
Api::Glx => format!("glX{cmd}"),
116+
Api::Wgl => format!("wgl{cmd}"),
117+
Api::Egl => format!("egl{cmd}"),
118118
}
119119
}

gl_generator/generators/struct_gen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ where
215215
fallbacks = match registry.aliases.get(&cmd.proto.ident) {
216216
Some(fbs) => fbs
217217
.iter()
218-
.map(|name| format!("\"{}\"", super::gen_symbol_name(registry.api, &name)))
218+
.map(|name| format!("\"{}\"", super::gen_symbol_name(registry.api, name)))
219219
.collect::<Vec<_>>()
220220
.join(", "),
221-
None => format!(""),
221+
None => String::new(),
222222
},
223223
)?
224224
}

0 commit comments

Comments
 (0)