-
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_expr silently discards trailing expressions #16935
Labels
A-syntaxext
Area: Syntax extensions
Comments
@huonw This is an old issue, and I updated the test case a bit, but it still seems to happen: // synext.rs
#![feature(plugin_registrar, quote, rustc_private)]
#![crate_name = "synext"]
#![crate_type = "dylib"]
extern crate syntax;
extern crate rustc_plugin;
use rustc_plugin::Registry;
use syntax::ext::base::{MacResult, MacEager};
use syntax::tokenstream;
use syntax::codemap::Span;
use syntax::ext::base::ExtCtxt;
#[plugin_registrar]
pub fn registrar(reg: &mut Registry) {
reg.register_macro("test", expand);
}
fn expand(cx: &mut ExtCtxt, _sp: Span,
_tts: &[tokenstream::TokenTree]) -> Box<MacResult + 'static> {
MacEager::expr(quote_expr!(cx,
std::io::stdout().write("one");
std::io::stdout().write("two");
))
} // test-synext.rs
#![feature(plugin)]
#![plugin(synext)]
fn main() {
test!()
} Compiling with #![feature(prelude_import)]
#![no_std]
#![feature(plugin)]
#![plugin(synext)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
fn main() { std::io::stdout().write("one") } |
Also, I get an ICE if I pass
|
Closing in favor of #12266. |
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 31, 2024
Handle panicking like rustc CTFE does Instead of using `core::fmt::format` to format panic messages, which may in turn panic too and cause recursive panics and other messy things, redirect `panic_fmt` to `const_panic_fmt` like CTFE, which in turn goes to `panic_display` and does the things normally. See the tests for the full call stack. The tests don't work yet, I probably missed something in minicore. fixes rust-lang#16907 in my local testing, I also need to add a test for it
lnicola
pushed a commit
to lnicola/rust
that referenced
this issue
Apr 24, 2024
Implement `BeginPanic` handling in const eval for rust-lang#16935, needs some figuring out of how to write these tests correctly
RalfJung
pushed a commit
to RalfJung/rust
that referenced
this issue
Apr 27, 2024
Implement `BeginPanic` handling in const eval for rust-lang#16935, needs some figuring out of how to write these tests correctly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiling those with
rustc synext.rs && rustc -L . test-synext.rs --pretty expanded
withi.e. the
std::io::println("two")
is gone. Wrapping the two expressions into a{ ... }
works.The text was updated successfully, but these errors were encountered: