Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:
type: string
env:
CARGO_TERM_COLOR: always
rust_version: 1.83.0
rust_version: 1.93.0
jobs:
build:
runs-on: ${{ inputs.os }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/scans.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ on:

env:
CARGO_TERM_COLOR: always
rust_version: 1.93.0
jobs:
audit:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4
- name: versions
run: |
rustup default ${{ env.rust_version }}
rustup --version
cargo --version
rustc --version
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ serde_json = "1.0"
slotmap = "1.0"
store-interval-tree = "0.4"
strum = { version = "0.28", features = ["derive"] }
subprocess = "=0.2.9"
subprocess = "1.0"
thiserror = "2.0"
urlencoding = "2.1"
utf8-read = "0.4"
Expand Down
27 changes: 11 additions & 16 deletions src/actions/analysis_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ impl AnalysisStorage {
self.device_triggers.get(path)
.map(|triggers|triggers.iter()
.filter(
|p|filter.map_or(
true,
|p|filter.is_none_or(
|f|f.contains(&ContextDefinition::Device((*p).clone()))))
.filter_map(|p|self.get_device_analysis(p).ok())
.collect())
Expand Down Expand Up @@ -286,8 +285,7 @@ impl AnalysisStorage {

trace!("Full contexts for {:?} are {:?}", path, contexts);

if self.get_isolated_analysis(path).map_or(
false, |a|a.is_device_file()) {
if self.get_isolated_analysis(path).is_ok_and(|a|a.is_device_file()) {
contexts.insert(Some(path.clone()));
}

Expand Down Expand Up @@ -316,7 +314,7 @@ impl AnalysisStorage {
let mut target_devices: Vec<CanonPath> = vec![];

if self.get_isolated_analysis(path)
.map_or(false, |a|a.is_device_file()) {
.is_ok_and(|a|a.is_device_file()) {
target_devices.push(path.clone());
} else {
// Remove ourselves from the trigee list of any file
Expand All @@ -325,7 +323,7 @@ impl AnalysisStorage {
self.device_triggers.get_mut(trigger_path)
.map(|e|e.remove(path));
if self.device_triggers.get(trigger_path)
.map_or(false, |e|e.is_empty()) {
.is_some_and(|e|e.is_empty()) {
self.device_triggers.remove(trigger_path);
}
}
Expand Down Expand Up @@ -483,13 +481,11 @@ impl AnalysisStorage {
let canon_path = analysis.path.clone();
trace!("Handling isolated analysis on {}",
canon_path.as_str());
if self.isolated_analysis.get(&canon_path).map_or(
true,
if self.isolated_analysis.get(&canon_path).is_none_or(
|prev| timestamp_is_newer(timestamp, prev.timestamp)) {
trace!("invalidators are {:?}", self.invalidators);
if self.invalidators.get(&canon_path).map_or(
true, |invalid| timestamp_is_newer(timestamp,
*invalid)) {
if self.invalidators.get(&canon_path).is_none_or(
|invalid| timestamp_is_newer(timestamp, *invalid)) {
trace!("was new, or fresh compared to previous");
dependencies_to_update.insert(canon_path.clone());
self.isolated_analysis.insert(canon_path.clone(),
Expand Down Expand Up @@ -530,9 +526,8 @@ impl AnalysisStorage {
if let AnalysisResult::Device(analysis) = analysisresult.stored {
let canon_path = analysis.path.clone();
trace!("Handling device analysis on {}", canon_path.as_str());
if self.device_analysis.get(&canon_path).map_or(
true, |prev| timestamp_is_newer(timestamp,
prev.timestamp)) {
if self.device_analysis.get(&canon_path).is_none_or(
|prev| timestamp_is_newer(timestamp, prev.timestamp)) {
trace!("was new, or fresh compared to previous");
// This should be guaranteed
let invalidators = self.all_dependencies(
Expand Down Expand Up @@ -581,7 +576,7 @@ impl AnalysisStorage {
for path in self.last_use.keys().cloned().collect::<Vec<CanonPath>>() {
if now.duration_since(*self.last_use.get(&path)
.unwrap().lock().unwrap())
.map_or(false, |duration|duration > max_age) {
.is_ok_and(|duration|duration > max_age) {
info!("Discarded analysis of {} due to it being \
unused for too long.", path.as_str());
self.mark_file_dirty(&path);
Expand Down Expand Up @@ -704,7 +699,7 @@ impl AnalysisStorage {
.extend(self.gather_linter_errors(file).into_iter());

// Only report device errors if this analysis context is active
if filter.map_or(true, |f|f.contains(&file.clone().into())) {
if filter.is_none_or(|f|f.contains(&file.clone().into())) {
for (dfile, errors) in self.gather_device_errors(file) {
device_errors.entry(dfile.clone())
.or_default()
Expand Down
6 changes: 3 additions & 3 deletions src/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ impl <O: Output> InitActionContext<O> {
if !workspaces.is_empty() &&
!workspaces.iter().any(
|root|parse_file_path!(&root.uri, "workspace")
.map_or(false, |p|canon_path.as_path()
.starts_with(p))) {
.is_ok_and(|p|canon_path.as_path()
.starts_with(p))) {
crate::server::warning_message(
out,
"Compilation info file is not under \
Expand Down Expand Up @@ -1435,7 +1435,7 @@ impl FileWatch {
fn relevant_change_kind(&self, change_uri: &Uri,
_kind: FileChangeType) -> bool {
let path = change_uri.as_str();
self.file_path.to_str().map_or(false, |fp|fp == path)
self.file_path.to_str().is_some_and(|fp|fp == path)
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/actions/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl BlockingNotificationAction for DidChangeConfiguration {
debug!("config change: {:?}", params.settings);
// New style config update, send re-config request
if params.settings.is_null() || params.settings.as_object().
map_or(false, |o|o.is_empty()) {
is_some_and(|o|o.is_empty()) {
let config_params = lsp_types::ConfigurationParams {
items: vec![lsp_types::ConfigurationItem {
scope_uri: None,
Expand Down
2 changes: 1 addition & 1 deletion src/actions/semantic_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ fn get_symbols_of_ref<'t>(reference: &Reference,
if device.templates.templates.get(sym.name_ref())
.and_then(|t|t.location.as_ref())
.and_then(|loc|device.template_object_implementation_map.get(loc))
.map_or(false, |impls|!impls.is_empty()) {
.is_some_and(|impls|!impls.is_empty()) {
any_template_used = true;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ impl DeviceAnalysis {
if let Some(found_obj)
= curr_obj.get_object(sym.name_ref()) {
if found_obj.resolve(&self.objects).as_shallow()
.map_or(false, |s|matches!(
.is_some_and(|s|matches!(
&s.variant,
DMLShallowObjectVariant::Method(_))) {
vec![found_obj.clone()]
Expand Down Expand Up @@ -1009,7 +1009,7 @@ impl DeviceAnalysis {
sym: &SimpleSymbol,
ref_matches: &mut ReferenceMatches) {
let resolved = obj.resolve(&self.objects);
if resolved.as_comp().map_or(false, |c|c.kind == CompObjectKind::Device)
if resolved.as_comp().is_some_and(|c|c.kind == CompObjectKind::Device)
&& sym.kind == DMLSymbolKind::Template {
self.lookup_global_symbol(sym, ref_matches);
} else {
Expand Down Expand Up @@ -1656,8 +1656,8 @@ impl IsolatedAnalysis {
&mut errors, filespec);
status.assert_alive();
// sanity, clientpath and path should be the same file
if CanonPath::from_path_buf(clientpath.clone()).map_or(
true, |cp|&cp != path) {
if CanonPath::from_path_buf(clientpath.clone()).is_none_or(
|cp|&cp != path) {
error!("Clientpath did not describe the same \
file as the actual path; {:?} vs {:?}",
path,
Expand Down
20 changes: 10 additions & 10 deletions src/analysis/parsing/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,8 @@ fn maybe_parse_extended_expression(preset_left: Option<Expression>,
let mut new_context = context.enter_context(understands_continuations);
let mut left = parse_expression_inner(
preset_left, &new_context, stream, file_info);
while new_context.peek_kind(stream).map_or(
false, |k|understands_continuations(k)) {
while new_context.peek_kind(stream).is_some_and(
|k|understands_continuations(k)) {
match new_context.peek_kind(stream) {
Some(TokenKind::LParen) => left = parse_function_call(
left, &new_context, stream, file_info),
Expand Down Expand Up @@ -872,7 +872,7 @@ fn maybe_parse_muldivmod_expression(preset_left: Option<Expression>,
let mut left = maybe_parse_extended_expression(preset_left,
&new_context,
stream, file_info);
if new_context.peek_kind(stream).map_or(false, understands_muldivmods) {
if new_context.peek_kind(stream).is_some_and(understands_muldivmods) {
let operation = new_context.next_leaf(stream);
let right = maybe_parse_muldivmod_expression(None,
context,
Expand All @@ -897,7 +897,7 @@ fn maybe_parse_addsub_expression(preset_left: Option<Expression>,
let mut left = maybe_parse_muldivmod_expression(preset_left,
&new_context,
stream, file_info);
if new_context.peek_kind(stream).map_or(false, understands_addsubs) {
if new_context.peek_kind(stream).is_some_and(understands_addsubs) {
let operation = new_context.next_leaf(stream);
let right = maybe_parse_addsub_expression(None,
context,
Expand All @@ -922,7 +922,7 @@ fn maybe_parse_shift_expression(preset_left: Option<Expression>,
let mut left = maybe_parse_addsub_expression(preset_left,
&new_context,
stream, file_info);
if new_context.peek_kind(stream).map_or(false, understands_shifts) {
if new_context.peek_kind(stream).is_some_and(understands_shifts) {
let operation = new_context.next_leaf(stream);
let right = maybe_parse_shift_expression(None,
context,
Expand All @@ -948,7 +948,7 @@ fn maybe_parse_comparison_expression(preset_left: Option<Expression>,
let mut left = maybe_parse_shift_expression(preset_left,
&new_context,
stream, file_info);
if new_context.peek_kind(stream).map_or(false, understands_comparisons) {
if new_context.peek_kind(stream).is_some_and(understands_comparisons) {
let operation = new_context.next_leaf(stream);
let right = maybe_parse_comparison_expression(None,
context,
Expand All @@ -974,7 +974,7 @@ fn maybe_parse_equality_expression(preset_left: Option<Expression>,
&new_context,
stream,
file_info);
if new_context.peek_kind(stream).map_or(false, understands_equality) {
if new_context.peek_kind(stream).is_some_and(understands_equality) {
let operation = new_context.next_leaf(stream);
let right = maybe_parse_equality_expression(None,
context,
Expand Down Expand Up @@ -1002,7 +1002,7 @@ fn maybe_parse_binary_calc_expression(preset_left: Option<Expression>,
let mut left = maybe_parse_equality_expression(preset_left,
&new_context,
stream, file_info);
if new_context.peek_kind(stream).map_or(false, understands_binaries) {
if new_context.peek_kind(stream).is_some_and(understands_binaries) {
let operation = new_context.next_leaf(stream);
let right = maybe_parse_binary_calc_expression(None,
context,
Expand Down Expand Up @@ -1090,8 +1090,8 @@ pub fn maybe_parse_tertiary_expression(preset_left: Option<Expression>,
let mut left = maybe_parse_logic_or_expression(preset_left,
&pre_quest_context,
stream, file_info);
if pre_quest_context.peek_kind(stream).map_or(
false, |k|understands_tert_first_ops(k)) {
if pre_quest_context.peek_kind(stream).is_some_and(
|k|understands_tert_first_ops(k)) {
let first_opr = pre_quest_context.next_leaf(stream);
let opr_kind = match first_opr {
LeafToken::Actual(token) => token.kind,
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/parsing/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ impl CDeclList {
-> CDeclList {
let mut new_context = context.enter_context(doesnt_understand_tokens);
let mut decls = vec![];
let empty = !new_context.peek_kind(stream).map_or(
false, CDecl::first_token_matcher);
let empty = !new_context.peek_kind(stream).is_some_and(
CDecl::first_token_matcher);
// Note that trailing commas in these lists are NOT allowed,
// which is why we only check for entry into the loop
if !empty {
Expand Down
33 changes: 17 additions & 16 deletions src/analysis/parsing/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl Parse<StatementContent> for CompoundContent {
statements.push(Statement::parse(&statement_context,
stream, file_info));
cont = statement_context.peek_kind(stream)
.map_or(false, dmlstatement_first_token_matcher);
.is_some_and(dmlstatement_first_token_matcher);
}
let rbrace = new_context.expect_next_kind(stream, TokenKind::RBrace);
StatementContent::Compound(CompoundContent {
Expand Down Expand Up @@ -666,6 +666,7 @@ impl TreeElement for ForPostElement {
}
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, PartialEq)]
pub enum ForPre {
Declaration(LeafToken, VarDecl, Option<(LeafToken, Initializer)>),
Expand Down Expand Up @@ -966,11 +967,11 @@ fn parse_switchhashif(context: &ParseContext, stream: &mut FileParser<'_>, file_
let lbrace = outer_context.expect_next_kind(stream, TokenKind::LBrace);
let mut rbrace_context = outer_context.enter_context(understands_rbrace);
let mut truecases = vec![];
while rbrace_context.peek_kind(stream).map_or(
false, |t|matches!(t,
TokenKind::HashIf |
TokenKind::Case |
TokenKind::Default) ||
while rbrace_context.peek_kind(stream).is_some_and(
|t|matches!(t,
TokenKind::HashIf |
TokenKind::Case |
TokenKind::Default) ||
dmlstatement_first_token_matcher(t)) {
truecases.push(parse_switchcase(&rbrace_context, stream, file_info));
}
Expand All @@ -983,11 +984,11 @@ fn parse_switchhashif(context: &ParseContext, stream: &mut FileParser<'_>, file_
let mut falsecases = vec![];
let mut rbrace_context = outer_context.enter_context(
understands_rbrace);
while rbrace_context.peek_kind(stream).map_or(
false, |t|matches!(t,
TokenKind::HashIf |
TokenKind::Case |
TokenKind::Default) ||
while rbrace_context.peek_kind(stream).is_some_and(
|t|matches!(t,
TokenKind::HashIf |
TokenKind::Case |
TokenKind::Default) ||
dmlstatement_first_token_matcher(t)){
falsecases.push(parse_switchcase(&rbrace_context, stream, file_info));
}
Expand Down Expand Up @@ -1147,11 +1148,11 @@ impl Parse<StatementContent> for SwitchContent {
let mut rbrace_context = outer_context.enter_context(
understands_rbrace);
let mut cases = vec![];
while rbrace_context.peek_kind(stream).map_or(
false, |t|matches!(t,
TokenKind::HashIf |
TokenKind::Case |
TokenKind::Default) ||
while rbrace_context.peek_kind(stream).is_some_and(
|t|matches!(t,
TokenKind::HashIf |
TokenKind::Case |
TokenKind::Default) ||
dmlstatement_first_token_matcher(t)) {
cases.push(parse_switchcase(&rbrace_context, stream, file_info));
}
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/parsing/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ fn check_dmlobject_kind(obj: &DMLObjectContent, _file: &TextFile) ->
},
DMLObjectContent::Method(methodcontent) => {
if methodcontent.modifier.as_ref().and_then(|m|m.get_token())
.map_or(false, |s|s.kind == TokenKind::Shared) {
.is_some_and(|s|s.kind == TokenKind::Shared) {
return vec![LocalDMLError {
range: obj.range(),
description: "Shared method \
Expand Down Expand Up @@ -813,8 +813,8 @@ impl Parse<ObjectStatementsContent> for ObjectStatements {
let mut bracecontext = outer.enter_context(
understands_rbrace);
let mut statements = vec![];
while bracecontext.peek_kind(stream).map_or(
false, |t|dmlobject_first_token_matcher(t)) {
while bracecontext.peek_kind(stream).is_some_and(
|t|dmlobject_first_token_matcher(t)) {
statements.push(
DMLObject::parse(&bracecontext, stream, file_info));
}
Expand Down
Loading