Skip to content

Commit c53b532

Browse files
committed
Hack: do not expand arg <expr> within ensure_not_fmt_string_literal.
An attempt to side-step the stability gates that are claiming that ensure_not_fmt_string_literal is expanding into uses of format_args internals. This attempt however did not work; this commit is only here for historical purposs while I ask others for advice. Here is the stack trace of the relevant error here: ``` ---- [run-fail] run-fail/explicit-panic-msg.rs stdout ---- error: compilation failed! status: exit code: 101 command: x86_64-apple-darwin/stage1/bin/rustc /Users/fklock/Dev/Mozilla/rust-panic/src/test/run-fail/explicit-panic-msg.rs -L x86_64-apple-darwin/test/run-fail/ --target=x86_64-apple-darwin -L x86_64-apple-darwin/test/run-fail/explicit-panic-msg.stage1-x86_64-apple-darwinlibaux -C prefer-dynamic -o x86_64-apple-darwin/test/run-fail/explicit-panic-msg.stage1-x86_64-apple-darwin --cfg rtopt --cfg debug -L x86_64-apple-darwin/rt stdout: ------------------------------------------ ------------------------------------------ stderr: ------------------------------------------ <std macros>:2:26: 2:57 error: use of unstable library feature 'core': internal to format_args! <std macros>:2 $ crate:: fmt:: format ( format_args ! ( $ ( $ arg ) * ) ) ) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ note: in expansion of __unstable_rustc_ensure_not_fmt_string_literal! <std macros>:4:1: 4:78 note: expansion site <std macros>:1:1: 12:23 note: in expansion of panic! /Users/fklock/Dev/Mozilla/rust-panic/src/test/run-fail/explicit-panic-msg.rs:18:5: 18:37 note: expansion site <std macros>:2:26: 2:57 help: add #![feature(core)] to the crate attributes to enable <std macros>:2:26: 2:57 error: use of unstable library feature 'core': internal to format_args! <std macros>:2 $ crate:: fmt:: format ( format_args ! ( $ ( $ arg ) * ) ) ) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ note: in expansion of __unstable_rustc_ensure_not_fmt_string_literal! <std macros>:4:1: 4:78 note: expansion site <std macros>:1:1: 12:23 note: in expansion of panic! /Users/fklock/Dev/Mozilla/rust-panic/src/test/run-fail/explicit-panic-msg.rs:18:5: 18:37 note: expansion site <std macros>:2:26: 2:57 help: add #![feature(core)] to the crate attributes to enable error: aborting due to 2 previous errors ------------------------------------------ thread '[run-fail] run-fail/explicit-panic-msg.rs' panicked at 'explicit panic', /Users/fklock/Dev/Mozilla/rust-panic/src/compiletest/runtest.rs:1499 failures: [run-fail] run-fail/explicit-panic-msg.rs ```
1 parent 8c0bead commit c53b532

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libsyntax/ext/format.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ pub fn ensure_not_fmt_string_literal<'cx>(cx: &'cx mut ExtCtxt,
651651
if p.token == token::Eof { return takes_two_args(cx, "given 1"); }
652652
if !panictry!(p.eat(&token::Comma)) { return takes_two_args(cx, "comma-separated"); }
653653
if p.token == token::Eof { return takes_two_args(cx, "given 1"); }
654-
let arg2 = cx.expander().fold_expr(p.parse_expr());
654+
// do not expand the `<expr>`; just inspect it as a black box.
655+
let arg2 = p.parse_expr();
655656
if p.token != token::Eof {
656657
takes_two_args(cx, "given too many");
657658
// (but do not return; handle two provided, nonetheless)

0 commit comments

Comments
 (0)