chore: Bump Rust edition to 2024 (#27800)
Follow-up to https://github.com/zed-industries/zed/pull/27791 Release Notes: - N/A
This commit is contained in:
parent
d50905e000
commit
dc64ec9cc8
802 changed files with 3775 additions and 3662 deletions
|
@ -1,11 +1,14 @@
|
|||
pub use crate::{
|
||||
Grammar, Language, LanguageRegistry,
|
||||
diagnostic_set::DiagnosticSet,
|
||||
highlight_map::{HighlightId, HighlightMap},
|
||||
proto, Grammar, Language, LanguageRegistry,
|
||||
proto,
|
||||
};
|
||||
use crate::{
|
||||
LanguageScope, Outline, OutlineConfig, RunnableCapture, RunnableTag, TextObject,
|
||||
TreeSitterOptions,
|
||||
diagnostic_set::{DiagnosticEntry, DiagnosticGroup},
|
||||
language_settings::{language_settings, LanguageSettings},
|
||||
language_settings::{LanguageSettings, language_settings},
|
||||
outline::OutlineItem,
|
||||
syntax_map::{
|
||||
SyntaxLayer, SyntaxMap, SyntaxMapCapture, SyntaxMapCaptures, SyntaxMapMatch,
|
||||
|
@ -13,10 +16,8 @@ use crate::{
|
|||
},
|
||||
task_context::RunnableRange,
|
||||
text_diff::text_diff,
|
||||
LanguageScope, Outline, OutlineConfig, RunnableCapture, RunnableTag, TextObject,
|
||||
TreeSitterOptions,
|
||||
};
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
use async_watch as watch;
|
||||
use clock::Lamport;
|
||||
pub use clock::ReplicaId;
|
||||
|
@ -66,7 +67,7 @@ pub use text::{
|
|||
use theme::{ActiveTheme as _, SyntaxTheme};
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
use util::RandomCharIter;
|
||||
use util::{debug_panic, maybe, RangeExt};
|
||||
use util::{RangeExt, debug_panic, maybe};
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub use {tree_sitter_rust, tree_sitter_typescript};
|
||||
|
@ -3742,47 +3743,49 @@ impl BufferSnapshot {
|
|||
|
||||
let mut captures = Vec::<(Range<usize>, TextObject)>::new();
|
||||
|
||||
iter::from_fn(move || loop {
|
||||
while let Some(capture) = captures.pop() {
|
||||
if capture.0.overlaps(&range) {
|
||||
return Some(capture);
|
||||
}
|
||||
}
|
||||
|
||||
let mat = matches.peek()?;
|
||||
|
||||
let Some(config) = configs[mat.grammar_index].as_ref() else {
|
||||
matches.advance();
|
||||
continue;
|
||||
};
|
||||
|
||||
for capture in mat.captures {
|
||||
let Some(ix) = config
|
||||
.text_objects_by_capture_ix
|
||||
.binary_search_by_key(&capture.index, |e| e.0)
|
||||
.ok()
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let text_object = config.text_objects_by_capture_ix[ix].1;
|
||||
let byte_range = capture.node.byte_range();
|
||||
|
||||
let mut found = false;
|
||||
for (range, existing) in captures.iter_mut() {
|
||||
if existing == &text_object {
|
||||
range.start = range.start.min(byte_range.start);
|
||||
range.end = range.end.max(byte_range.end);
|
||||
found = true;
|
||||
break;
|
||||
iter::from_fn(move || {
|
||||
loop {
|
||||
while let Some(capture) = captures.pop() {
|
||||
if capture.0.overlaps(&range) {
|
||||
return Some(capture);
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
captures.push((byte_range, text_object));
|
||||
}
|
||||
}
|
||||
let mat = matches.peek()?;
|
||||
|
||||
matches.advance();
|
||||
let Some(config) = configs[mat.grammar_index].as_ref() else {
|
||||
matches.advance();
|
||||
continue;
|
||||
};
|
||||
|
||||
for capture in mat.captures {
|
||||
let Some(ix) = config
|
||||
.text_objects_by_capture_ix
|
||||
.binary_search_by_key(&capture.index, |e| e.0)
|
||||
.ok()
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let text_object = config.text_objects_by_capture_ix[ix].1;
|
||||
let byte_range = capture.node.byte_range();
|
||||
|
||||
let mut found = false;
|
||||
for (range, existing) in captures.iter_mut() {
|
||||
if existing == &text_object {
|
||||
range.start = range.start.min(byte_range.start);
|
||||
range.end = range.end.max(byte_range.end);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
captures.push((byte_range, text_object));
|
||||
}
|
||||
}
|
||||
|
||||
matches.advance();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4092,11 +4095,7 @@ impl BufferSnapshot {
|
|||
.then(a.diagnostic.severity.cmp(&b.diagnostic.severity))
|
||||
// and stabilize order with group_id
|
||||
.then(a.diagnostic.group_id.cmp(&b.diagnostic.group_id));
|
||||
if reversed {
|
||||
cmp.reverse()
|
||||
} else {
|
||||
cmp
|
||||
}
|
||||
if reversed { cmp.reverse() } else { cmp }
|
||||
})?;
|
||||
iterators[next_ix]
|
||||
.next()
|
||||
|
@ -4699,22 +4698,24 @@ pub(crate) fn contiguous_ranges(
|
|||
) -> impl Iterator<Item = Range<u32>> {
|
||||
let mut values = values;
|
||||
let mut current_range: Option<Range<u32>> = None;
|
||||
std::iter::from_fn(move || loop {
|
||||
if let Some(value) = values.next() {
|
||||
if let Some(range) = &mut current_range {
|
||||
if value == range.end && range.len() < max_len {
|
||||
range.end += 1;
|
||||
continue;
|
||||
std::iter::from_fn(move || {
|
||||
loop {
|
||||
if let Some(value) = values.next() {
|
||||
if let Some(range) = &mut current_range {
|
||||
if value == range.end && range.len() < max_len {
|
||||
range.end += 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let prev_range = current_range.clone();
|
||||
current_range = Some(value..(value + 1));
|
||||
if prev_range.is_some() {
|
||||
return prev_range;
|
||||
let prev_range = current_range.clone();
|
||||
current_range = Some(value..(value + 1));
|
||||
if prev_range.is_some() {
|
||||
return prev_range;
|
||||
}
|
||||
} else {
|
||||
return current_range.take();
|
||||
}
|
||||
} else {
|
||||
return current_range.take();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use super::*;
|
||||
use crate::Buffer;
|
||||
use crate::language_settings::{
|
||||
AllLanguageSettings, AllLanguageSettingsContent, LanguageSettingsContent,
|
||||
};
|
||||
use crate::Buffer;
|
||||
use clock::ReplicaId;
|
||||
use collections::BTreeMap;
|
||||
use futures::FutureExt as _;
|
||||
|
@ -27,7 +27,7 @@ use text::{Point, ToPoint};
|
|||
use theme::ActiveTheme;
|
||||
use unindent::Unindent as _;
|
||||
use util::test::marked_text_offsets;
|
||||
use util::{assert_set_eq, post_inc, test::marked_text_ranges, RandomCharIter};
|
||||
use util::{RandomCharIter, assert_set_eq, post_inc, test::marked_text_ranges};
|
||||
|
||||
pub static TRAILING_WHITESPACE_REGEX: LazyLock<regex::Regex> = LazyLock::new(|| {
|
||||
RegexBuilder::new(r"[ \t]+$")
|
||||
|
@ -156,12 +156,14 @@ async fn test_first_line_pattern(cx: &mut TestAppContext) {
|
|||
..Default::default()
|
||||
});
|
||||
|
||||
assert!(cx
|
||||
.read(|cx| languages.language_for_file(&file("the/script"), None, cx))
|
||||
.is_none());
|
||||
assert!(cx
|
||||
.read(|cx| languages.language_for_file(&file("the/script"), Some(&"nothing".into()), cx))
|
||||
.is_none());
|
||||
assert!(
|
||||
cx.read(|cx| languages.language_for_file(&file("the/script"), None, cx))
|
||||
.is_none()
|
||||
);
|
||||
assert!(
|
||||
cx.read(|cx| languages.language_for_file(&file("the/script"), Some(&"nothing".into()), cx))
|
||||
.is_none()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
cx.read(|cx| languages.language_for_file(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{range_to_lsp, Diagnostic};
|
||||
use crate::{Diagnostic, range_to_lsp};
|
||||
use anyhow::Result;
|
||||
use collections::HashMap;
|
||||
use lsp::LanguageServerId;
|
||||
|
|
|
@ -24,7 +24,7 @@ pub mod buffer_tests;
|
|||
|
||||
pub use crate::language_settings::EditPredictionsMode;
|
||||
use crate::language_settings::SoftWrap;
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
use async_trait::async_trait;
|
||||
use collections::{HashMap, HashSet};
|
||||
use fs::Fs;
|
||||
|
@ -38,11 +38,11 @@ pub use manifest::{ManifestName, ManifestProvider, ManifestQuery};
|
|||
use parking_lot::Mutex;
|
||||
use regex::Regex;
|
||||
use schemars::{
|
||||
JsonSchema,
|
||||
r#gen::SchemaGenerator,
|
||||
schema::{InstanceType, Schema, SchemaObject},
|
||||
JsonSchema,
|
||||
};
|
||||
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer, de};
|
||||
use serde_json::Value;
|
||||
use settings::WorktreeId;
|
||||
use smol::future::FutureExt as _;
|
||||
|
@ -57,18 +57,18 @@ use std::{
|
|||
pin::Pin,
|
||||
str,
|
||||
sync::{
|
||||
atomic::{AtomicU64, AtomicUsize, Ordering::SeqCst},
|
||||
Arc, LazyLock,
|
||||
atomic::{AtomicU64, AtomicUsize, Ordering::SeqCst},
|
||||
},
|
||||
};
|
||||
use std::{num::NonZeroU32, sync::OnceLock};
|
||||
use syntax_map::{QueryCursorHandle, SyntaxSnapshot};
|
||||
use task::RunnableTag;
|
||||
pub use task_context::{ContextProvider, RunnableRange};
|
||||
pub use text_diff::{line_diff, text_diff, text_diff_with_options, unified_diff, DiffOptions};
|
||||
pub use text_diff::{DiffOptions, line_diff, text_diff, text_diff_with_options, unified_diff};
|
||||
use theme::SyntaxTheme;
|
||||
pub use toolchain::{LanguageToolchainStore, Toolchain, ToolchainList, ToolchainLister};
|
||||
use tree_sitter::{self, wasmtime, Query, QueryCursor, WasmStore};
|
||||
use tree_sitter::{self, Query, QueryCursor, WasmStore, wasmtime};
|
||||
use util::serde::default_true;
|
||||
|
||||
pub use buffer::Operation;
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
use crate::{
|
||||
CachedLspAdapter, File, Language, LanguageConfig, LanguageId, LanguageMatcher,
|
||||
LanguageServerName, LspAdapter, PLAIN_TEXT, ToolchainLister,
|
||||
language_settings::{
|
||||
all_language_settings, AllLanguageSettingsContent, LanguageSettingsContent,
|
||||
AllLanguageSettingsContent, LanguageSettingsContent, all_language_settings,
|
||||
},
|
||||
task_context::ContextProvider,
|
||||
with_parser, CachedLspAdapter, File, Language, LanguageConfig, LanguageId, LanguageMatcher,
|
||||
LanguageServerName, LspAdapter, ToolchainLister, PLAIN_TEXT,
|
||||
with_parser,
|
||||
};
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use collections::{hash_map, HashMap, HashSet};
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
use collections::{HashMap, HashSet, hash_map};
|
||||
|
||||
use futures::{
|
||||
channel::{mpsc, oneshot},
|
||||
Future,
|
||||
channel::{mpsc, oneshot},
|
||||
};
|
||||
use globset::GlobSet;
|
||||
use gpui::{App, BackgroundExecutor, SharedString};
|
||||
|
@ -31,7 +32,7 @@ use sum_tree::Bias;
|
|||
use text::{Point, Rope};
|
||||
use theme::Theme;
|
||||
use unicase::UniCase;
|
||||
use util::{maybe, post_inc, ResultExt};
|
||||
use util::{ResultExt, maybe, post_inc};
|
||||
|
||||
#[derive(
|
||||
Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, JsonSchema,
|
||||
|
|
|
@ -5,23 +5,23 @@ use anyhow::Result;
|
|||
use collections::{HashMap, HashSet};
|
||||
use core::slice;
|
||||
use ec4rs::{
|
||||
property::{FinalNewline, IndentSize, IndentStyle, TabWidth, TrimTrailingWs},
|
||||
Properties as EditorconfigProperties,
|
||||
property::{FinalNewline, IndentSize, IndentStyle, TabWidth, TrimTrailingWs},
|
||||
};
|
||||
use globset::{Glob, GlobMatcher, GlobSet, GlobSetBuilder};
|
||||
use gpui::{App, Modifiers};
|
||||
use itertools::{Either, Itertools};
|
||||
use schemars::{
|
||||
schema::{InstanceType, ObjectValidation, Schema, SchemaObject, SingleOrVec},
|
||||
JsonSchema,
|
||||
schema::{InstanceType, ObjectValidation, Schema, SchemaObject, SingleOrVec},
|
||||
};
|
||||
use serde::{
|
||||
de::{self, IntoDeserializer, MapAccess, SeqAccess, Visitor},
|
||||
Deserialize, Deserializer, Serialize,
|
||||
de::{self, IntoDeserializer, MapAccess, SeqAccess, Visitor},
|
||||
};
|
||||
use serde_json::Value;
|
||||
use settings::{
|
||||
add_references_to_properties, Settings, SettingsLocation, SettingsSources, SettingsStore,
|
||||
Settings, SettingsLocation, SettingsSources, SettingsStore, add_references_to_properties,
|
||||
};
|
||||
use std::{borrow::Cow, num::NonZeroU32, path::Path, sync::Arc};
|
||||
use util::serde::default_true;
|
||||
|
@ -1308,9 +1308,11 @@ impl settings::Settings for AllLanguageSettings {
|
|||
|
||||
// Create a schema for a 'languages overrides' object, associating editor
|
||||
// settings with specific languages.
|
||||
assert!(root_schema
|
||||
.definitions
|
||||
.contains_key("LanguageSettingsContent"));
|
||||
assert!(
|
||||
root_schema
|
||||
.definitions
|
||||
.contains_key("LanguageSettingsContent")
|
||||
);
|
||||
|
||||
let languages_object_schema = SchemaObject {
|
||||
instance_type: Some(InstanceType::Object.into()),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Handles conversions of `language` items to and from the [`rpc`] protocol.
|
||||
|
||||
use crate::{diagnostic_set::DiagnosticEntry, CursorShape, Diagnostic};
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use crate::{CursorShape, Diagnostic, diagnostic_set::DiagnosticEntry};
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
use clock::ReplicaId;
|
||||
use lsp::{DiagnosticSeverity, LanguageServerId};
|
||||
use rpc::proto;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
mod syntax_map_tests;
|
||||
|
||||
use crate::{
|
||||
with_parser, Grammar, InjectionConfig, Language, LanguageId, LanguageRegistry, QUERY_CURSORS,
|
||||
Grammar, InjectionConfig, Language, LanguageId, LanguageRegistry, QUERY_CURSORS, with_parser,
|
||||
};
|
||||
use collections::HashMap;
|
||||
use futures::FutureExt;
|
||||
|
@ -1890,7 +1890,7 @@ impl fmt::Debug for LogChangedRegions<'_> {
|
|||
f.debug_list()
|
||||
.entries(
|
||||
self.0
|
||||
.0
|
||||
.0
|
||||
.iter()
|
||||
.map(|region| LogAnchorRange(®ion.range, self.1)),
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::*;
|
||||
use crate::{
|
||||
buffer_tests::{markdown_inline_lang, markdown_lang},
|
||||
LanguageConfig, LanguageMatcher,
|
||||
buffer_tests::{markdown_inline_lang, markdown_lang},
|
||||
};
|
||||
use gpui::App;
|
||||
use rand::rngs::StdRng;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use crate::{CharClassifier, CharKind, LanguageScope};
|
||||
use imara_diff::{
|
||||
diff,
|
||||
Algorithm, UnifiedDiffBuilder, diff,
|
||||
intern::{InternedInput, Token},
|
||||
sources::lines_with_terminator,
|
||||
Algorithm, UnifiedDiffBuilder,
|
||||
};
|
||||
use std::{iter, ops::Range, sync::Arc};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue