rust/crates/mbe/src
bors[bot] 2ace128dd4
Merge #8560
8560: Escape characters in doc comments in macros correctly r=jonas-schievink a=ChayimFriedman2

Previously they were escaped twice, both by `.escape_default()` and the debug view of strings (`{:?}`). This leads to things like newlines or tabs in documentation comments being `\\n`, but we unescape literals only once, ending up with `\n`.

This was hard to spot because CMark unescaped them (at least for `'` and `"`), but it did not do so in code blocks.

This also was the root cause of #7781. This issue was solved by using `.escape_debug()` instead of `.escape_default()`, but the real issue remained.
We can bring the `.escape_default()` back by now, however I didn't do it because it is probably slower than `.escape_debug()` (more work to do), and also in order to change the code the least.

Example (the keyword and primitive docs are `include!()`d at https://doc.rust-lang.org/src/std/lib.rs.html#570-578, and thus originate from macro):

Before:
![image](https://user-images.githubusercontent.com/24700207/115130096-40544300-9ff5-11eb-847b-969e7034e8a4.png)

After:
![image](https://user-images.githubusercontent.com/24700207/115130143-9cb76280-9ff5-11eb-9281-323746089440.png)


Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2021-04-18 02:14:27 +00:00
..
expander a lot of clippy::style fixes 2021-03-21 16:15:41 +01:00
tests Merge #8560 2021-04-18 02:14:27 +00:00
benchmark.rs Make ast_to_token_tree infallible 2021-04-04 01:46:45 +02:00
expander.rs Make ast_to_token_tree infallible 2021-04-04 01:46:45 +02:00
lib.rs Allow , to delimit macro 2.0 rules 2021-04-03 03:08:31 +02:00
parser.rs a lot of clippy::style fixes 2021-03-21 16:15:41 +01:00
subtree_source.rs Make bare underscore token an Ident rather than Punct in proc-macro 2021-03-20 12:28:44 -06:00
syntax_bridge.rs Merge #8560 2021-04-18 02:14:27 +00:00
tests.rs Make ast_to_token_tree infallible 2021-04-04 01:46:45 +02:00
tt_iter.rs Allow , to delimit macro 2.0 rules 2021-04-03 03:08:31 +02:00