Fix for `windows-targets::link` doc compatibility (#2868)

This commit is contained in:
Kenny Kerr 2024-02-22 09:10:02 -06:00 коммит произвёл GitHub
Родитель 0494b0245e
Коммит 428a7ca2e6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -1,7 +1,7 @@
[package]
name = "windows-targets"
version = "0.52.1"
version = "0.52.2"
authors = ["Microsoft"]
edition = "2021"
rust-version = "1.60"

Просмотреть файл

@ -8,7 +8,7 @@ Learn more about Rust for Windows here: <https://github.com/microsoft/windows-rs
#[cfg(all(windows_raw_dylib, target_arch = "x86"))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated")]
extern $abi {
$(#[link_name=$link_name])?
@ -21,7 +21,7 @@ macro_rules! link {
#[cfg(all(windows_raw_dylib, not(target_arch = "x86")))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim")]
extern "C" {
$(#[link_name=$link_name])?
@ -34,7 +34,7 @@ macro_rules! link {
#[cfg(all(windows, not(windows_raw_dylib)))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
#[link(name = "windows.0.52.1")]
extern $abi {
$(#[link_name=$link_name])?
@ -47,7 +47,7 @@ macro_rules! link {
#[cfg(all(not(windows), not(windows_raw_dylib)))]
#[macro_export]
macro_rules! link {
($library:literal $abi:literal $($link_name:literal)? fn $($function:tt)*) => (
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
extern $abi {
pub fn $($function)*;
}

Просмотреть файл

@ -22,6 +22,17 @@ fn link_name() {
}
}
#[test]
fn doc() {
windows_targets::link!("kernel32.dll" "system" "SetLastError" #[doc = "SetLastError"] fn SetLastError(code: u32) -> ());
windows_targets::link!("kernel32.dll" "system" #[doc = "GetLastError"] fn GetLastError() -> u32);
unsafe {
SetLastError(1234);
assert_eq!(GetLastError(), 1234);
}
}
#[test]
fn cdecl() {
windows_targets::link!("wldap32.dll" "cdecl" fn LdapMapErrorToWin32(code : i32) -> u32);