chore: Prepare for Rust edition bump to 2024 (without autofix) (#27791)
Successor to #27779 - in this PR I've applied changes manually, without futzing with if let lifetimes at all. Release Notes: - N/A
This commit is contained in:
parent
d51aa2ffb0
commit
0729d24d77
162 changed files with 2333 additions and 1937 deletions
|
@ -989,7 +989,7 @@ impl Buffer {
|
|||
language: Option<Arc<Language>>,
|
||||
language_registry: Option<Arc<LanguageRegistry>>,
|
||||
cx: &mut App,
|
||||
) -> impl Future<Output = BufferSnapshot> {
|
||||
) -> impl Future<Output = BufferSnapshot> + use<> {
|
||||
let entity_id = cx.reserve_entity::<Self>().entity_id();
|
||||
let buffer_id = entity_id.as_non_zero_u64().into();
|
||||
async move {
|
||||
|
@ -1587,7 +1587,9 @@ impl Buffer {
|
|||
}
|
||||
}
|
||||
|
||||
fn compute_autoindents(&self) -> Option<impl Future<Output = BTreeMap<u32, IndentSize>>> {
|
||||
fn compute_autoindents(
|
||||
&self,
|
||||
) -> Option<impl Future<Output = BTreeMap<u32, IndentSize>> + use<>> {
|
||||
let max_rows_between_yields = 100;
|
||||
let snapshot = self.snapshot();
|
||||
if snapshot.syntax.is_empty() || self.autoindent_requests.is_empty() {
|
||||
|
@ -2082,23 +2084,26 @@ impl Buffer {
|
|||
}
|
||||
|
||||
/// Waits for the buffer to receive operations with the given timestamps.
|
||||
pub fn wait_for_edits(
|
||||
pub fn wait_for_edits<It: IntoIterator<Item = clock::Lamport>>(
|
||||
&mut self,
|
||||
edit_ids: impl IntoIterator<Item = clock::Lamport>,
|
||||
) -> impl Future<Output = Result<()>> {
|
||||
edit_ids: It,
|
||||
) -> impl Future<Output = Result<()>> + use<It> {
|
||||
self.text.wait_for_edits(edit_ids)
|
||||
}
|
||||
|
||||
/// Waits for the buffer to receive the operations necessary for resolving the given anchors.
|
||||
pub fn wait_for_anchors(
|
||||
pub fn wait_for_anchors<It: IntoIterator<Item = Anchor>>(
|
||||
&mut self,
|
||||
anchors: impl IntoIterator<Item = Anchor>,
|
||||
) -> impl 'static + Future<Output = Result<()>> {
|
||||
anchors: It,
|
||||
) -> impl 'static + Future<Output = Result<()>> + use<It> {
|
||||
self.text.wait_for_anchors(anchors)
|
||||
}
|
||||
|
||||
/// Waits for the buffer to receive operations up to the given version.
|
||||
pub fn wait_for_version(&mut self, version: clock::Global) -> impl Future<Output = Result<()>> {
|
||||
pub fn wait_for_version(
|
||||
&mut self,
|
||||
version: clock::Global,
|
||||
) -> impl Future<Output = Result<()>> + use<> {
|
||||
self.text.wait_for_version(version)
|
||||
}
|
||||
|
||||
|
@ -3916,91 +3921,93 @@ impl BufferSnapshot {
|
|||
.map(|grammar| grammar.runnable_config.as_ref())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
iter::from_fn(move || loop {
|
||||
let mat = syntax_matches.peek()?;
|
||||
iter::from_fn(move || {
|
||||
loop {
|
||||
let mat = syntax_matches.peek()?;
|
||||
|
||||
let test_range = test_configs[mat.grammar_index].and_then(|test_configs| {
|
||||
let mut run_range = None;
|
||||
let full_range = mat.captures.iter().fold(
|
||||
Range {
|
||||
start: usize::MAX,
|
||||
end: 0,
|
||||
},
|
||||
|mut acc, next| {
|
||||
let byte_range = next.node.byte_range();
|
||||
if acc.start > byte_range.start {
|
||||
acc.start = byte_range.start;
|
||||
}
|
||||
if acc.end < byte_range.end {
|
||||
acc.end = byte_range.end;
|
||||
}
|
||||
acc
|
||||
},
|
||||
);
|
||||
if full_range.start > full_range.end {
|
||||
// We did not find a full spanning range of this match.
|
||||
return None;
|
||||
let test_range = test_configs[mat.grammar_index].and_then(|test_configs| {
|
||||
let mut run_range = None;
|
||||
let full_range = mat.captures.iter().fold(
|
||||
Range {
|
||||
start: usize::MAX,
|
||||
end: 0,
|
||||
},
|
||||
|mut acc, next| {
|
||||
let byte_range = next.node.byte_range();
|
||||
if acc.start > byte_range.start {
|
||||
acc.start = byte_range.start;
|
||||
}
|
||||
if acc.end < byte_range.end {
|
||||
acc.end = byte_range.end;
|
||||
}
|
||||
acc
|
||||
},
|
||||
);
|
||||
if full_range.start > full_range.end {
|
||||
// We did not find a full spanning range of this match.
|
||||
return None;
|
||||
}
|
||||
let extra_captures: SmallVec<[_; 1]> =
|
||||
SmallVec::from_iter(mat.captures.iter().filter_map(|capture| {
|
||||
test_configs
|
||||
.extra_captures
|
||||
.get(capture.index as usize)
|
||||
.cloned()
|
||||
.and_then(|tag_name| match tag_name {
|
||||
RunnableCapture::Named(name) => {
|
||||
Some((capture.node.byte_range(), name))
|
||||
}
|
||||
RunnableCapture::Run => {
|
||||
let _ = run_range.insert(capture.node.byte_range());
|
||||
None
|
||||
}
|
||||
})
|
||||
}));
|
||||
let run_range = run_range?;
|
||||
let tags = test_configs
|
||||
.query
|
||||
.property_settings(mat.pattern_index)
|
||||
.iter()
|
||||
.filter_map(|property| {
|
||||
if *property.key == *"tag" {
|
||||
property
|
||||
.value
|
||||
.as_ref()
|
||||
.map(|value| RunnableTag(value.to_string().into()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let extra_captures = extra_captures
|
||||
.into_iter()
|
||||
.map(|(range, name)| {
|
||||
(
|
||||
name.to_string(),
|
||||
self.text_for_range(range.clone()).collect::<String>(),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
// All tags should have the same range.
|
||||
Some(RunnableRange {
|
||||
run_range,
|
||||
full_range,
|
||||
runnable: Runnable {
|
||||
tags,
|
||||
language: mat.language,
|
||||
buffer: self.remote_id(),
|
||||
},
|
||||
extra_captures,
|
||||
buffer_id: self.remote_id(),
|
||||
})
|
||||
});
|
||||
|
||||
syntax_matches.advance();
|
||||
if test_range.is_some() {
|
||||
// It's fine for us to short-circuit on .peek()? returning None. We don't want to return None from this iter if we
|
||||
// had a capture that did not contain a run marker, hence we'll just loop around for the next capture.
|
||||
return test_range;
|
||||
}
|
||||
let extra_captures: SmallVec<[_; 1]> =
|
||||
SmallVec::from_iter(mat.captures.iter().filter_map(|capture| {
|
||||
test_configs
|
||||
.extra_captures
|
||||
.get(capture.index as usize)
|
||||
.cloned()
|
||||
.and_then(|tag_name| match tag_name {
|
||||
RunnableCapture::Named(name) => {
|
||||
Some((capture.node.byte_range(), name))
|
||||
}
|
||||
RunnableCapture::Run => {
|
||||
let _ = run_range.insert(capture.node.byte_range());
|
||||
None
|
||||
}
|
||||
})
|
||||
}));
|
||||
let run_range = run_range?;
|
||||
let tags = test_configs
|
||||
.query
|
||||
.property_settings(mat.pattern_index)
|
||||
.iter()
|
||||
.filter_map(|property| {
|
||||
if *property.key == *"tag" {
|
||||
property
|
||||
.value
|
||||
.as_ref()
|
||||
.map(|value| RunnableTag(value.to_string().into()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let extra_captures = extra_captures
|
||||
.into_iter()
|
||||
.map(|(range, name)| {
|
||||
(
|
||||
name.to_string(),
|
||||
self.text_for_range(range.clone()).collect::<String>(),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
// All tags should have the same range.
|
||||
Some(RunnableRange {
|
||||
run_range,
|
||||
full_range,
|
||||
runnable: Runnable {
|
||||
tags,
|
||||
language: mat.language,
|
||||
buffer: self.remote_id(),
|
||||
},
|
||||
extra_captures,
|
||||
buffer_id: self.remote_id(),
|
||||
})
|
||||
});
|
||||
|
||||
syntax_matches.advance();
|
||||
if test_range.is_some() {
|
||||
// It's fine for us to short-circuit on .peek()? returning None. We don't want to return None from this iter if we
|
||||
// had a capture that did not contain a run marker, hence we'll just loop around for the next capture.
|
||||
return test_range;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -4352,7 +4359,10 @@ impl<'a> BufferChunks<'a> {
|
|||
} else {
|
||||
// We cannot obtain new highlights for a language-aware buffer iterator, as we don't have a buffer snapshot.
|
||||
// Seeking such BufferChunks is not supported.
|
||||
debug_assert!(false, "Attempted to seek on a language-aware buffer iterator without associated buffer snapshot");
|
||||
debug_assert!(
|
||||
false,
|
||||
"Attempted to seek on a language-aware buffer iterator without associated buffer snapshot"
|
||||
);
|
||||
}
|
||||
|
||||
highlights.captures.set_byte_range(self.range.clone());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue