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)
This commit is contained in:
bors 2023-04-05 20:42:55 +00:00
commit ea22d245b6
3 changed files with 14 additions and 20 deletions

View File

@ -90,8 +90,6 @@ impl Assist {
let comment_blocks = sourcegen::CommentBlock::extract("Assist", &text); let comment_blocks = sourcegen::CommentBlock::extract("Assist", &text);
for block in comment_blocks { for block in comment_blocks {
// FIXME: doesn't support blank lines yet, need to tweak
// `extract_comment_blocks` for that.
let id = block.id; let id = block.id;
assert!( assert!(
id.chars().all(|it| it.is_ascii_lowercase() || it == '_'), id.chars().all(|it| it.is_ascii_lowercase() || it == '_'),

View File

@ -675,14 +675,12 @@ fn is_consumed_lvalue(node: &SyntaxNode, local: &hir::Local, db: &RootDatabase)
/// Returns true if the parent nodes of `node` all match the `SyntaxKind`s in `kinds` exactly. /// Returns true if the parent nodes of `node` all match the `SyntaxKind`s in `kinds` exactly.
fn parents_match(mut node: NodeOrToken<SyntaxNode, SyntaxToken>, mut kinds: &[SyntaxKind]) -> bool { fn parents_match(mut node: NodeOrToken<SyntaxNode, SyntaxToken>, mut kinds: &[SyntaxKind]) -> bool {
while let (Some(parent), [kind, rest @ ..]) = (&node.parent(), kinds) { while let (Some(parent), [kind, rest @ ..]) = (node.parent(), kinds) {
if parent.kind() != *kind { if parent.kind() != *kind {
return false; return false;
} }
// FIXME: Would be nice to get parent out of the match, but binding by-move and by-value node = parent.into();
// in the same pattern is unstable: rust-lang/rust#68354.
node = node.parent().unwrap().into();
kinds = rest; kinds = rest;
} }

View File

@ -58,21 +58,19 @@ impl CommentBlock {
assert!(tag.starts_with(char::is_uppercase)); assert!(tag.starts_with(char::is_uppercase));
let tag = format!("{tag}:"); let tag = format!("{tag}:");
// Would be nice if we had `.retain_mut` here! let mut blocks = CommentBlock::extract_untagged(text);
CommentBlock::extract_untagged(text) blocks.retain_mut(|block| {
.into_iter() let first = block.contents.remove(0);
.filter_map(|mut block| { let Some(id) = first.strip_prefix(&tag) else { return false; };
let first = block.contents.remove(0);
first.strip_prefix(&tag).map(|id| {
if block.is_doc {
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
}
block.id = id.trim().to_string(); if block.is_doc {
block panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
}) }
})
.collect() block.id = id.trim().to_string();
true
});
blocks
} }
pub fn extract_untagged(text: &str) -> Vec<CommentBlock> { pub fn extract_untagged(text: &str) -> Vec<CommentBlock> {