Make attr template suggestions preserve attribute safety.

This commit is contained in:
Aria Givens
2026-05-20 20:45:36 +02:00
parent 835004a53f
commit 9c9f439997
2 changed files with 9 additions and 10 deletions
+4 -4
View File
@@ -135,23 +135,23 @@ pub fn suggestions(
if self.word {
debug_assert!(macro_call.is_empty(), "Macro suggestions use list style");
suggestions.push(format!("{maybe_unsafe_start}{start}{name}{end}{maybe_unsafe_end}"));
suggestions.push(format!("{start}{maybe_unsafe_start}{name}{maybe_unsafe_end}{end}"));
}
if let Some(descr) = self.list {
for descr in descr {
suggestions.push(format!(
"{maybe_unsafe_start}{start}{name}{macro_call}({descr}){end}{maybe_unsafe_end}"
"{start}{maybe_unsafe_start}{name}{macro_call}({descr}){maybe_unsafe_end}{end}"
));
}
}
suggestions.extend(self.one_of.iter().map(|&word| {
format!("{maybe_unsafe_start}{start}{name}({word}){end}{maybe_unsafe_end}")
format!("{start}{maybe_unsafe_start}{name}({word}){maybe_unsafe_end}{end}")
}));
if let Some(descr) = self.name_value_str {
debug_assert!(macro_call.is_empty(), "Macro suggestions use list style");
for descr in descr {
suggestions.push(format!(
"{maybe_unsafe_start}{start}{name} = \"{descr}\"{end}{maybe_unsafe_end}"
"{start}{maybe_unsafe_start}{name} = \"{descr}\"{maybe_unsafe_end}{end}"
));
}
}
+5 -6
View File
@@ -159,9 +159,8 @@ LL | #[unsafe(export_name)]
|
help: must be of the form
|
LL - #[unsafe(export_name)]
LL + #[export_name = "name"]
|
LL | #[unsafe(export_name = "name")]
| ++++++++
error: `rustc_allow_const_fn_unstable` expects a list of feature names
--> $DIR/malformed-attrs.rs:31:1
@@ -330,7 +329,7 @@ LL | #[unsafe(naked())]
help: must be of the form
|
LL - #[unsafe(naked())]
LL + #[naked]
LL + #[unsafe(naked)]
|
error[E0565]: malformed `track_caller` attribute input
@@ -651,7 +650,7 @@ LL | #[unsafe(ffi_pure = 1)]
help: must be of the form
|
LL - #[unsafe(ffi_pure = 1)]
LL + #[ffi_pure]
LL + #[unsafe(ffi_pure)]
|
error[E0539]: malformed `link_ordinal` attribute input
@@ -677,7 +676,7 @@ LL | #[unsafe(ffi_const = 1)]
help: must be of the form
|
LL - #[unsafe(ffi_const = 1)]
LL + #[ffi_const]
LL + #[unsafe(ffi_const)]
|
error[E0539]: malformed `linkage` attribute input