Merge pull request #19511 from snprajwal/fixmes

chore: clean up some FIXMEs
This commit is contained in:
Lukas Wirth 2025-04-07 10:30:46 +00:00 committed by GitHub
commit 33c3f67764
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 47 deletions

View File

@ -210,8 +210,11 @@ fn expand_subtree(
} }
Op::Ignore { name, id } => { Op::Ignore { name, id } => {
// Expand the variable, but ignore the result. This registers the repetition count. // Expand the variable, but ignore the result. This registers the repetition count.
// FIXME: Any emitted errors are dropped. let e = ctx.bindings.get_fragment(name, *id, &mut ctx.nesting, marker).err();
let _ = ctx.bindings.get_fragment(name, *id, &mut ctx.nesting, marker); // FIXME: The error gets dropped if there were any previous errors.
// This should be reworked in a way where the errors can be combined
// and reported rather than storing the first error encountered.
err = err.or(e);
} }
Op::Index { depth } => { Op::Index { depth } => {
let index = let index =
@ -239,9 +242,7 @@ fn expand_subtree(
let mut binding = match ctx.bindings.get(name, ctx.call_site) { let mut binding = match ctx.bindings.get(name, ctx.call_site) {
Ok(b) => b, Ok(b) => b,
Err(e) => { Err(e) => {
if err.is_none() { err = err.or(Some(e));
err = Some(e);
}
continue; continue;
} }
}; };

View File

@ -378,7 +378,7 @@ mod tests {
use expect_test::expect; use expect_test::expect;
use crate::{ use crate::{
AstNode, SyntaxKind, AstNode,
ast::{self, make, syntax_factory::SyntaxFactory}, ast::{self, make, syntax_factory::SyntaxFactory},
}; };
@ -624,20 +624,12 @@ mod tests {
} }
if let Some(tail) = parent_fn.body().unwrap().tail_expr() { if let Some(tail) = parent_fn.body().unwrap().tail_expr() {
// FIXME: We do this because `xtask tidy` will not allow us to have trailing whitespace in the expect string.
if let Some(SyntaxElement::Token(token)) = tail.syntax().prev_sibling_or_token() {
if let SyntaxKind::WHITESPACE = token.kind() {
editor.delete(token);
}
}
editor.delete(tail.syntax().clone()); editor.delete(tail.syntax().clone());
} }
let edit = editor.finish(); let edit = editor.finish();
let expect = expect![[r#" let expect = expect![["fn it() {\n \n}"]];
fn it() {
}"#]];
expect.assert_eq(&edit.new_root.to_string()); expect.assert_eq(&edit.new_root.to_string());
} }
} }

View File

@ -414,9 +414,8 @@ fn generate_nodes(kinds: KindsSrc, grammar: &AstSrc) -> String {
.map(|kind| to_pascal_case(kind)) .map(|kind| to_pascal_case(kind))
.filter(|name| !defined_nodes.iter().any(|&it| it == name)) .filter(|name| !defined_nodes.iter().any(|&it| it == name))
{ {
drop(node) eprintln!("Warning: node {} not defined in AST source", node);
// FIXME: restore this drop(node);
// eprintln!("Warning: node {} not defined in ast source", node);
} }
let ast = quote! { let ast = quote! {

View File

@ -126,31 +126,28 @@ fn check_cargo_toml(path: &Path, text: String) {
} }
fn check_licenses(sh: &Shell) { fn check_licenses(sh: &Shell) {
let expected = " const EXPECTED: [&str; 20] = [
(MIT OR Apache-2.0) AND Unicode-3.0 "(MIT OR Apache-2.0) AND Unicode-3.0",
0BSD OR MIT OR Apache-2.0 "0BSD OR MIT OR Apache-2.0",
Apache-2.0 "Apache-2.0",
Apache-2.0 OR BSL-1.0 "Apache-2.0 OR BSL-1.0",
Apache-2.0 OR MIT "Apache-2.0 OR MIT",
Apache-2.0 WITH LLVM-exception "Apache-2.0 WITH LLVM-exception",
Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
Apache-2.0/MIT "Apache-2.0/MIT",
CC0-1.0 "CC0-1.0",
ISC "ISC",
MIT "MIT",
MIT / Apache-2.0 "MIT / Apache-2.0",
MIT OR Apache-2.0 "MIT OR Apache-2.0",
MIT OR Zlib OR Apache-2.0 "MIT OR Zlib OR Apache-2.0",
MIT/Apache-2.0 "MIT/Apache-2.0",
MPL-2.0 "MPL-2.0",
Unicode-3.0 "Unicode-3.0",
Unlicense OR MIT "Unlicense OR MIT",
Unlicense/MIT "Unlicense/MIT",
Zlib "Zlib",
" ];
.lines()
.filter(|it| !it.is_empty())
.collect::<Vec<_>>();
let meta = cmd!(sh, "cargo metadata --format-version 1").read().unwrap(); let meta = cmd!(sh, "cargo metadata --format-version 1").read().unwrap();
let mut licenses = meta let mut licenses = meta
@ -161,18 +158,18 @@ Zlib
.collect::<Vec<_>>(); .collect::<Vec<_>>();
licenses.sort_unstable(); licenses.sort_unstable();
licenses.dedup(); licenses.dedup();
if licenses != expected { if licenses != EXPECTED {
let mut diff = String::new(); let mut diff = String::new();
diff.push_str("New Licenses:\n"); diff.push_str("New Licenses:\n");
for &l in licenses.iter() { for &l in licenses.iter() {
if !expected.contains(&l) { if !EXPECTED.contains(&l) {
diff += &format!(" {l}\n") diff += &format!(" {l}\n")
} }
} }
diff.push_str("\nMissing Licenses:\n"); diff.push_str("\nMissing Licenses:\n");
for &l in expected.iter() { for l in EXPECTED {
if !licenses.contains(&l) { if !licenses.contains(&l) {
diff += &format!(" {l}\n") diff += &format!(" {l}\n")
} }
@ -180,7 +177,7 @@ Zlib
panic!("different set of licenses!\n{diff}"); panic!("different set of licenses!\n{diff}");
} }
assert_eq!(licenses, expected); assert_eq!(licenses, EXPECTED);
} }
fn check_test_attrs(path: &Path, text: &str) { fn check_test_attrs(path: &Path, text: &str) {