Skip to content

Commit

Permalink
Iterate over all elements of Path when making sure timeout is not…
Browse files Browse the repository at this point in the history
… used twice

This fixes code completion inside intellij-rust and rust-analyzer when using another proc macro with tests, like `#[tokio::test]`
  • Loading branch information
mati865 authored and becheran committed Jul 18, 2023
1 parent e871f26 commit 0f88d14
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ntest_timeout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,17 @@ fn check_other_attributes(input: &syn::ItemFn) {
match meta {
std::result::Result::Ok(m) => match m {
syn::Meta::Path(p) => {
let identifier = p.get_ident().expect("Expected identifier!");
if identifier == "timeout" {
if p.segments.iter().any(|ps| ps.ident == "timeout") {
panic!("Timeout attribute is only allowed once");
}
}
syn::Meta::List(ml) => {
let identifier = ml.path.get_ident().expect("Expected identifier!");
if identifier == "timeout" {
if ml.path.segments.iter().any(|ps| ps.ident == "timeout") {
panic!("Timeout attribute is only allowed once");
}
}
syn::Meta::NameValue(nv) => {
let identifier = nv.path.get_ident().expect("Expected identifier!");
if identifier == "timeout" {
if nv.path.segments.iter().any(|ps| ps.ident == "timeout") {
panic!("Timeout attribute is only allowed once");
}
}
Expand Down

0 comments on commit 0f88d14

Please sign in to comment.