-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
quote macros do not err or warn on trailing token-trees in input #12266
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-syntaxext
Area: Syntax extensions
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Comments
Still an issue. Updated code: #![feature(quote)]
#![feature(macro_rules)]
extern crate syntax;
extern crate rustc;
use syntax::ast;
use syntax::codemap;
use syntax::parse;
use syntax::parse::token;
use syntax::print::pprust;
fn main() {
let ctxt = Ctxt { parse: parse::new_parse_sess() };
let e = quote_expr!(&ctxt, x + y);
println!("expr: {}", pprust::expr_to_string(&*e));
let p = quote_pat!(&ctxt, x + y);
println!("pat: {}", pprust::pat_to_string(&*p));
}
struct Ctxt {
parse: parse::ParseSess
}
impl Ctxt {
fn parse_sess(&self) -> &syntax::parse::ParseSess { &self.parse }
fn cfg(&self) -> ast::CrateConfig { vec![] }
fn call_site(&self) -> codemap::Span { codemap::DUMMY_SP }
fn ident_of(&self, st: &str) -> ast::Ident { token::str_to_ident(st) }
} |
Updated code: #![feature(quote)]
#![feature(rustc_private)]
extern crate syntax;
extern crate rustc;
use syntax::ast;
use syntax::codemap;
use syntax::parse;
use syntax::parse::token;
use syntax::print::pprust;
fn main() {
let ctxt = Ctxt { parse: parse::ParseSess::new() };
let e = quote_expr!(&ctxt, x + y);
println!("expr: {}", pprust::expr_to_string(&*e));
let p = quote_pat!(&ctxt, x + y);
println!("pat: {}", pprust::pat_to_string(&*p));
}
struct Ctxt {
parse: parse::ParseSess
}
impl Ctxt {
fn parse_sess(&self) -> &syntax::parse::ParseSess { &self.parse }
fn cfg(&self) -> ast::CrateConfig { vec![] }
fn call_site(&self) -> codemap::Span { codemap::DUMMY_SP }
fn ident_of(&self, st: &str) -> ast::Ident { token::str_to_ident(st) }
} |
Triage: @Stebalien 's code doesn't work any more, but I don't know how to update it to see if this problem persists. |
@jseyfried Perhaps you could help out and provide a reproducible example here? This may also be related to macros 2.0 work. |
Mark-Simulacrum
added
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
A-diagnostics
Area: Messages for errors, warnings, and lints
labels
Jul 20, 2017
bors
added a commit
that referenced
this issue
Sep 30, 2018
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. r? @Manishearth
bors
added a commit
that referenced
this issue
Oct 2, 2018
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. r? @Manishearth
bors
added a commit
that referenced
this issue
Dec 8, 2018
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. Fixes #26994. r? @Manishearth
bors
added a commit
that referenced
this issue
Jan 23, 2019
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. Fixes #26994. r? @Manishearth
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Feb 26, 2024
…eds-usize, r=Manishearth fix: ICE when array index exceeds usize fixes rust-lang#12253 This PR fixes ICE in `indexing_slicing` as it panics when the index of the array exceeds `usize`. changelog: none
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-syntaxext
Area: Syntax extensions
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
here is a snippet of code (i've pasted the full example at the bottom):
Once #12264 is fixed, then you can compile and run this, and you'll get:
In particular, I fed
x + y
into bothquote_expr!
and intoquote_pat!
, and the+ y
was simply silently discarded whenquote_pat!
parsed its input.The macros should check for trailing input and issue a warning (that one could then use allow/deny/forbid on).
Here is the full example code (again, won't compile until #12264 is fixed):
The text was updated successfully, but these errors were encountered: