mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 05:57:03 +03:00
Make attr template suggestions preserve attribute safety.
This commit is contained in:
@@ -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}"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user