`syn::Result::ok` silently discards errors
- Dominant language
- Rust
- Stars
- 633
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
In my attempt to migrate this crate away from the abandoned `proc-macro-error` crate I discovered [these usages of `syn::Result::ok`](https://github.com/search?q=repo%3Afrondeus%2Ftest-case%20%22.ok()%22&type=code) were causing test failures with this diff applied:
```diff
diff --git a/crates/test-case-core/src/complex_expr.rs b/crates/test-case-core/src/complex_expr.rs
index e708f2e..2a4334e 100644
--- a/crates/test-case-core/src/complex_expr.rs
+++ b/crates/test-case-core/src/complex_expr.rs
@@ -323,11 +323,11 @@ impl ComplexTestCase {
expected_regex: input.parse()?,
})
} else {
- proc_macro_error::abort!(input.span(), "'with-regex' feature is required to use 'matches-regex' keyword");
+ return Err(input.error("'with-regex' feature is required to use 'matches-regex' keyword"));
}
}
} else {
- proc_macro_error::abort!(input.span(), "cannot parse complex expression")
+ return Err(input.error("cannot parse complex expression"));
})
}
}
```
I realize that these `.ok()` calls are used in cases where expressions and comments are optional, but it would be better to peek and avoid errors so that these `.ok()`s can be removed to allow the change above.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.