Skip to content

Commit ea22d24

Browse files
committed
Auto merge of #14499 - DropDemBits:drive-by-fixmes, r=Veykril
minor: Fix some simple FIXMEs Each FIXME fix has been split into its own commit, since they're all pretty independent changes. (Forgot to open a PR for this a few days ago, oops)
2 parents ec80303 + 0a144f7 commit ea22d24

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

crates/ide-assists/src/tests/sourcegen.rs

-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ impl Assist {
9090
let comment_blocks = sourcegen::CommentBlock::extract("Assist", &text);
9191

9292
for block in comment_blocks {
93-
// FIXME: doesn't support blank lines yet, need to tweak
94-
// `extract_comment_blocks` for that.
9593
let id = block.id;
9694
assert!(
9795
id.chars().all(|it| it.is_ascii_lowercase() || it == '_'),

crates/ide/src/syntax_highlighting/highlight.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -675,14 +675,12 @@ fn is_consumed_lvalue(node: &SyntaxNode, local: &hir::Local, db: &RootDatabase)
675675

676676
/// Returns true if the parent nodes of `node` all match the `SyntaxKind`s in `kinds` exactly.
677677
fn parents_match(mut node: NodeOrToken<SyntaxNode, SyntaxToken>, mut kinds: &[SyntaxKind]) -> bool {
678-
while let (Some(parent), [kind, rest @ ..]) = (&node.parent(), kinds) {
678+
while let (Some(parent), [kind, rest @ ..]) = (node.parent(), kinds) {
679679
if parent.kind() != *kind {
680680
return false;
681681
}
682682

683-
// FIXME: Would be nice to get parent out of the match, but binding by-move and by-value
684-
// in the same pattern is unstable: rust-lang/rust#68354.
685-
node = node.parent().unwrap().into();
683+
node = parent.into();
686684
kinds = rest;
687685
}
688686

crates/sourcegen/src/lib.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,19 @@ impl CommentBlock {
5858
assert!(tag.starts_with(char::is_uppercase));
5959

6060
let tag = format!("{tag}:");
61-
// Would be nice if we had `.retain_mut` here!
62-
CommentBlock::extract_untagged(text)
63-
.into_iter()
64-
.filter_map(|mut block| {
65-
let first = block.contents.remove(0);
66-
first.strip_prefix(&tag).map(|id| {
67-
if block.is_doc {
68-
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
69-
}
61+
let mut blocks = CommentBlock::extract_untagged(text);
62+
blocks.retain_mut(|block| {
63+
let first = block.contents.remove(0);
64+
let Some(id) = first.strip_prefix(&tag) else { return false; };
65+
66+
if block.is_doc {
67+
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
68+
}
7069

71-
block.id = id.trim().to_string();
72-
block
73-
})
74-
})
75-
.collect()
70+
block.id = id.trim().to_string();
71+
true
72+
});
73+
blocks
7674
}
7775

7876
pub fn extract_untagged(text: &str) -> Vec<CommentBlock> {

0 commit comments

Comments
 (0)