Commit fa9162d
committed
Allow printing a fully-qualified path in
Previously, the local crate would always be printed as a leading `crate::`.
Allow resolving it to the crate name instead.
This allows printing a fully qualified path with:
```rust
let qualified_name = with_no_visible_paths!(with_resolve_crate_name!(
with_no_trimmed_paths!(tcx.def_path_str(def_id))
));
```
I found this useful for an out-of-tree rustc-driver. I do not currently
have a usecase in mind upstream; I'm ok if you don't want this PR for
that reason.
This does not currently have tests. I am not aware of an easy way to
test def-id printing, since it requires having access to a TyCtxt.def_path_str
1 parent dc2c356 commit fa9162d
1 file changed
+13
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
101 | 111 | | |
| 112 | + | |
| 113 | + | |
102 | 114 | | |
103 | 115 | | |
104 | 116 | | |
| |||
2313 | 2325 | | |
2314 | 2326 | | |
2315 | 2327 | | |
2316 | | - | |
| 2328 | + | |
2317 | 2329 | | |
2318 | 2330 | | |
2319 | 2331 | | |
| |||
0 commit comments