address comments
This commit is contained in:
@@ -420,16 +420,11 @@ pub(super) enum AllowMultipleAlternatives {
|
|||||||
Yes,
|
Yes,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs the `format!()` invocation(s) necessary for a `#[suggestion*(code = "foo")]` or
|
fn parse_suggestion_values(
|
||||||
/// `#[suggestion*(code("foo", "bar"))]` attribute field
|
|
||||||
pub(super) fn build_suggestion_code(
|
|
||||||
code_field: &Ident,
|
|
||||||
nested: ParseNestedMeta<'_>,
|
nested: ParseNestedMeta<'_>,
|
||||||
fields: &impl HasFieldMap,
|
|
||||||
allow_multiple: AllowMultipleAlternatives,
|
allow_multiple: AllowMultipleAlternatives,
|
||||||
) -> TokenStream {
|
) -> syn::Result<Vec<LitStr>> {
|
||||||
let values = match (|| {
|
let values = if let Ok(val) = nested.value() {
|
||||||
let values: Vec<LitStr> = if let Ok(val) = nested.value() {
|
|
||||||
vec![val.parse()?]
|
vec![val.parse()?]
|
||||||
} else {
|
} else {
|
||||||
let content;
|
let content;
|
||||||
@@ -468,7 +463,17 @@ pub(super) fn build_suggestion_code(
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ok(values)
|
Ok(values)
|
||||||
})() {
|
}
|
||||||
|
|
||||||
|
/// Constructs the `format!()` invocation(s) necessary for a `#[suggestion*(code = "foo")]` or
|
||||||
|
/// `#[suggestion*(code("foo", "bar"))]` attribute field
|
||||||
|
pub(super) fn build_suggestion_code(
|
||||||
|
code_field: &Ident,
|
||||||
|
nested: ParseNestedMeta<'_>,
|
||||||
|
fields: &impl HasFieldMap,
|
||||||
|
allow_multiple: AllowMultipleAlternatives,
|
||||||
|
) -> TokenStream {
|
||||||
|
let values = match parse_suggestion_values(nested, allow_multiple) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(e) => return e.into_compile_error(),
|
Err(e) => return e.into_compile_error(),
|
||||||
};
|
};
|
||||||
@@ -706,14 +711,14 @@ impl SubdiagnosticKind {
|
|||||||
let path_span = nested.path.span().unwrap();
|
let path_span = nested.path.span().unwrap();
|
||||||
let val_span = nested.input.span().unwrap();
|
let val_span = nested.input.span().unwrap();
|
||||||
|
|
||||||
macro get_string() {
|
macro_rules! get_string {
|
||||||
{
|
() => {{
|
||||||
let Ok(value) = nested.value().and_then(|x| x.parse::<LitStr>()) else {
|
let Ok(value) = nested.value().and_then(|x| x.parse::<LitStr>()) else {
|
||||||
span_err(val_span, "expected `= \"xxx\"`").emit();
|
span_err(val_span, "expected `= \"xxx\"`").emit();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
value
|
value
|
||||||
}
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut has_errors = false;
|
let mut has_errors = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user