Skip to content

ViEditor: cleanup logging #474

ViEditor: cleanup logging

ViEditor: cleanup logging #474

GitHub Actions / clippy succeeded Dec 8, 2023 in 0s

clippy

16 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 16
Note 0
Help 0

Versions

  • rustc 1.74.0 (79e9716c9 2023-11-13)
  • cargo 1.74.0 (ecb9851af 2023-10-18)
  • clippy 0.1.74 (79e9716 2023-11-13)

Annotations

Check warning on line 226 in src/edit/mod.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

item in documentation is missing backticks

warning: item in documentation is missing backticks
   --> src/edit/mod.rs:226:56
    |
226 |     /// Insert text at specified cursor with specified attrs_list
    |                                                        ^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
note: the lint level is defined here
   --> src/lib.rs:84:9
    |
84  | #![warn(clippy::doc_markdown)]
    |         ^^^^^^^^^^^^^^^^^^^^
help: try
    |
226 |     /// Insert text at specified cursor with specified `attrs_list`
    |                                                        ~~~~~~~~~~~~

Check warning on line 1053 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function returning `Result` missing `# Errors` section

warning: docs for function returning `Result` missing `# Errors` section
    --> src/edit/vi.rs:1049:5
     |
1049 | /     pub fn load_text<P: AsRef<std::path::Path>>(
1050 | |         &mut self,
1051 | |         path: P,
1052 | |         attrs: crate::Attrs,
1053 | |     ) -> std::io::Result<()> {
     | |____________________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

Check warning on line 720 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/edit/vi.rs:702:33
    |
702 | / ...                   match text[..cursor.index]
703 | | ...                       .char_indices()
704 | | ...                       .filter_map(|(i, c)| {
705 | | ...                           if c == find_c {
...   |
719 | | ...                       None => {}
720 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
702 ~                                 if let Some(i) = text[..cursor.index]
703 +                                     .char_indices()
704 +                                     .filter_map(|(i, c)| {
705 +                                         if c == find_c {
706 +                                             let end = i + c.len_utf8();
707 +                                             if end < cursor.index {
708 +                                                 return Some(end);
709 +                                             }
710 +                                         }
711 +                                         None
712 +                                     })
713 +                                     .last() {
714 +                                     cursor.index = i;
715 +                                     editor.set_cursor(cursor);
716 +                                 }
    |

Check warning on line 693 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/edit/vi.rs:683:33
    |
683 | / ...                   match text[..cursor.index]
684 | | ...                       .char_indices()
685 | | ...                       .filter(|&(_, c)| c == find_c)
686 | | ...                       .last()
...   |
692 | | ...                       None => {}
693 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
683 ~                                 if let Some((i, _)) = text[..cursor.index]
684 +                                     .char_indices()
685 +                                     .filter(|&(_, c)| c == find_c)
686 +                                     .last() {
687 +                                     cursor.index = i;
688 +                                     editor.set_cursor(cursor);
689 +                                 }
    |

Check warning on line 588 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead

warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead
   --> src/edit/vi.rs:585:39
    |
585 |   ...                   match text[cursor.index..]
    |  _____________________________^
586 | | ...                       .char_indices()
587 | | ...                       .filter(|&(i, c)| i > 0 && c == find_c)
588 | | ...                       .next()
    | |_________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#filter_next
    = note: `#[warn(clippy::filter_next)]` on by default
help: try
    |
585 ~                                 match text[cursor.index..]
586 +                                     .char_indices().find(|&(i, c)| i > 0 && c == find_c)
    |

Check warning on line 595 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/edit/vi.rs:585:33
    |
585 | / ...                   match text[cursor.index..]
586 | | ...                       .char_indices()
587 | | ...                       .filter(|&(i, c)| i > 0 && c == find_c)
588 | | ...                       .next()
...   |
594 | | ...                       None => {}
595 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
585 ~                                 if let Some((i, _)) = text[cursor.index..]
586 +                                     .char_indices()
587 +                                     .filter(|&(i, c)| i > 0 && c == find_c)
588 +                                     .next() {
589 +                                     cursor.index += i;
590 +                                     editor.set_cursor(cursor);
591 +                                 }
    |

Check warning on line 369 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

match expression looks like `matches!` macro

warning: match expression looks like `matches!` macro
   --> src/edit/vi.rs:366:29
    |
366 |           let has_selection = match editor.selection() {
    |  _____________________________^
367 | |             Selection::None => false,
368 | |             _ => true,
369 | |         };
    | |_________^ help: try: `!matches!(editor.selection(), Selection::None)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
    = note: `#[warn(clippy::match_like_matches_macro)]` on by default

Check warning on line 189 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function returning `Result` missing `# Errors` section

warning: docs for function returning `Result` missing `# Errors` section
   --> src/edit/vi.rs:184:5
    |
184 | /     pub fn load_text<P: AsRef<std::path::Path>>(
185 | |         &mut self,
186 | |         font_system: &mut FontSystem,
187 | |         path: P,
188 | |         attrs: crate::Attrs,
189 | |     ) -> std::io::Result<()> {
    | |____________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc
note: the lint level is defined here
   --> src/lib.rs:86:9
    |
86  | #![warn(clippy::missing_errors_doc)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^

Check warning on line 41 in src/edit/vi.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
  --> src/edit/vi.rs:33:5
   |
33 | /     match editor.finish_change() {
34 | |         Some(change) => {
35 | |             if !change.items.is_empty() {
36 | |                 commands.push(change);
...  |
40 | |         None => {}
41 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
   |
33 ~     if let Some(change) = editor.finish_change() {
34 +         if !change.items.is_empty() {
35 +             commands.push(change);
36 +             *changed = true;
37 +         }
38 +     }
   |

Check warning on line 352 in src/edit/editor.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/edit/editor.rs:342:9
    |
342 | /         match self.change.take() {
343 | |             Some(pending) => {
344 | |                 if !pending.items.is_empty() {
345 | |                     //TODO: is this a good idea?
...   |
351 | |             None => {}
352 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
    = note: `#[warn(clippy::single_match)]` on by default
help: try
    |
342 ~         if let Some(pending) = self.change.take() {
343 +             if !pending.items.is_empty() {
344 +                 //TODO: is this a good idea?
345 +                 log::warn!("pending change caused apply_change to be ignored!");
346 +                 self.change = Some(pending);
347 +                 return false;
348 +             }
349 +         }
    |

Check warning on line 225 in src/buffer_line.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer_line.rs:218:5
    |
218 | /     pub fn layout_in_buffer(
219 | |         &mut self,
220 | |         scratch: &mut ShapeBuffer,
221 | |         font_system: &mut FontSystem,
...   |
224 | |         wrap: Wrap,
225 | |     ) -> &[LayoutLine] {
    | |______________________^
    |
note: first possible panic found here
   --> src/buffer_line.rs:234:9
    |
234 |         self.layout_opt.as_ref().expect("layout not found")
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 206 in src/buffer_line.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer_line.rs:200:5
    |
200 | /     pub fn layout(
201 | |         &mut self,
202 | |         font_system: &mut FontSystem,
203 | |         font_size: f32,
204 | |         width: f32,
205 | |         wrap: Wrap,
206 | |     ) -> &[LayoutLine] {
    | |______________________^
    |
note: first possible panic found here
   --> src/buffer_line.rs:214:9
    |
214 |         self.layout_opt.as_ref().expect("layout not found")
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 180 in src/buffer_line.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer_line.rs:176:5
    |
176 | /     pub fn shape_in_buffer(
177 | |         &mut self,
178 | |         scratch: &mut ShapeBuffer,
179 | |         font_system: &mut FontSystem,
180 | |     ) -> &ShapeLine {
    | |___________________^
    |
note: first possible panic found here
   --> src/buffer_line.rs:191:9
    |
191 |         self.shape_opt.as_ref().expect("shape not found")
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 486 in src/buffer.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer.rs:486:5
    |
486 |     pub fn layout_cursor(&self, cursor: &Cursor) -> LayoutCursor {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/buffer.rs:490:22
    |
490 |         let layout = line.layout_opt().as_ref().expect("layout not found");
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 129 in src/buffer.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/buffer.rs:129:5
    |
129 |     pub fn highlight(&self, cursor_start: Cursor, cursor_end: Cursor) -> Option<(f32, f32)> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/buffer.rs:151:25
    |
151 |             let x_end = x_end.expect("end of cursor not found");
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc

Check warning on line 272 in src/attrs.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

docs for function which may panic missing `# Panics` section

warning: docs for function which may panic missing `# Panics` section
   --> src/attrs.rs:272:5
    |
272 |     pub fn split_off(&mut self, index: usize) -> Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: first possible panic found here
   --> src/attrs.rs:288:34
    |
288 |               let (range, attrs) = self
    |  __________________________________^
289 | |                 .spans
290 | |                 .get_key_value(&key.start)
291 | |                 .map(|v| (v.0.clone(), v.1.clone()))
292 | |                 .expect("attrs span not found");
    | |_______________________________________________^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
note: the lint level is defined here
   --> src/lib.rs:88:9
    |
88  | #![warn(clippy::missing_panics_doc)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^