Skip to content

fix: Insert spaces when inlining a function defined in a macro. #12877

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

Merged
merged 2 commits into from
Jul 26, 2022

Conversation

zachs18
Copy link
Contributor

@zachs18 zachs18 commented Jul 25, 2022

(partially) fixes #12860.

This PR (only) addresses the whitespace issue when inlining functions defined in macros.

Additionally, the indentation/spacing is not ideal, but works, e.g.

macro_rules! define_function {
    () => { fn test_function_macro() {
        if let Some(3) = 3i32.checked_add(0) {
            println!("3 + 0 == 3");
        }
    } };
}
define_function!();
fn main() {
    test_function_macro();
}
// previously became
// ...
fn main() {
    ifletSome(3)=3i32.checked_add(0){println!("3 + 0 == 3");};
}
// now becomes
// ...
fn main() {
    if let Some(3) = 3i32.checked_add(0){
        println!("3 + 0 == 3");
        
      };
}

The self -> this problem1 is (probably?) a separate problem that I am also looking into.

Footnotes

  1. As mentioned in my comment on the above issue, inlining a method defined in a macro does not properly replace self with the new local this.

@zachs18 zachs18 marked this pull request as ready for review July 25, 2022 21:49
@Veykril
Copy link
Member

Veykril commented Jul 26, 2022

Thanks! I think the FIXME comment can just go
@bors delegate+

@bors
Copy link
Contributor

bors commented Jul 26, 2022

✌️ @zachs18 can now approve this pull request

@zachs18
Copy link
Contributor Author

zachs18 commented Jul 26, 2022

Okay, I removed the FIXME comment. Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Jul 26, 2022

📌 Commit add33b6 has been approved by zachs18

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 26, 2022

⌛ Testing commit add33b6 with merge c2eebd7...

@bors
Copy link
Contributor

bors commented Jul 26, 2022

☀️ Test successful - checks-actions
Approved by: zachs18
Pushing c2eebd7 to master...

@bors bors merged commit c2eebd7 into rust-lang:master Jul 26, 2022
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.

Inlining function defined in macro produces incorrect results (concatenated tokens).
3 participants