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

Improve error from invalid syntax inside proc_macro::quote! #47315

Closed
dtolnay opened this issue Jan 10, 2018 · 2 comments
Closed

Improve error from invalid syntax inside proc_macro::quote! #47315

dtolnay opened this issue Jan 10, 2018 · 2 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros-2.0 Area: Declarative macros 2.0 (#39412) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics

Comments

@dtolnay
Copy link
Member

dtolnay commented Jan 10, 2018

Ideally the `$` must be followed by an ident or `$` in `quote!` error message would not look like an ICE.

#![feature(proc_macro)]

extern crate proc_macro;
use proc_macro::{quote, TokenStream};

#[proc_macro]
pub fn p(input: TokenStream) -> TokenStream {
    quote! {
        $()*
    }
}
error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.25.0-nightly (b5392f545 2018-01-08) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at '`$` must be followed by an ident or `$` in `quote!`', libproc_macro/quote.rs:105:26

@jseyfried

@jseyfried jseyfried self-assigned this Jan 10, 2018
@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Jan 11, 2018
@rust-lang rust-lang deleted a comment from anxiousmodernman Jan 25, 2018
@dtolnay dtolnay added the A-macros-2.0 Area: Declarative macros 2.0 (#39412) label Feb 13, 2018
@XAMPPRocky XAMPPRocky added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics labels Apr 10, 2018
@alexreg
Copy link
Contributor

alexreg commented Jul 3, 2018

progress?

@estebank
Copy link
Contributor

Current output:

error: proc macro panicked
  --> src/lib.rs:9:5
   |
9  | /     quote! {
10 | |         $()*
11 | |     }
   | |_____^
   |
   = help: message: `$` must be followed by an ident or `$` in `quote!`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros-2.0 Area: Declarative macros 2.0 (#39412) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

5 participants