Skip to content

Commit

Permalink
add param name to duplicate attribute warning
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron1024 committed Dec 16, 2024
1 parent ec1c690 commit 779a6ac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions proptest-macro/src/property_test/validate.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use quote::quote_spanned;
use quote::{quote_spanned, ToTokens};
use syn::{spanned::Spanned, FnArg, ItemFn, Meta};

use super::utils::is_strategy;
Expand Down Expand Up @@ -55,8 +55,13 @@ fn validate_parameter_attrs(f: &mut ItemFn) -> Result<(), TokenStream> {
// a "good" strategy - if we see more than one, emit an error
Meta::NameValue(_) => {
if first_strategy_seen {
let pat =
pat_ty.pat.clone().into_token_stream().to_string();
let message = format!(
"{pat} has duplicate `#[strategy = ...] attribute`"
);
error.extend(quote_spanned! {
attr.span() => compile_error!("duplicate `#[strategy = ...]` definition");
attr.span() => compile_error!(#message);
});
} else {
final_attrs.push(attr);
Expand Down

0 comments on commit 779a6ac

Please sign in to comment.