rust/compiler/rustc_builtin_macros/src
Sasha f6d18db402 Use string literal directly when available in format
Previous implementation used the `Parser::parse_expr` function in order
to extract the format expression. If the first comma following the
format expression was mistakenly replaced with a dot, then the next
format expression was eaten by the function, because it looked as a
syntactically valid expression, which resulted in incorrectly spanned
error messages.

The way the format expression is exctracted is changed: we first look at
the first available token in the first argument supplied to the
`format!` macro call. If it is a string literal, then it is promoted as
a format expression immediatly, otherwise we fall back to the original
`parse_expr`-related method.

This allows us to ensure that the parser won't consume too much tokens
when a typo is made.

A test has been created so that it is ensured that the issue is properly
fixed.
2020-08-30 22:09:58 +02:00
..
deriving mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
format_foreign mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
asm.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
assert.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
cfg.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
cfg_accessible.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
cmdline_attrs.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
compile_error.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
concat.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
concat_idents.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
env.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
format.rs Use string literal directly when available in format 2020-08-30 22:09:58 +02:00
format_foreign.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
global_allocator.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
global_asm.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
lib.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
llvm_asm.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
log_syntax.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
proc_macro_harness.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
source_util.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
standard_library_imports.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
test.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
test_harness.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
trace_macros.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
util.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00