From 779a6aca5be6989bafaea55b0b2659c840d06716 Mon Sep 17 00:00:00 2001 From: cameron Date: Mon, 16 Dec 2024 05:03:52 +0000 Subject: [PATCH] add param name to duplicate attribute warning --- proptest-macro/src/property_test/validate.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/proptest-macro/src/property_test/validate.rs b/proptest-macro/src/property_test/validate.rs index 89561140..d1f69424 100644 --- a/proptest-macro/src/property_test/validate.rs +++ b/proptest-macro/src/property_test/validate.rs @@ -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; @@ -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);