Skip to content

Commit

Permalink
Replace Default returns with explicit panics for unknown enum variants
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbb authored and TedDriggs committed Apr 27, 2023
1 parent 3fcf61a commit 1d6f8df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions core/src/usage/lifetimes.rs
Expand Up @@ -247,7 +247,8 @@ impl UsesLifetimes for syn::WherePredicate {
syn::WherePredicate::Type(ref v) => v.uses_lifetimes(options, lifetimes),
syn::WherePredicate::Lifetime(ref v) => v.uses_lifetimes(options, lifetimes),
// non-exhaustive enum
_ => Default::default(),
// TODO: replace panic with failible function
_ => panic!("Unknown syn::WherePredicate: {:?}", self),
}
}
}
Expand All @@ -267,7 +268,8 @@ impl UsesLifetimes for syn::GenericArgument {
Default::default()
}
// non-exhaustive enum
_ => Default::default(),
// TODO: replace panic with failible function
_ => panic!("Unknown syn::GenericArgument: {:?}", self),
}
}
}
Expand Down Expand Up @@ -296,7 +298,8 @@ impl UsesLifetimes for syn::TypeParamBound {
syn::TypeParamBound::Trait(ref v) => v.uses_lifetimes(options, lifetimes),
syn::TypeParamBound::Lifetime(ref v) => v.uses_lifetimes(options, lifetimes),
// non-exhaustive enum
_ => Default::default(),
// TODO: replace panic with failible function
_ => panic!("Unknown syn::TypeParamBound: {:?}", self),
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions core/src/usage/type_params.rs
Expand Up @@ -217,7 +217,8 @@ impl UsesTypeParams for syn::WherePredicate {
syn::WherePredicate::Lifetime(_) => Default::default(),
syn::WherePredicate::Type(ref v) => v.uses_type_params(options, type_set),
// non-exhaustive enum
_ => Default::default(),
// TODO: replace panic with failible function
_ => panic!("Unknown syn::WherePredicate: {:?}", self),
}
}
}
Expand All @@ -232,7 +233,8 @@ impl UsesTypeParams for syn::GenericArgument {
| syn::GenericArgument::Const(_)
| syn::GenericArgument::Lifetime(_) => Default::default(),
// non-exhaustive enum
_ => Default::default(),
// TODO: replace panic with failible function
_ => panic!("Unknown syn::GenericArgument: {:?}", self),
}
}
}
Expand All @@ -243,7 +245,8 @@ impl UsesTypeParams for syn::TypeParamBound {
syn::TypeParamBound::Trait(ref v) => v.uses_type_params(options, type_set),
syn::TypeParamBound::Lifetime(_) => Default::default(),
// non-exhaustive enum
_ => Default::default(),
// TODO: replace panic with failible function
_ => panic!("Unknown syn::TypeParamBound: {:?}", self),
}
}
}
Expand Down

0 comments on commit 1d6f8df

Please sign in to comment.