Skip to content

Commit 0dd50b4

Browse files
author
Stephan Dilly
committed
upgrade to rust 1.45 and fix new clippy warnings
1 parent b82d7af commit 0dd50b4

File tree

10 files changed

+35
-29
lines changed

10 files changed

+35
-29
lines changed

asyncgit/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![forbid(unsafe_code)]
44
#![forbid(missing_docs)]
55
#![deny(clippy::all)]
6-
#![deny(clippy::result_unwrap_used)]
6+
#![deny(clippy::unwrap_used)]
77
#![deny(clippy::panic)]
88

99
pub mod cached;

asyncgit/src/sync/diff.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,10 @@ fn raw_diff_to_file_diff<'a>(
219219
};
220220

221221
let new_file_diff = if diff.deltas().len() == 1 {
222-
// it's safe to unwrap here because we check first that diff.deltas has a single element.
223-
let delta: DiffDelta = diff.deltas().next().unwrap();
222+
let delta: DiffDelta = diff
223+
.deltas()
224+
.next()
225+
.expect("it's safe to unwrap here because we check first that diff.deltas has a single element");
224226

225227
if delta.status() == Delta::Untracked {
226228
let relative_path =
@@ -272,7 +274,10 @@ fn raw_diff_to_file_diff<'a>(
272274
}
273275

274276
if !current_lines.is_empty() {
275-
adder(&current_hunk.unwrap(), &current_lines);
277+
adder(
278+
&current_hunk.expect("invalid hunk"),
279+
&current_lines,
280+
);
276281
}
277282

278283
if new_file_diff {

asyncgit/src/sync/hunks.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pub fn stage_hunk(
2323

2424
let mut opt = ApplyOptions::new();
2525
opt.hunk_callback(|hunk| {
26-
let header = HunkHeader::from(hunk.unwrap());
26+
let header =
27+
HunkHeader::from(hunk.expect("hunk unavailable"));
2728
hash(&header) == hunk_hash
2829
});
2930

@@ -117,7 +118,8 @@ pub fn unstage_hunk(
117118
let mut hunk_idx = 0;
118119
let mut opt = ApplyOptions::new();
119120
opt.hunk_callback(|_hunk| {
120-
let res = if hunk_idx == hunk_index.unwrap() {
121+
let res = if hunk_idx == hunk_index.expect("invalid hunk")
122+
{
121123
count += 1;
122124
true
123125
} else {

scopetime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![forbid(unsafe_code)]
44
#![forbid(missing_docs)]
5-
#![deny(clippy::result_unwrap_used)]
5+
#![deny(clippy::unwrap_used)]
66

77
use std::time::Instant;
88

src/components/filetree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl FileTreeComponent {
109109
if let Some(item) = self.tree.selected_item() {
110110
match item.kind {
111111
FileTreeItemKind::File(_) => true,
112-
_ => false,
112+
FileTreeItemKind::Path(..) => false,
113113
}
114114
} else {
115115
false
@@ -206,7 +206,7 @@ impl FileTreeComponent {
206206
StatusItemType::New => '+',
207207
StatusItemType::Deleted => '-',
208208
StatusItemType::Renamed => 'R',
209-
_ => ' ',
209+
StatusItemType::Typechange => ' ',
210210
}
211211
}
212212
}

src/components/utils/filetree.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ impl FileTreeItems {
192192
index: usize,
193193
) -> usize {
194194
if let Some(parent_path) = Path::new(path).parent() {
195-
let parent_path = parent_path.to_str().unwrap();
195+
let parent_path =
196+
parent_path.to_str().expect("invalid path");
196197
for i in (0..=index).rev() {
197198
let item = &self.items[i];
198199
let item_path = &item.info.full_path;
@@ -216,18 +217,16 @@ impl FileTreeItems {
216217
ancestors.reverse();
217218

218219
for c in &ancestors {
219-
if c.parent().is_some() {
220-
let path_string = String::from(c.to_str().unwrap());
221-
if !paths_added.contains(c) {
222-
paths_added.insert(c);
223-
let is_collapsed =
224-
collapsed.contains(&path_string);
225-
nodes.push(FileTreeItem::new_path(
226-
c,
227-
path_string,
228-
is_collapsed,
229-
)?);
230-
}
220+
if c.parent().is_some() && !paths_added.contains(c) {
221+
paths_added.insert(c);
222+
let path_string =
223+
String::from(c.to_str().expect("invalid path"));
224+
let is_collapsed = collapsed.contains(&path_string);
225+
nodes.push(FileTreeItem::new_path(
226+
c,
227+
path_string,
228+
is_collapsed,
229+
)?);
231230
}
232231
}
233232

src/components/utils/statustree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ impl StatusTree {
332332
inner_collapsed = Some(format!("{}/", &item_path));
333333
}
334334

335-
if prefix.is_none()
336-
|| item_path.starts_with(prefix.unwrap())
335+
if prefix
336+
.map_or(true, |prefix| item_path.starts_with(prefix))
337337
{
338338
self.tree[i].info.visible = true
339339
} else {

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![deny(clippy::cargo)]
33
#![deny(clippy::pedantic)]
44
#![deny(clippy::nursery)]
5-
#![deny(clippy::result_unwrap_used)]
5+
#![deny(clippy::unwrap_used)]
66
#![deny(clippy::panic)]
77
#![allow(clippy::module_name_repetitions)]
88
#![allow(clippy::multiple_crate_versions)]
@@ -141,8 +141,8 @@ fn main() -> Result<()> {
141141
{
142142
app.update_git(ev)?
143143
}
144+
QueueEvent::GitEvent(..) => (),
144145
QueueEvent::SpinnerUpdate => unreachable!(),
145-
_ => (),
146146
}
147147

148148
draw(&mut terminal, &app)?;

src/tabs/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl Status {
137137
match self.focus {
138138
Focus::WorkDir => self.index_wd.is_file_seleted(),
139139
Focus::Stage => self.index.is_file_seleted(),
140-
_ => false,
140+
Focus::Diff => false,
141141
}
142142
}
143143

src/ui/style.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl Theme {
110110
StatusItemType::Renamed => {
111111
Style::default().fg(self.diff_file_moved)
112112
}
113-
_ => Style::default(),
113+
StatusItemType::Typechange => Style::default(),
114114
};
115115

116116
self.apply_select(style, selected)
@@ -155,7 +155,7 @@ impl Theme {
155155
DiffLineType::Header => Style::default()
156156
.fg(self.disabled_fg)
157157
.modifier(Modifier::BOLD),
158-
_ => Style::default().fg(if selected {
158+
DiffLineType::None => Style::default().fg(if selected {
159159
self.command_fg
160160
} else {
161161
Color::Reset

0 commit comments

Comments
 (0)