Skip to content
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

Eliminate piles of extra semicolons from expanded code #221

Merged
merged 1 commit into from Jun 18, 2022
Merged

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Jun 18, 2022

Look at cargo rustc --profile=check -- -Zunpretty=expanded of the following program:

use quote::quote;

fn main() {
    let _ = quote!(1 + 1);
}

Before:

use quote::quote;

fn main() {
    let _ =
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ;
            ;
            ;
            ::quote::__private::parse(&mut _s, "1");
            ;
            ::quote::__private::push_add(&mut _s);
            ;
            ::quote::__private::parse(&mut _s, "1");
            ;
            ;
            ;
            ;
            _s
        };
}

After:

use quote::quote;

fn main() {
    let _ =
        {
            let mut _s = ::quote::__private::TokenStream::new();
            ::quote::__private::parse(&mut _s, "1");
            ::quote::__private::push_add(&mut _s);
            ::quote::__private::parse(&mut _s, "1");
            _s
        };
}

Look at `cargo rustc --profile=check -- -Zunpretty=expanded` of the
following program:

    use quote::quote;
    fn main() {
        let _ = quote!(1 + 1);
    }

Before:

    use quote::quote;
    fn main() {
        let _ =
            {
                let mut _s = ::quote::__private::TokenStream::new();
                ;
                ;
                ;
                ::quote::__private::parse(&mut _s, "1");
                ;
                ::quote::__private::push_add(&mut _s);
                ;
                ::quote::__private::parse(&mut _s, "1");
                ;
                ;
                ;
                ;
                _s
            };
    }

After:

    use quote::quote;
    fn main() {
        let _ =
            {
                let mut _s = ::quote::__private::TokenStream::new();
                ::quote::__private::parse(&mut _s, "1");
                ::quote::__private::push_add(&mut _s);
                ::quote::__private::parse(&mut _s, "1");
                _s
            };
    }
@dtolnay dtolnay merged commit 75d195e into master Jun 18, 2022
@dtolnay dtolnay deleted the semicolon branch June 18, 2022 23:43
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.

None yet

1 participant