misc clippy fixes from 1.60.0
This commit is contained in:
parent
dffab1c737
commit
7cd285ecbc
12 changed files with 30 additions and 45 deletions
|
@ -50,7 +50,6 @@ rustflags = [
|
|||
"-Wclippy::missing_enforced_import_renames",
|
||||
"-Wclippy::missing_errors_doc",
|
||||
"-Wclippy::missing_safety_doc",
|
||||
# "-Wclippy::mod_module_files", // Enable when we update MSRV
|
||||
"-Wclippy::mut_mut",
|
||||
"-Wclippy::mutex_integer",
|
||||
"-Wclippy::needless_borrow",
|
||||
|
|
|
@ -101,9 +101,7 @@ impl Default for InputState {
|
|||
impl InputState {
|
||||
#[must_use]
|
||||
pub fn begin_frame(mut self, new: RawInput) -> InputState {
|
||||
let time = new
|
||||
.time
|
||||
.unwrap_or_else(|| self.time + new.predicted_dt as f64);
|
||||
let time = new.time.unwrap_or(self.time + new.predicted_dt as f64);
|
||||
let unstable_dt = (time - self.time) as f32;
|
||||
let screen_rect = new.screen_rect.unwrap_or(self.screen_rect);
|
||||
self.create_touch_states_for_new_devices(&new.events);
|
||||
|
|
|
@ -772,32 +772,30 @@ impl Layout {
|
|||
let cursor = region.cursor;
|
||||
let next_pos = self.next_widget_position(region);
|
||||
|
||||
let align;
|
||||
|
||||
let l = 64.0;
|
||||
|
||||
match self.main_dir {
|
||||
let align = match self.main_dir {
|
||||
Direction::LeftToRight => {
|
||||
painter.line_segment([cursor.left_top(), cursor.left_bottom()], stroke);
|
||||
painter.arrow(next_pos, vec2(l, 0.0), stroke);
|
||||
align = Align2([Align::LEFT, self.vertical_align()]);
|
||||
Align2([Align::LEFT, self.vertical_align()])
|
||||
}
|
||||
Direction::RightToLeft => {
|
||||
painter.line_segment([cursor.right_top(), cursor.right_bottom()], stroke);
|
||||
painter.arrow(next_pos, vec2(-l, 0.0), stroke);
|
||||
align = Align2([Align::RIGHT, self.vertical_align()]);
|
||||
Align2([Align::RIGHT, self.vertical_align()])
|
||||
}
|
||||
Direction::TopDown => {
|
||||
painter.line_segment([cursor.left_top(), cursor.right_top()], stroke);
|
||||
painter.arrow(next_pos, vec2(0.0, l), stroke);
|
||||
align = Align2([self.horizontal_align(), Align::TOP]);
|
||||
Align2([self.horizontal_align(), Align::TOP])
|
||||
}
|
||||
Direction::BottomUp => {
|
||||
painter.line_segment([cursor.left_bottom(), cursor.right_bottom()], stroke);
|
||||
painter.arrow(next_pos, vec2(0.0, -l), stroke);
|
||||
align = Align2([self.horizontal_align(), Align::BOTTOM]);
|
||||
Align2([self.horizontal_align(), Align::BOTTOM])
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
painter.debug_text(next_pos, align, stroke.color, text);
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ impl MenuRootManager {
|
|||
) -> Option<InnerResponse<R>> {
|
||||
if let Some(root) = self.inner.as_mut() {
|
||||
let (menu_response, inner_response) = root.show(response, add_contents);
|
||||
if let MenuResponse::Close = menu_response {
|
||||
if MenuResponse::Close == menu_response {
|
||||
self.inner = None;
|
||||
}
|
||||
inner_response
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
/// ``` ignore
|
||||
/// password_ui(ui, &mut my_password);
|
||||
/// ```
|
||||
#[allow(clippy::ptr_arg)] // false positive
|
||||
pub fn password_ui(ui: &mut egui::Ui, password: &mut String) -> egui::Response {
|
||||
// This widget has its own state — show or hide password characters (`show_plaintext`).
|
||||
// In this case we use a simple `bool`, but you can also declare your own type.
|
||||
|
|
|
@ -41,6 +41,7 @@ impl Default for RunMode {
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct BackendPanel {
|
||||
|
@ -60,18 +61,6 @@ pub struct BackendPanel {
|
|||
egui_windows: EguiWindows,
|
||||
}
|
||||
|
||||
impl Default for BackendPanel {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
open: false,
|
||||
run_mode: Default::default(),
|
||||
pixels_per_point: Default::default(),
|
||||
frame_history: Default::default(),
|
||||
egui_windows: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BackendPanel {
|
||||
pub fn update(&mut self, ctx: &egui::Context, frame: &mut epi::Frame) {
|
||||
self.frame_history
|
||||
|
|
|
@ -133,7 +133,7 @@ impl<'a> Parser<'a> {
|
|||
self.s = rest;
|
||||
self.start_of_line = false;
|
||||
self.style.code = true;
|
||||
let rest_of_line = &self.s[..self.s.find('\n').unwrap_or_else(|| self.s.len())];
|
||||
let rest_of_line = &self.s[..self.s.find('\n').unwrap_or(self.s.len())];
|
||||
if let Some(end) = rest_of_line.find('`') {
|
||||
let item = Item::Text(self.style, &self.s[..end]);
|
||||
self.s = &self.s[end + 1..];
|
||||
|
@ -153,7 +153,7 @@ impl<'a> Parser<'a> {
|
|||
/// `<url>` or `[link](url)`
|
||||
fn url(&mut self) -> Option<Item<'a>> {
|
||||
if self.s.starts_with('<') {
|
||||
let this_line = &self.s[..self.s.find('\n').unwrap_or_else(|| self.s.len())];
|
||||
let this_line = &self.s[..self.s.find('\n').unwrap_or(self.s.len())];
|
||||
if let Some(url_end) = this_line.find('>') {
|
||||
let url = &self.s[1..url_end];
|
||||
self.s = &self.s[url_end + 1..];
|
||||
|
@ -164,7 +164,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
// [text](url)
|
||||
if self.s.starts_with('[') {
|
||||
let this_line = &self.s[..self.s.find('\n').unwrap_or_else(|| self.s.len())];
|
||||
let this_line = &self.s[..self.s.find('\n').unwrap_or(self.s.len())];
|
||||
if let Some(bracket_end) = this_line.find(']') {
|
||||
let text = &this_line[1..bracket_end];
|
||||
if this_line[bracket_end + 1..].starts_with('(') {
|
||||
|
@ -217,7 +217,7 @@ impl<'a> Iterator for Parser<'a> {
|
|||
if self.start_of_line {
|
||||
// leading space (indentation)
|
||||
if self.s.starts_with(' ') {
|
||||
let length = self.s.find(|c| c != ' ').unwrap_or_else(|| self.s.len());
|
||||
let length = self.s.find(|c| c != ' ').unwrap_or(self.s.len());
|
||||
self.s = &self.s[length..];
|
||||
self.start_of_line = true; // indentation doesn't count
|
||||
return Some(Item::Indentation(length));
|
||||
|
|
|
@ -404,7 +404,7 @@ impl Highlighter {
|
|||
|
||||
while !text.is_empty() {
|
||||
if text.starts_with("//") {
|
||||
let end = text.find('\n').unwrap_or_else(|| text.len());
|
||||
let end = text.find('\n').unwrap_or(text.len());
|
||||
job.append(&text[..end], 0.0, theme.formats[TokenType::Comment].clone());
|
||||
text = &text[end..];
|
||||
} else if text.starts_with('"') {
|
||||
|
@ -412,7 +412,7 @@ impl Highlighter {
|
|||
.find('"')
|
||||
.map(|i| i + 2)
|
||||
.or_else(|| text.find('\n'))
|
||||
.unwrap_or_else(|| text.len());
|
||||
.unwrap_or(text.len());
|
||||
job.append(
|
||||
&text[..end],
|
||||
0.0,
|
||||
|
|
|
@ -29,7 +29,9 @@ impl ShaderVersion {
|
|||
pub(crate) fn parse(glsl_ver: &str) -> Self {
|
||||
let start = glsl_ver.find(|c| char::is_ascii_digit(&c)).unwrap();
|
||||
let es = glsl_ver[..start].contains(" ES ");
|
||||
let ver = glsl_ver[start..].splitn(2, ' ').next().unwrap();
|
||||
let ver = glsl_ver[start..]
|
||||
.split_once(' ')
|
||||
.map_or(&glsl_ver[start..], |x| x.0);
|
||||
let [maj, min]: [u8; 2] = ver
|
||||
.splitn(3, '.')
|
||||
.take(2)
|
||||
|
|
|
@ -29,17 +29,16 @@ pub fn pos_from_touch_event(
|
|||
event: &web_sys::TouchEvent,
|
||||
touch_id_for_pos: &mut Option<egui::TouchId>,
|
||||
) -> egui::Pos2 {
|
||||
let touch_for_pos;
|
||||
if let Some(touch_id_for_pos) = touch_id_for_pos {
|
||||
let touch_for_pos = if let Some(touch_id_for_pos) = touch_id_for_pos {
|
||||
// search for the touch we previously used for the position
|
||||
// (unfortunately, `event.touches()` is not a rust collection):
|
||||
touch_for_pos = (0..event.touches().length())
|
||||
(0..event.touches().length())
|
||||
.into_iter()
|
||||
.map(|i| event.touches().get(i).unwrap())
|
||||
.find(|touch| egui::TouchId::from(touch.identifier()) == *touch_id_for_pos);
|
||||
.find(|touch| egui::TouchId::from(touch.identifier()) == *touch_id_for_pos)
|
||||
} else {
|
||||
touch_for_pos = None;
|
||||
}
|
||||
None
|
||||
};
|
||||
// Use the touch found above or pick the first, or return a default position if there is no
|
||||
// touch at all. (The latter is not expected as the current method is only called when there is
|
||||
// at least one touch.)
|
||||
|
|
|
@ -250,7 +250,9 @@ fn line_break(
|
|||
|
||||
if row_start_idx < paragraph.glyphs.len() {
|
||||
if non_empty_rows == job.wrap.max_rows {
|
||||
replace_last_glyph_with_overflow_character(fonts, job, out_rows);
|
||||
if let Some(last_row) = out_rows.last_mut() {
|
||||
replace_last_glyph_with_overflow_character(fonts, job, last_row);
|
||||
}
|
||||
} else {
|
||||
let glyphs: Vec<Glyph> = paragraph.glyphs[row_start_idx..]
|
||||
.iter()
|
||||
|
@ -277,18 +279,13 @@ fn line_break(
|
|||
fn replace_last_glyph_with_overflow_character(
|
||||
fonts: &mut FontsImpl,
|
||||
job: &LayoutJob,
|
||||
out_rows: &mut Vec<Row>,
|
||||
row: &mut Row,
|
||||
) {
|
||||
let overflow_character = match job.wrap.overflow_character {
|
||||
Some(c) => c,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let row = match out_rows.last_mut() {
|
||||
Some(r) => r,
|
||||
None => return,
|
||||
};
|
||||
|
||||
loop {
|
||||
let (prev_glyph, last_glyph) = match row.glyphs.as_mut_slice() {
|
||||
[.., prev, last] => (Some(prev), last),
|
||||
|
|
|
@ -65,3 +65,5 @@ cargo deny check
|
|||
|
||||
# what compiles slowly?
|
||||
# cargo llvm-lines --lib -p egui | head -20
|
||||
|
||||
echo "All checks passed."
|
||||
|
|
Loading…
Reference in a new issue