Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable let_underscore_untyped lint #5217

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ large_include_file = "warn"
large_stack_arrays = "warn"
large_stack_frames = "warn"
large_types_passed_by_value = "warn"
let_underscore_untyped = "warn"
let_unit_value = "warn"
linkedlist = "warn"
lossy_float_literal = "warn"
Expand Down Expand Up @@ -255,7 +256,6 @@ zero_sized_map_values = "warn"

# TODO(emilk): enable more of these lints:
iter_over_hash_type = "allow"
let_underscore_untyped = "allow"
missing_assert_message = "allow"
should_panic_without_expect = "allow"
too_many_lines = "allow"
Expand Down
4 changes: 2 additions & 2 deletions crates/ecolor/src/hex_color_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
/// If the literal string has the wrong format, the code does not compile.
///
/// ```compile_fail
/// let _ = ecolor::hex_color!("#abc");
/// _ = ecolor::hex_color!("#abc");
/// ```
///
/// ```compile_fail
/// let _ = ecolor::hex_color!("#20212x");
/// _ = ecolor::hex_color!("#20212x");
/// ```
///
/// The macro cannot be used in a `const` context.
Expand Down
2 changes: 1 addition & 1 deletion crates/eframe/src/web/web_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl WebRunner {
// We can paint now, so clear the animation frame.
// This drops the `closure` and allows another
// animation frame to be scheduled
let _ = runner_ref.frame.take();
_ = runner_ref.frame.take();
events::paint_and_schedule(&runner_ref)
}
});
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ pub enum WidgetType {
pub fn __run_test_ctx(mut run_ui: impl FnMut(&Context)) {
let ctx = Context::default();
ctx.set_fonts(FontDefinitions::empty()); // prevent fonts from being loaded (save CPU time)
let _ = ctx.run(Default::default(), |ctx| {
_ = ctx.run(Default::default(), |ctx| {
run_ui(ctx);
});
}
Expand All @@ -677,7 +677,7 @@ pub fn __run_test_ctx(mut run_ui: impl FnMut(&Context)) {
pub fn __run_test_ui(add_contents: impl Fn(&mut Ui)) {
let ctx = Context::default();
ctx.set_fonts(FontDefinitions::empty()); // prevent fonts from being loaded (save CPU time)
let _ = ctx.run(Default::default(), |ctx| {
_ = ctx.run(Default::default(), |ctx| {
crate::CentralPanel::default().show(ctx, |ui| {
add_contents(ui);
});
Expand Down
6 changes: 3 additions & 3 deletions crates/egui/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ pub trait BytesLoader {
/// Implementations may use this to perform work at the end of a frame,
/// such as evicting unused entries from a cache.
fn end_pass(&self, frame_index: usize) {
let _ = frame_index;
_ = frame_index;
}

/// If the loader caches any data, this should return the size of that cache.
Expand Down Expand Up @@ -370,7 +370,7 @@ pub trait ImageLoader {
/// Implementations may use this to perform work at the end of a pass,
/// such as evicting unused entries from a cache.
fn end_pass(&self, frame_index: usize) {
let _ = frame_index;
_ = frame_index;
}

/// If the loader caches any data, this should return the size of that cache.
Expand Down Expand Up @@ -508,7 +508,7 @@ pub trait TextureLoader {
/// Implementations may use this to perform work at the end of a pass,
/// such as evicting unused entries from a cache.
fn end_pass(&self, frame_index: usize) {
let _ = frame_index;
_ = frame_index;
}

/// If the loader caches any data, this should return the size of that cache.
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ impl Response {
});
#[cfg(not(feature = "accesskit"))]
{
let _ = id;
_ = id;
}

self
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ impl ViewportOutput {

self.parent = parent;
self.class = class;
let _ = self.builder.patch(builder); // we ignore the returned command, because `self.builder` will be the basis of a new patch
_ = self.builder.patch(builder); // we ignore the returned command, because `self.builder` will be the basis of a new patch
self.viewport_ui_cb = viewport_ui_cb;
self.commands.append(&mut commands);
self.repaint_delay = self.repaint_delay.min(repaint_delay);
Expand Down
6 changes: 3 additions & 3 deletions crates/egui/tests/accesskit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ fn multiple_disabled_widgets() {
let output = accesskit_output_single_egui_frame(|ctx| {
CentralPanel::default().show(ctx, |ui| {
ui.add_enabled_ui(false, |ui| {
let _ = ui.button("Button 1");
let _ = ui.button("Button 2");
let _ = ui.button("Button 3");
_ = ui.button("Button 1");
_ = ui.button("Button 2");
_ = ui.button("Button 3");
})
});
});
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {

{
let ctx = egui::Context::default();
let _ = ctx.run(RawInput::default(), |ctx| {
_ = ctx.run(RawInput::default(), |ctx| {
egui::CentralPanel::default().show(ctx, |ui| {
c.bench_function("label &str", |b| {
b.iter(|| {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn about_immediate_mode(ui: &mut egui::Ui) {
ui.horizontal_wrapped(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
ui.label("Immediate mode is a GUI paradigm that lets you create a GUI with less code and simpler control flow. For example, this is how you create a ");
let _ = ui.small_button("button");
_ = ui.small_button("button");
ui.label(" in egui:");
});

Expand Down
16 changes: 8 additions & 8 deletions crates/egui_demo_lib/src/demo/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,28 @@ impl ContextMenus {
if ui.button("Open…").clicked() {
ui.close_menu();
}
let _ = ui.button("Item");
_ = ui.button("Item");
});
ui.menu_button("SubMenu", |ui| {
if ui.button("Open…").clicked() {
ui.close_menu();
}
let _ = ui.button("Item");
_ = ui.button("Item");
});
let _ = ui.button("Item");
_ = ui.button("Item");
if ui.button("Open…").clicked() {
ui.close_menu();
}
});
ui.menu_button("SubMenu", |ui| {
let _ = ui.button("Item1");
let _ = ui.button("Item2");
let _ = ui.button("Item3");
let _ = ui.button("Item4");
_ = ui.button("Item1");
_ = ui.button("Item2");
_ = ui.button("Item3");
_ = ui.button("Item4");
if ui.button("Open…").clicked() {
ui.close_menu();
}
});
let _ = ui.button("Very long text for this item that should be wrapped");
_ = ui.button("Very long text for this item that should be wrapped");
}
}
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/misc_demo_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ fn label_ui(ui: &mut egui::Ui) {
);

ui.label("You can mix in other widgets into text, like");
let _ = ui.small_button("this button");
_ = ui.small_button("this button");
ui.label(".");

ui.label("The default font supports all latin and cyrillic characters (ИÅđ…), common math symbols (∫√∞²⅓…), and many emojis (💓🌟🖩…).")
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/tests/cursor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl crate::View for CursorTest {
ui.vertical_centered_justified(|ui| {
ui.heading("Hover to switch cursor icon:");
for &cursor_icon in &egui::CursorIcon::ALL {
let _ = ui
_ = ui
.button(format!("{cursor_icon:?}"))
.on_hover_cursor(cursor_icon);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_demo_lib/src/demo/tests/id_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ impl crate::View for IdTest {
(and if it is, the window will have a new layout, and the slider will end up somewhere else, and so aborting the interaction probably makes sense).");

ui.label("So these buttons have automatic Id:s, and therefore there is no name clash:");
let _ = ui.button("Button");
let _ = ui.button("Button");
_ = ui.button("Button");
_ = ui.button("Button");

ui.vertical_centered(|ui| {
ui.add(crate::egui_github_link_file!());
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/tests/layout_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@ fn demo_ui(ui: &mut Ui) {
let mut dummy = false;
ui.checkbox(&mut dummy, "checkbox");
ui.radio_value(&mut dummy, false, "radio");
let _ = ui.button("button");
_ = ui.button("button");
}
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn install_image_loaders(ctx: &egui::Context) {
))]
log::warn!("`install_image_loaders` was called, but no loaders are enabled");

let _ = ctx;
_ = ctx;
}

#[cfg(not(target_arch = "wasm32"))]
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders/ehttp_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl BytesLoader for EhttpLoader {
}

fn forget(&self, uri: &str) {
let _ = self.cache.lock().remove(uri);
_ = self.cache.lock().remove(uri);
}

fn forget_all(&self) {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders/file_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl BytesLoader for FileLoader {
}

fn forget(&self, uri: &str) {
let _ = self.cache.lock().remove(uri);
_ = self.cache.lock().remove(uri);
}

fn forget_all(&self) {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders/gif_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl ImageLoader for GifLoader {
}

fn forget(&self, uri: &str) {
let _ = self.cache.lock().remove(uri);
_ = self.cache.lock().remove(uri);
}

fn forget_all(&self) {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl ImageLoader for ImageCrateLoader {
}

fn forget(&self, uri: &str) {
let _ = self.cache.lock().remove(uri);
_ = self.cache.lock().remove(uri);
}

fn forget_all(&self) {
Expand Down
4 changes: 2 additions & 2 deletions crates/epaint/src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,13 @@ mod tests_rwlock {
let other_thread1 = {
let one = Arc::clone(&one);
std::thread::spawn(move || {
let _ = one.write();
_ = one.write();
})
};
let other_thread2 = {
let one = Arc::clone(&one);
std::thread::spawn(move || {
let _ = one.read();
_ = one.read();
})
};
std::thread::sleep(Duration::from_millis(200));
Expand Down
6 changes: 3 additions & 3 deletions examples/hello_world_par/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn new_worker(
let mut state = ThreadState::new(thread_nr);
while let Ok(ctx) = show_rc.recv() {
state.show(&ctx);
let _ = on_done_tx.send(());
_ = on_done_tx.send(());
}
})
.expect("failed to spawn thread");
Expand Down Expand Up @@ -124,11 +124,11 @@ impl eframe::App for MyApp {
});

for (_handle, show_tx) in &self.threads {
let _ = show_tx.send(ctx.clone());
_ = show_tx.send(ctx.clone());
}

for _ in 0..self.threads.len() {
let _ = self.on_done_rc.recv();
_ = self.on_done_rc.recv();
}
}
}
8 changes: 4 additions & 4 deletions tests/test_size_pass/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() -> eframe::Result {
);
ui.label("Hover for interactive tooltip").on_hover_ui(|ui| {
ui.label("This tooltip has a button:");
let _ = ui.button("Clicking me does nothing");
_ = ui.button("Clicking me does nothing");
});
});
});
Expand All @@ -64,9 +64,9 @@ fn main() -> eframe::Result {

ui.label("The menu should be as wide as the widest button");
ui.menu_button("Click for menu", |ui| {
let _ = ui.button("Narrow").clicked();
let _ = ui.button("Very wide text").clicked();
let _ = ui.button("Narrow").clicked();
_ = ui.button("Narrow").clicked();
_ = ui.button("Very wide text").clicked();
_ = ui.button("Narrow").clicked();
});

ui.label("Hover for tooltip").on_hover_ui(|ui| {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_viewports/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const DRAG_AND_DROP_TEST: bool = false;
fn main() {
env_logger::init(); // Use `RUST_LOG=debug` to see logs.

let _ = eframe::run_native(
_ = eframe::run_native(
"Viewports",
eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([450.0, 400.0]),
Expand Down
Loading