mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
729185338f
Originally, this was kinda half-allowed. There were some primitive checks in place that looked at the span to see whether the input was likely a literal. These "source literal" checks are needed because the spans created during `format_args` parsing only make sense when it is indeed a literal that was written in the source code directly. This is orthogonal to the restriction that the first argument must be a "direct literal", not being exanpanded from macros. This restriction was imposed by [RFC 2795] on the basis of being too confusing. But this was only concerned with the argument of the invocation being a literal, not whether it was a source literal (maybe in spirit it meant it being a source literal, this is not clear to me). Since the original check only really cared about source literals (which is good enough to deny the `format_args!(concat!())` example), macros expanding to `format_args` invocations were able to use implicit captures if they spanned the string in a way that lead back to a source string. The "source literal" checks were not strict enough and caused ICEs in certain cases (see # 106191 (the space is intended to avoid spammy backreferences)). So I tightened it up in # 106195 to really only work if it's a direct source literal. This caused the `indoc` crate to break. `indoc` transformed the source literal by removing whitespace, which made it not a "source literal" anymore (which is required to fix the ICE). But since `indoc` spanned the literal in ways that made the old check think that it's a literal, it was able to use implicit captures (which is useful and nice for the users of `indoc`). This commit properly seperates the previously introduced concepts of "source literal" and "direct literal" and therefore allows `indoc` invocations, which don't create "source literals" to use implicit captures again. [RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene |
||
---|---|---|
.. | ||
auxiliary | ||
format-args-capture-first-literal-is-macro.rs | ||
format-args-capture-first-literal-is-macro.stderr | ||
format-args-capture-from-pm-first-arg-macro.rs | ||
format-args-capture-from-pm-first-arg-macro.stderr | ||
format-args-capture-issue-93378.rs | ||
format-args-capture-issue-93378.stderr | ||
format-args-capture-issue-94010.rs | ||
format-args-capture-issue-94010.stderr | ||
format-args-capture-issue-102057.rs | ||
format-args-capture-issue-102057.stderr | ||
format-args-capture-issue-106408.rs | ||
format-args-capture-macro-hygiene-pass.rs | ||
format-args-capture-macro-hygiene.rs | ||
format-args-capture-macro-hygiene.stderr | ||
format-args-capture-missing-variables.rs | ||
format-args-capture-missing-variables.stderr | ||
format-args-capture.rs | ||
format-expanded-string.rs | ||
format-expanded-string.stderr | ||
format-raw-string-error.rs | ||
format-raw-string-error.stderr | ||
format-string-error-2.rs | ||
format-string-error-2.stderr | ||
format-string-error.rs | ||
format-string-error.stderr | ||
format-string-wrong-order.rs | ||
format-string-wrong-order.stderr | ||
format-with-yield-point.rs | ||
ifmt-bad-arg.rs | ||
ifmt-bad-arg.stderr | ||
ifmt-bad-format-args.rs | ||
ifmt-bad-format-args.stderr | ||
ifmt-unimpl.rs | ||
ifmt-unimpl.stderr | ||
ifmt-unknown-trait.rs | ||
ifmt-unknown-trait.stderr | ||
incorrect-separator.rs | ||
incorrect-separator.stderr | ||
indoc-issue-106408.rs | ||
issue-75307.rs | ||
issue-75307.stderr | ||
issue-86085.rs | ||
issue-86085.stderr | ||
issue-89173.rs | ||
issue-89173.stderr | ||
issue-91556.rs | ||
issue-91556.stderr | ||
issue-103826.rs | ||
issue-103826.stderr | ||
issue-104142.rs | ||
issue-104142.stderr | ||
respanned-literal-issue-106191.rs | ||
respanned-literal-issue-106191.stderr | ||
send-sync.rs | ||
send-sync.stderr | ||
struct-field-as-captured-argument.fixed | ||
struct-field-as-captured-argument.rs | ||
struct-field-as-captured-argument.stderr | ||
unicode-escape-spans.rs | ||
unicode-escape-spans.stderr |