about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/coverage/debug.rs
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-06-24 16:43:41 +0900
committerGitHub <noreply@github.com>2022-06-24 16:43:41 +0900
commit97f4d7bd2c1b001d7b9d8b238f866de0cb328b05 (patch)
tree5d49138356fca3df1820d004dff2c2a8b0d4ca53 /compiler/rustc_mir_transform/src/coverage/debug.rs
parentfc96600bf6a52f92aeeee60a92a161a82b61c0ef (diff)
parentbeb2f364cc85b4408da1d043f875d159003558e4 (diff)
downloadrust-97f4d7bd2c1b001d7b9d8b238f866de0cb328b05.tar.gz
rust-97f4d7bd2c1b001d7b9d8b238f866de0cb328b05.zip
Rollup merge of #91264 - GuillaumeGomez:macro-jump-to-def, r=jsha
Add macro support in jump to definition feature

Fixes #91174.

To do so, I check if the span comes from an expansion, and if so, I infer the original macro `DefId` or `Span` depending if it's a defined in the current crate or not.

There is one limitation due to macro expansion though:

```rust
macro_rules! yolo { () => {}}

fn foo() {
    yolo!();
}
```

In `foo`, `yolo!` won't be linked because after expansion, it is replaced by nothing (which seems logical). So I can't get an item from the `Visitor` from which I could tell if its `Span` comes from an expansion.

I added a test for this specific limitation alongside others.

Demo: https://rustdoc.crud.net/imperio/macro-jump-to-def/src/foo/check-source-code-urls-to-def-std.rs.html

As for the empty macro issue that cannot create a jump to definition, you can see it [here](https://rustdoc.crud.net/imperio/macro-jump-to-def/src/foo/check-source-code-urls-to-def-std.rs.html#35).

r? ```@jyn514```
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/debug.rs')
0 files changed, 0 insertions, 0 deletions