Skip to content

Commit

Permalink
beta clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Feb 19, 2024
1 parent 56adf16 commit 639a0ca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
12 changes: 3 additions & 9 deletions libs/common/src/reporting/diagnostic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,9 @@ impl Diagnostic {
processed: &crate::reporting::Processed,
) -> Option<Self> {
let mut diag = Self::new(code.ident(), code.message()).set_severity(code.severity());
let Some(map_start) = processed.mapping(span.start) else {
return None;
};
let Some(map_end) = processed.mapping(span.end) else {
return None;
};
let Some(map_file) = processed.source(map_start.source()) else {
return None;
};
let map_start = processed.mapping(span.start)?;
let map_end = processed.mapping(span.end)?;
let map_file = processed.source(map_start.source())?;
diag.labels.push(
Label::primary(
map_file.0.clone(),
Expand Down
4 changes: 1 addition & 3 deletions libs/common/src/reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ pub trait Code: Send + Sync {

/// A diagnostic for the LSP / terminal
fn diagnostic(&self) -> Option<Diagnostic> {
let Some(token) = self.token() else {
return None;
};
let token = self.token()?;
let mut diag = Diagnostic::new(self.ident(), self.message())
.with_label(
Label::primary(token.position().path().clone(), token.position().span())
Expand Down
8 changes: 2 additions & 6 deletions libs/preprocessor/src/codes/pe12_include_not_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ impl Code for IncludeNotFound {

fn diagnostic(&self) -> Option<Diagnostic> {
// TODO look for files with a similar name
let Some(first) = self.token.first() else {
return None;
};
let Some(last) = self.token.last() else {
return None;
};
let first = self.token.first()?;
let last = self.token.last()?;
Some(
Diagnostic::new(self.ident(), self.message()).with_label(
Label::primary(
Expand Down
8 changes: 2 additions & 6 deletions libs/preprocessor/src/codes/pe15_if_invalid_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ impl Code for IfInvalidOperator {
}

fn diagnostic(&self) -> Option<Diagnostic> {
let Some(start) = self.tokens.first() else {
return None;
};
let Some(end) = self.tokens.last() else {
return None;
};
let start = self.tokens.first()?;
let end = self.tokens.last()?;
Some(
Diagnostic::new(self.ident(), self.message())
.with_label(
Expand Down

0 comments on commit 639a0ca

Please sign in to comment.