Rust: Path resolution for crate::{self as foo}

This commit is contained in:
Tom Hvitved
2025-06-18 19:57:57 +02:00
parent 77a92c062b
commit 519e56f752
3 changed files with 10 additions and 2 deletions

View File

@@ -205,7 +205,11 @@ abstract class ItemNode extends Locatable {
else result = this.getImmediateParentModule().getImmediateParentModule()
or
name = "self" and
if this instanceof Module or this instanceof Enum or this instanceof Struct
if
this instanceof Module or
this instanceof Enum or
this instanceof Struct or
this instanceof Crate
then result = this
else result = this.getImmediateParentModule()
or

View File

@@ -638,7 +638,7 @@ impl AStruct // $ item=I123
use std::{self as ztd}; // $ item=std
fn use_ztd(x: ztd::string::String) {} // $ MISSING: item=String
fn use_ztd(x: ztd::string::String) {} // $ item=String
fn main() {
my::nested::nested1::nested2::f(); // $ item=I4

View File

@@ -277,6 +277,10 @@ resolvePath
| main.rs:635:7:635:16 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
| main.rs:635:7:635:28 | ...::add_suffix | proc_macro.rs:4:1:12:1 | fn add_suffix |
| main.rs:639:5:639:7 | std | {EXTERNAL LOCATION} | Crate(std@0.0.0) |
| main.rs:639:11:639:14 | self | {EXTERNAL LOCATION} | Crate(std@0.0.0) |
| main.rs:641:15:641:17 | ztd | {EXTERNAL LOCATION} | Crate(std@0.0.0) |
| main.rs:641:15:641:25 | ...::string | {EXTERNAL LOCATION} | mod string |
| main.rs:641:15:641:33 | ...::String | {EXTERNAL LOCATION} | struct String |
| main.rs:644:5:644:6 | my | main.rs:1:1:1:7 | mod my |
| main.rs:644:5:644:14 | ...::nested | my.rs:1:1:1:15 | mod nested |
| main.rs:644:5:644:23 | ...::nested1 | my/nested.rs:1:1:17:1 | mod nested1 |