rust/tests
bors 2e7034ebf7 Auto merge of #106505 - Nilstrieb:format-args-string-literal-episode-2, r=petrochenkov
Properly allow macro expanded `format_args` invocations to uses captures

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). 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.

Fixes #106191

[RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14 14:25:02 +00:00
..
assembly Update the minimum external LLVM to 14 2023-02-10 16:06:25 -08:00
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
codegen Rollup merge of #109081 - krasimirgg:llvm-17-simd-wide-sum, r=nikic 2023-03-13 21:55:38 +01:00
codegen-units Move /src/test to /tests 2023-01-11 09:32:08 +00:00
debuginfo Remove the capture_disjoint_fields feature 2023-02-28 01:21:15 +00:00
incremental Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mir-opt Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors 2023-03-14 10:12:58 +00:00
pretty Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
run-make Update coverage info. 2023-03-09 17:51:38 +00:00
run-make-fulldeps rustdoc: fix test case for custom themes 2023-03-08 12:49:35 -07:00
run-pass-valgrind Move /src/test to /tests 2023-01-11 09:32:08 +00:00
rustdoc Rollup merge of #108936 - GuillaumeGomez:rustdoc-anonymous-reexport, r=notriddle 2023-03-10 12:31:58 +01:00
rustdoc-gui Rollup merge of #106915 - notriddle:notriddle/load-only-one-theme, r=GuillaumeGomez,jsha 2023-03-09 12:11:52 +01:00
rustdoc-js rustdoc: function signature search with traits in where clause 2023-03-04 09:05:57 -07:00
rustdoc-js-std rustdoc: use restricted Damerau-Levenshtein distance for search 2023-03-10 19:47:08 -07:00
rustdoc-json Add regression test for #107677 2023-02-18 18:28:17 +01:00
rustdoc-ui rustdoc: Don't crash on crate references in blocks 2023-03-10 17:49:13 +01:00
ui Auto merge of #106505 - Nilstrieb:format-args-string-literal-episode-2, r=petrochenkov 2023-03-14 14:25:02 +00:00
ui-fulldeps Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
COMPILER_TESTS.md Move /src/test to /tests 2023-01-11 09:32:08 +00:00