about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-11-05 19:05:36 +0000
committerbors <bors@rust-lang.org>2021-11-05 19:05:36 +0000
commit0d1754e8bf6942b4c1d24d7c923438782129ba5a (patch)
tree4776ca716504a5a1c13ac8a9062b90f62115d60d /compiler/rustc_interface/src
parent045612b8b97b344d55c13b9aad3cfb3e98405b77 (diff)
parent82b23be3c1c79b2326964ae6aa4eebd788bab691 (diff)
downloadrust-0d1754e8bf6942b4c1d24d7c923438782129ba5a.tar.gz
rust-0d1754e8bf6942b4c1d24d7c923438782129ba5a.zip
Auto merge of #90583 - willcrichton:example-analyzer, r=jyn514
Fix ICE when rustdoc is scraping examples inside of a proc macro

This PR provides a clearer semantics for how --scrape-examples interacts with macros. If an expression's span AND it's enclosing item's span both are not `from_expansion`, then the example will be scraped. The added test case `rustdoc-scrape-examples-macros` shows a variety of situations.

* A macro-rules macro that takes a function call as input: good
* A macro-rules macro that generates a function call as output: bad
* A proc-macro that generates a function call as output: bad
* An attribute macro that generates a function call as output: bad
* An attribute macro that takes a function call as input: good, if the proc macro is designed to propagate the input spans

I ran this updated rustdoc on pyo3 and confirmed that it successfully scrapes examples from inside a proc macro, eg

<img width="1013" alt="Screen Shot 2021-11-04 at 1 11 28 PM" src="https://user-images.githubusercontent.com/663326/140412691-81a3bb6b-a448-4a1b-a293-f7a795553634.png">

(cc `@mejrs)`

Additionally, this PR fixes an ordering bug in the highlighting logic.

Fixes https://github.com/rust-lang/rust/issues/90567.

r? `@jyn514`
Diffstat (limited to 'compiler/rustc_interface/src')
0 files changed, 0 insertions, 0 deletions