Skip to content

Commit dfe13e5

Browse files
authored
Merge pull request rust-lang#19511 from snprajwal/fixmes
chore: clean up some FIXMEs
2 parents b91731c + e9bad9c commit dfe13e5

File tree

4 files changed

+36
-47
lines changed

4 files changed

+36
-47
lines changed

src/tools/rust-analyzer/crates/mbe/src/expander/transcriber.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,11 @@ fn expand_subtree(
210210
}
211211
Op::Ignore { name, id } => {
212212
// Expand the variable, but ignore the result. This registers the repetition count.
213-
// FIXME: Any emitted errors are dropped.
214-
let _ = ctx.bindings.get_fragment(name, *id, &mut ctx.nesting, marker);
213+
let e = ctx.bindings.get_fragment(name, *id, &mut ctx.nesting, marker).err();
214+
// FIXME: The error gets dropped if there were any previous errors.
215+
// This should be reworked in a way where the errors can be combined
216+
// and reported rather than storing the first error encountered.
217+
err = err.or(e);
215218
}
216219
Op::Index { depth } => {
217220
let index =
@@ -239,9 +242,7 @@ fn expand_subtree(
239242
let mut binding = match ctx.bindings.get(name, ctx.call_site) {
240243
Ok(b) => b,
241244
Err(e) => {
242-
if err.is_none() {
243-
err = Some(e);
244-
}
245+
err = err.or(Some(e));
245246
continue;
246247
}
247248
};

src/tools/rust-analyzer/crates/syntax/src/syntax_editor.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ mod tests {
378378
use expect_test::expect;
379379

380380
use crate::{
381-
AstNode, SyntaxKind,
381+
AstNode,
382382
ast::{self, make, syntax_factory::SyntaxFactory},
383383
};
384384

@@ -624,20 +624,12 @@ mod tests {
624624
}
625625

626626
if let Some(tail) = parent_fn.body().unwrap().tail_expr() {
627-
// FIXME: We do this because `xtask tidy` will not allow us to have trailing whitespace in the expect string.
628-
if let Some(SyntaxElement::Token(token)) = tail.syntax().prev_sibling_or_token() {
629-
if let SyntaxKind::WHITESPACE = token.kind() {
630-
editor.delete(token);
631-
}
632-
}
633627
editor.delete(tail.syntax().clone());
634628
}
635629

636630
let edit = editor.finish();
637631

638-
let expect = expect![[r#"
639-
fn it() {
640-
}"#]];
632+
let expect = expect![["fn it() {\n \n}"]];
641633
expect.assert_eq(&edit.new_root.to_string());
642634
}
643635
}

src/tools/rust-analyzer/xtask/src/codegen/grammar.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,8 @@ fn generate_nodes(kinds: KindsSrc, grammar: &AstSrc) -> String {
414414
.map(|kind| to_pascal_case(kind))
415415
.filter(|name| !defined_nodes.iter().any(|&it| it == name))
416416
{
417-
drop(node)
418-
// FIXME: restore this
419-
// eprintln!("Warning: node {} not defined in ast source", node);
417+
eprintln!("Warning: node {} not defined in AST source", node);
418+
drop(node);
420419
}
421420

422421
let ast = quote! {

src/tools/rust-analyzer/xtask/src/tidy.rs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -126,31 +126,28 @@ fn check_cargo_toml(path: &Path, text: String) {
126126
}
127127

128128
fn check_licenses(sh: &Shell) {
129-
let expected = "
130-
(MIT OR Apache-2.0) AND Unicode-3.0
131-
0BSD OR MIT OR Apache-2.0
132-
Apache-2.0
133-
Apache-2.0 OR BSL-1.0
134-
Apache-2.0 OR MIT
135-
Apache-2.0 WITH LLVM-exception
136-
Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
137-
Apache-2.0/MIT
138-
CC0-1.0
139-
ISC
140-
MIT
141-
MIT / Apache-2.0
142-
MIT OR Apache-2.0
143-
MIT OR Zlib OR Apache-2.0
144-
MIT/Apache-2.0
145-
MPL-2.0
146-
Unicode-3.0
147-
Unlicense OR MIT
148-
Unlicense/MIT
149-
Zlib
150-
"
151-
.lines()
152-
.filter(|it| !it.is_empty())
153-
.collect::<Vec<_>>();
129+
const EXPECTED: [&str; 20] = [
130+
"(MIT OR Apache-2.0) AND Unicode-3.0",
131+
"0BSD OR MIT OR Apache-2.0",
132+
"Apache-2.0",
133+
"Apache-2.0 OR BSL-1.0",
134+
"Apache-2.0 OR MIT",
135+
"Apache-2.0 WITH LLVM-exception",
136+
"Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
137+
"Apache-2.0/MIT",
138+
"CC0-1.0",
139+
"ISC",
140+
"MIT",
141+
"MIT / Apache-2.0",
142+
"MIT OR Apache-2.0",
143+
"MIT OR Zlib OR Apache-2.0",
144+
"MIT/Apache-2.0",
145+
"MPL-2.0",
146+
"Unicode-3.0",
147+
"Unlicense OR MIT",
148+
"Unlicense/MIT",
149+
"Zlib",
150+
];
154151

155152
let meta = cmd!(sh, "cargo metadata --format-version 1").read().unwrap();
156153
let mut licenses = meta
@@ -161,26 +158,26 @@ Zlib
161158
.collect::<Vec<_>>();
162159
licenses.sort_unstable();
163160
licenses.dedup();
164-
if licenses != expected {
161+
if licenses != EXPECTED {
165162
let mut diff = String::new();
166163

167164
diff.push_str("New Licenses:\n");
168165
for &l in licenses.iter() {
169-
if !expected.contains(&l) {
166+
if !EXPECTED.contains(&l) {
170167
diff += &format!(" {l}\n")
171168
}
172169
}
173170

174171
diff.push_str("\nMissing Licenses:\n");
175-
for &l in expected.iter() {
172+
for l in EXPECTED {
176173
if !licenses.contains(&l) {
177174
diff += &format!(" {l}\n")
178175
}
179176
}
180177

181178
panic!("different set of licenses!\n{diff}");
182179
}
183-
assert_eq!(licenses, expected);
180+
assert_eq!(licenses, EXPECTED);
184181
}
185182

186183
fn check_test_attrs(path: &Path, text: &str) {

0 commit comments

Comments
 (0)