Add support for #[deprecated].

Closes #875.
Closes #860.
Closes #408.
This commit is contained in:
sevenc-nanashi
2023-07-23 07:31:55 +09:00
committed by Emilio Cobos Álvarez
parent d8355da466
commit 0fb5d07ae4
21 changed files with 769 additions and 2 deletions
+52
View File
@@ -0,0 +1,52 @@
#[no_mangle]
#[deprecated]
pub extern "C" fn deprecated_without_note() {}
#[no_mangle]
#[deprecated = "This is a note"]
pub extern "C" fn deprecated_without_bracket() {}
#[no_mangle]
#[deprecated(note = "This is a note")]
pub extern "C" fn deprecated_with_note() {}
#[no_mangle]
#[deprecated(note = "This is a note", since = "1.0.0")]
pub extern "C" fn deprecated_with_note_and_since() {}
#[no_mangle]
#[deprecated(note = "This quote \" requires to be quoted, and this [\n] requires to be escaped")]
pub extern "C" fn deprecated_with_note_which_requires_to_be_escaped() {}
#[repr(i32)]
#[deprecated]
pub enum DeprecatedEnum {
A = 0,
}
#[repr(i32)]
#[deprecated(note = "This is a note")]
pub enum DeprecatedEnumWithNote {
B = 0,
}
#[repr(C)]
#[deprecated]
pub struct DeprecatedStruct {
pub a: i32,
}
#[repr(C)]
#[deprecated(note = "This is a note")]
pub struct DeprecatedStructWithNote {
pub a: i32,
}
#[no_mangle]
pub extern "C" fn dummy(
a: DeprecatedEnum,
b: DeprecatedEnumWithNote,
c: DeprecatedStruct,
d: DeprecatedStructWithNote,
) -> void {
}
+20
View File
@@ -0,0 +1,20 @@
header = """
#define DEPRECATED_FUNC __attribute__((deprecated))
#define DEPRECATED_STRUCT __attribute__((deprecated))
#define DEPRECATED_ENUM __attribute__((deprecated))
#define DEPRECATED_FUNC_WITH_NOTE(...) __attribute__((deprecated(__VA_ARGS__)))
#define DEPRECATED_STRUCT_WITH_NOTE(...) __attribute__((deprecated(__VA_ARGS__)))
#define DEPRECATED_ENUM_WITH_NOTE(...) __attribute__((deprecated(__VA_ARGS__)))
"""
[fn]
deprecated = "DEPRECATED_FUNC"
deprecated_with_note = "DEPRECATED_FUNC_WITH_NOTE({})"
[struct]
deprecated = "DEPRECATED_STRUCT"
deprecated_with_note = "DEPRECATED_STRUCT_WITH_NOTE({})"
[enum]
deprecated = "DEPRECATED_ENUM"
deprecated_with_note = "DEPRECATED_ENUM_WITH_NOTE({})"