on master help sign in
Fix all remaining warnings in helix-core except for two.
220bc85Nathan Vegdahl
helix-core/src/auto_pairs.rs+1−1
@@ -139,7 +139,7 @@ fn handle_close(doc: &Rope, selection: &Selection, _open: char, close: char) ->
139}
139}
140
140
141// handle cases where open and close is the same, or in triples ("""docstring""")
141// handle cases where open and close is the same, or in triples ("""docstring""")
142−fn handle_same(doc: &Rope, selection: &Selection, token: char) -> Option<Transaction> {
142+fn handle_same(_doc: &Rope, _selection: &Selection, _token: char) -> Option<Transaction> {
143 // if not cursor but selection, wrap
143 // if not cursor but selection, wrap
144 // let next = next char
144 // let next = next char
145
145
helix-core/src/history.rs+4−5
@@ -126,7 +126,6 @@ impl History {
126 let last_child = current_revision.last_child?;
126 let last_child = current_revision.last_child?;
127 self.current = last_child.get();
127 self.current = last_child.get();
128
128
129− let last_child_revision = &self.revisions[last_child.get()];
130 Some(&self.revisions[last_child.get()].transaction)
129 Some(&self.revisions[last_child.get()].transaction)
131 }
130 }
132
131
@@ -376,21 +375,21 @@ mod test {
376 if let Some(transaction) = history.undo() {
375 if let Some(transaction) = history.undo() {
377 transaction.apply(&mut state.doc);
376 transaction.apply(&mut state.doc);
378 }
377 }
379− };
378+ }
380
379
381 fn earlier(history: &mut History, state: &mut State, uk: UndoKind) {
380 fn earlier(history: &mut History, state: &mut State, uk: UndoKind) {
382 let txns = history.earlier(uk);
381 let txns = history.earlier(uk);
383 for txn in txns {
382 for txn in txns {
384 txn.apply(&mut state.doc);
383 txn.apply(&mut state.doc);
385 }
384 }
386− };
385+ }
387
386
388 fn later(history: &mut History, state: &mut State, uk: UndoKind) {
387 fn later(history: &mut History, state: &mut State, uk: UndoKind) {
389 let txns = history.later(uk);
388 let txns = history.later(uk);
390 for txn in txns {
389 for txn in txns {
391 txn.apply(&mut state.doc);
390 txn.apply(&mut state.doc);
392 }
391 }
393− };
392+ }
394
393
395 fn commit_change(
394 fn commit_change(
396 history: &mut History,
395 history: &mut History,
@@ -401,7 +400,7 @@ mod test {
401 let txn = Transaction::change(&state.doc, vec![change.clone()].into_iter());
400 let txn = Transaction::change(&state.doc, vec![change.clone()].into_iter());
402 history.commit_revision_at_timestamp(&txn, &state, instant);
401 history.commit_revision_at_timestamp(&txn, &state, instant);
403 txn.apply(&mut state.doc);
402 txn.apply(&mut state.doc);
404− };
403+ }
405
404
406 let t0 = Instant::now();
405 let t0 = Instant::now();
407 let t = |n| t0.checked_add(Duration::from_secs(n)).unwrap();
406 let t = |n| t0.checked_add(Duration::from_secs(n)).unwrap();
helix-core/src/indent.rs+3−2
@@ -7,7 +7,7 @@ use crate::{
7
7
8/// To determine indentation of a newly inserted line, figure out the indentation at the last col
8/// To determine indentation of a newly inserted line, figure out the indentation at the last col
9/// of the previous line.
9/// of the previous line.
10−
10+#[allow(dead_code)]
11fn indent_level_for_line(line: RopeSlice, tab_width: usize) -> usize {
11fn indent_level_for_line(line: RopeSlice, tab_width: usize) -> usize {
12 let mut len = 0;
12 let mut len = 0;
13 for ch in line.chars() {
13 for ch in line.chars() {
@@ -98,12 +98,13 @@ fn calculate_indentation(query: &IndentQuery, node: Option<Node>, newline: bool)
98 increment as usize
98 increment as usize
99}
99}
100
100
101+#[allow(dead_code)]
101fn suggested_indent_for_line(
102fn suggested_indent_for_line(
102 language_config: &LanguageConfiguration,
103 language_config: &LanguageConfiguration,
103 syntax: Option<&Syntax>,
104 syntax: Option<&Syntax>,
104 text: RopeSlice,
105 text: RopeSlice,
105 line_num: usize,
106 line_num: usize,
106− tab_width: usize,
107+ _tab_width: usize,
107) -> usize {
108) -> usize {
108 if let Some(start) = find_first_non_whitespace_char(text.line(line_num)) {
109 if let Some(start) = find_first_non_whitespace_char(text.line(line_num)) {
109 return suggested_indent_for_pos(
110 return suggested_indent_for_pos(
helix-core/src/match_brackets.rs+1−1
@@ -12,7 +12,7 @@ pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
12 // most naive implementation: find the innermost syntax node, if we're at the edge of a node,
12 // most naive implementation: find the innermost syntax node, if we're at the edge of a node,
13 // return the other edge.
13 // return the other edge.
14
14
15− let mut node = match tree
15+ let node = match tree
16 .root_node()
16 .root_node()
17 .named_descendant_for_byte_range(byte_pos, byte_pos)
17 .named_descendant_for_byte_range(byte_pos, byte_pos)
18 {
18 {
helix-core/src/movement.rs+1−2
@@ -113,7 +113,7 @@ pub fn move_prev_long_word_start(slice: RopeSlice, range: Range, count: usize) -
113 word_move(slice, range, count, WordMotionTarget::PrevLongWordStart)
113 word_move(slice, range, count, WordMotionTarget::PrevLongWordStart)
114}
114}
115
115
116−fn word_move(slice: RopeSlice, mut range: Range, count: usize, target: WordMotionTarget) -> Range {
116+fn word_move(slice: RopeSlice, range: Range, count: usize, target: WordMotionTarget) -> Range {
117 (0..count).fold(range, |range, _| {
117 (0..count).fold(range, |range, _| {
118 slice.chars_at(range.head).range_to_target(target, range)
118 slice.chars_at(range.head).range_to_target(target, range)
119 })
119 })
@@ -179,7 +179,6 @@ enum WordMotionPhase {
179
179
180impl CharHelpers for Chars<'_> {
180impl CharHelpers for Chars<'_> {
181 fn range_to_target(&mut self, target: WordMotionTarget, origin: Range) -> Range {
181 fn range_to_target(&mut self, target: WordMotionTarget, origin: Range) -> Range {
182− let range = origin;
183 // Characters are iterated forward or backwards depending on the motion direction.
182 // Characters are iterated forward or backwards depending on the motion direction.
184 let characters: Box<dyn Iterator<Item = char>> = match target {
183 let characters: Box<dyn Iterator<Item = char>> = match target {
185 WordMotionTarget::PrevWordStart | WordMotionTarget::PrevLongWordStart => {
184 WordMotionTarget::PrevWordStart | WordMotionTarget::PrevLongWordStart => {
helix-core/src/position.rs+2−2
@@ -80,8 +80,8 @@ mod test {
80
80
81 #[test]
81 #[test]
82 fn test_coords_at_pos() {
82 fn test_coords_at_pos() {
83− let text = Rope::from("ḧëḷḷö\nẅöṛḷḋ");
83+ // let text = Rope::from("ḧëḷḷö\nẅöṛḷḋ");
84− let slice = text.slice(..);
84+ // let slice = text.slice(..);
85 // assert_eq!(coords_at_pos(slice, 0), (0, 0).into());
85 // assert_eq!(coords_at_pos(slice, 0), (0, 0).into());
86 // assert_eq!(coords_at_pos(slice, 5), (0, 5).into()); // position on \n
86 // assert_eq!(coords_at_pos(slice, 5), (0, 5).into()); // position on \n
87 // assert_eq!(coords_at_pos(slice, 6), (1, 0).into()); // position on w
87 // assert_eq!(coords_at_pos(slice, 6), (1, 0).into()); // position on w
helix-core/src/selection.rs+5−7
@@ -345,10 +345,8 @@ pub fn select_on_matches(
345 // TODO: can't avoid occasional allocations since Regex can't operate on chunks yet
345 // TODO: can't avoid occasional allocations since Regex can't operate on chunks yet
346 let fragment = sel.fragment(text);
346 let fragment = sel.fragment(text);
347
347
348− let mut sel_start = sel.from();
348+ let sel_start = sel.from();
349− let sel_end = sel.to();
350−
351− let mut start_byte = text.char_to_byte(sel_start);
349+ let start_byte = text.char_to_byte(sel_start);
352
350
353 for mat in regex.find_iter(&fragment) {
351 for mat in regex.find_iter(&fragment) {
354 // TODO: retain range direction
352 // TODO: retain range direction
@@ -379,10 +377,10 @@ pub fn split_on_matches(
379 // TODO: can't avoid occasional allocations since Regex can't operate on chunks yet
377 // TODO: can't avoid occasional allocations since Regex can't operate on chunks yet
380 let fragment = sel.fragment(text);
378 let fragment = sel.fragment(text);
381
379
382− let mut sel_start = sel.from();
380+ let sel_start = sel.from();
383 let sel_end = sel.to();
381 let sel_end = sel.to();
384
382
385− let mut start_byte = text.char_to_byte(sel_start);
383+ let start_byte = text.char_to_byte(sel_start);
386
384
387 let mut start = sel_start;
385 let mut start = sel_start;
388
386
@@ -411,7 +409,7 @@ mod test {
411 #[test]
409 #[test]
412 #[should_panic]
410 #[should_panic]
413 fn test_new_empty() {
411 fn test_new_empty() {
414− let sel = Selection::new(smallvec![], 0);
412+ let _ = Selection::new(smallvec![], 0);
415 }
413 }
416
414
417 #[test]
415 #[test]
helix-core/src/syntax.rs+18−17
@@ -166,7 +166,7 @@ impl LanguageConfiguration {
166 None
166 None
167 } else {
167 } else {
168 let language = get_language(self.language_id);
168 let language = get_language(self.language_id);
169− let mut config = HighlightConfiguration::new(
169+ let config = HighlightConfiguration::new(
170 language,
170 language,
171 &highlights_query,
171 &highlights_query,
172 &injections_query,
172 &injections_query,
@@ -332,7 +332,8 @@ impl Syntax {
332
332
333 // update root layer
333 // update root layer
334 PARSER.with(|ts_parser| {
334 PARSER.with(|ts_parser| {
335+ // TODO: handle the returned `Result` properly.
335− syntax.root_layer.parse(
336+ let _ = syntax.root_layer.parse(
336 &mut ts_parser.borrow_mut(),
337 &mut ts_parser.borrow_mut(),
337 &syntax.config,
338 &syntax.config,
338 source,
339 source,
@@ -387,7 +388,7 @@ impl Syntax {
387 source: RopeSlice<'a>,
388 source: RopeSlice<'a>,
388 range: Option<std::ops::Range<usize>>,
389 range: Option<std::ops::Range<usize>>,
389 cancellation_flag: Option<&'a AtomicUsize>,
390 cancellation_flag: Option<&'a AtomicUsize>,
390− mut injection_callback: impl FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
391+ injection_callback: impl FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
391 ) -> impl Iterator<Item = Result<HighlightEvent, Error>> + 'a {
392 ) -> impl Iterator<Item = Result<HighlightEvent, Error>> + 'a {
392 // The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
393 // The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
393 // prevents them from being moved. But both of these values are really just
394 // prevents them from being moved. But both of these values are really just
@@ -494,8 +495,8 @@ impl LanguageLayer {
494 ts_parser: &mut TsParser,
495 ts_parser: &mut TsParser,
495 config: &HighlightConfiguration,
496 config: &HighlightConfiguration,
496 source: &Rope,
497 source: &Rope,
497− mut depth: usize,
498+ _depth: usize,
498− mut ranges: Vec<Range>,
499+ ranges: Vec<Range>,
499 ) -> Result<(), Error> {
500 ) -> Result<(), Error> {
500 if ts_parser.parser.set_included_ranges(&ranges).is_ok() {
501 if ts_parser.parser.set_included_ranges(&ranges).is_ok() {
501 ts_parser
502 ts_parser
@@ -1644,13 +1645,13 @@ fn injection_for_match<'a>(
1644 (language_name, content_node, include_children)
1645 (language_name, content_node, include_children)
1645}
1646}
1646
1647
1647−fn shrink_and_clear<T>(vec: &mut Vec<T>, capacity: usize) {
1648+// fn shrink_and_clear<T>(vec: &mut Vec<T>, capacity: usize) {
1648− if vec.len() > capacity {
1649+// if vec.len() > capacity {
1649− vec.truncate(capacity);
1650+// vec.truncate(capacity);
1650− vec.shrink_to_fit();
1651+// vec.shrink_to_fit();
1651− }
1652+// }
1652− vec.clear();
1653+// vec.clear();
1653−}
1654+// }
1654
1655
1655pub struct Merge<I> {
1656pub struct Merge<I> {
1656 iter: I,
1657 iter: I,
@@ -1691,7 +1692,7 @@ impl<I: Iterator<Item = HighlightEvent>> Iterator for Merge<I> {
1691 loop {
1692 loop {
1692 match (self.next_event, &self.next_span) {
1693 match (self.next_event, &self.next_span) {
1693 // this happens when range is partially or fully offscreen
1694 // this happens when range is partially or fully offscreen
1694− (Some(Source { start, end }), Some((span, range))) if start > range.start => {
1695+ (Some(Source { start, .. }), Some((span, range))) if start > range.start => {
1695 if start > range.end {
1696 if start > range.end {
1696 self.next_span = self.spans.next();
1697 self.next_span = self.spans.next();
1697 } else {
1698 } else {
@@ -1711,7 +1712,7 @@ impl<I: Iterator<Item = HighlightEvent>> Iterator for Merge<I> {
1711 self.next_event = self.iter.next();
1712 self.next_event = self.iter.next();
1712 Some(HighlightEnd)
1713 Some(HighlightEnd)
1713 }
1714 }
1714− (Some(Source { start, end }), Some((span, range))) if start < range.start => {
1715+ (Some(Source { start, end }), Some((_, range))) if start < range.start => {
1715 let intersect = range.start.min(end);
1716 let intersect = range.start.min(end);
1716 let event = Source {
1717 let event = Source {
1717 start,
1718 start,
@@ -1766,7 +1767,7 @@ impl<I: Iterator<Item = HighlightEvent>> Iterator for Merge<I> {
1766 Some(event)
1767 Some(event)
1767 }
1768 }
1768 // can happen if deleting and cursor at EOF, and diagnostic reaches past the end
1769 // can happen if deleting and cursor at EOF, and diagnostic reaches past the end
1769− (None, Some((span, range))) => {
1770+ (None, Some((_, _))) => {
1770 self.next_span = None;
1771 self.next_span = None;
1771 None
1772 None
1772 }
1773 }
@@ -1809,7 +1810,7 @@ mod test {
1809 .collect();
1810 .collect();
1810
1811
1811 let language = get_language(Lang::Rust);
1812 let language = get_language(Lang::Rust);
1812− let mut config = HighlightConfiguration::new(
1813+ let config = HighlightConfiguration::new(
1813 language,
1814 language,
1814 &std::fs::read_to_string(
1815 &std::fs::read_to_string(
1815 "../helix-syntax/languages/tree-sitter-rust/queries/highlights.scm",
1816 "../helix-syntax/languages/tree-sitter-rust/queries/highlights.scm",
@@ -1853,7 +1854,7 @@ mod test {
1853 use crate::State;
1854 use crate::State;
1854 use tree_sitter::InputEdit;
1855 use tree_sitter::InputEdit;
1855
1856
1856− let mut state = State::new("hello world!\ntest 123".into());
1857+ let state = State::new("hello world!\ntest 123".into());
1857 let transaction = Transaction::change(
1858 let transaction = Transaction::change(
1858 &state.doc,
1859 &state.doc,
1859 vec![(6, 11, Some("test".into())), (12, 17, None)].into_iter(),
1860 vec![(6, 11, Some("test".into())), (12, 17, None)].into_iter(),
helix-core/src/transaction.rs+6−7
@@ -163,7 +163,7 @@ impl ChangeSet {
163 head_a = a;
163 head_a = a;
164 head_b = changes_b.next();
164 head_b = changes_b.next();
165 }
165 }
166− (None, val) | (val, None) => return unreachable!("({:?})", val),
166+ (None, val) | (val, None) => unreachable!("({:?})", val),
167 (Some(Retain(i)), Some(Retain(j))) => match i.cmp(&j) {
167 (Some(Retain(i)), Some(Retain(j))) => match i.cmp(&j) {
168 Ordering::Less => {
168 Ordering::Less => {
169 changes.retain(i);
169 changes.retain(i);
@@ -202,7 +202,7 @@ impl ChangeSet {
202 }
202 }
203 }
203 }
204 }
204 }
205− (Some(Insert(mut s)), Some(Retain(j))) => {
205+ (Some(Insert(s)), Some(Retain(j))) => {
206 let len = s.chars().count();
206 let len = s.chars().count();
207 match len.cmp(&j) {
207 match len.cmp(&j) {
208 Ordering::Less => {
208 Ordering::Less => {
@@ -274,7 +274,6 @@ impl ChangeSet {
274 let mut changes = Self::with_capacity(self.changes.len());
274 let mut changes = Self::with_capacity(self.changes.len());
275
275
276 let mut pos = 0;
276 let mut pos = 0;
277− let mut len = 0;
278
277
279 for change in &self.changes {
278 for change in &self.changes {
280 use Operation::*;
279 use Operation::*;
@@ -700,7 +699,7 @@ mod test {
700
699
701 #[test]
700 #[test]
702 fn changes_iter() {
701 fn changes_iter() {
703− let mut state = State::new("hello world!\ntest 123".into());
702+ let state = State::new("hello world!\ntest 123".into());
704 let changes = vec![(6, 11, Some("void".into())), (12, 17, None)];
703 let changes = vec![(6, 11, Some("void".into())), (12, 17, None)];
705 let transaction = Transaction::change(&state.doc, changes.clone().into_iter());
704 let transaction = Transaction::change(&state.doc, changes.clone().into_iter());
706 assert_eq!(transaction.changes_iter().collect::<Vec<_>>(), changes);
705 assert_eq!(transaction.changes_iter().collect::<Vec<_>>(), changes);
@@ -732,7 +731,7 @@ mod test {
732 // retain 1, e
731 // retain 1, e
733 // retain 2, l
732 // retain 2, l
734
733
735− let mut changes = t1
734+ let changes = t1
736 .changes
735 .changes
737 .compose(t2.changes)
736 .compose(t2.changes)
738 .compose(t3.changes)
737 .compose(t3.changes)
@@ -747,7 +746,7 @@ mod test {
747 #[test]
746 #[test]
748 fn combine_with_empty() {
747 fn combine_with_empty() {
749 let empty = Rope::from("");
748 let empty = Rope::from("");
750− let mut a = ChangeSet::new(&empty);
749+ let a = ChangeSet::new(&empty);
751
750
752 let mut b = ChangeSet::new(&empty);
751 let mut b = ChangeSet::new(&empty);
753 b.insert("a".into());
752 b.insert("a".into());
@@ -763,7 +762,7 @@ mod test {
763 const TEST_CASE: &'static str = "Hello, これはヘリックスエディターです!";
762 const TEST_CASE: &'static str = "Hello, これはヘリックスエディターです!";
764
763
765 let empty = Rope::from("");
764 let empty = Rope::from("");
766− let mut a = ChangeSet::new(&empty);
765+ let a = ChangeSet::new(&empty);
767
766
768 let mut b = ChangeSet::new(&empty);
767 let mut b = ChangeSet::new(&empty);
769 b.insert(TEST_CASE.into());
768 b.insert(TEST_CASE.into());