Skip to content

library/windows_targets: Fix macro expansion error in 'link' macro #144417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

itf
Copy link
Contributor

@itf itf commented Jul 24, 2025

A recent change altered the definition of the link! macro when the windows_raw_dylib feature is enabled, changing its syntax from pub macro {..} to pub macro($tt:tt) {..} in #143592

This change introduced a build failure with the error: "macros that expand to items must be delimited with braces or followed by a semicolon".

We revert this change, making it consistent with the link! macro when the windows_raw_dylib feature is not enabled.

For the case when it is not enabled, it also makes use of code repetition in order to avoid the macro expansion error. If instead we try to reuse the code, as seen in #144415, we run into the same issue of "macros that expand to items must be delimited with braces or followed by a semicolon"

…st-lang#144415

A recent change altered the definition of the link! macro when the windows_raw_dylib feature is enabled, changing its syntax from pub macro {..} to pub macro($tt:tt) {..} in rust-lang#143592

This change introduced a build failure with the error: "macros that expand to items must be delimited with braces or followed by a semicolon".

We revert this change, making it consistent with the link! macro when the windows_raw_dylib feature is not enabled.

For the case when it is not enabled, it also makes use of code repetition in order to avoid the macro expansion error. If instead we try to reuse the code, as seen in rust-lang#144415, we run into the same issue of "macros that expand to items must be delimited with braces or followed by a semicolon"
@rustbot
Copy link
Collaborator

rustbot commented Jul 24, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 24, 2025

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@@ -33,8 +33,15 @@ pub macro link_dylib {
}

#[cfg(feature = "windows_raw_dylib")]
pub macro link($($tt:tt)*) {
$crate::link_raw_dylib!($($tt)*)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message says the issue here is a missing semicolon so the fix is to simply append the semicolon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed that this would cause scoping issues. I followed the suggestion here: #144422

@itf itf closed this Jul 25, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants