internal: Implement module_path macro

This commit is contained in:
Lukas Wirth 2024-08-21 12:22:15 +02:00
parent 9b7b93e031
commit d44a3ab30c
20 changed files with 279 additions and 71 deletions

View file

@ -8702,3 +8702,68 @@ fn foo() {
"#]],
);
}
#[test]
fn module_path_macro() {
check(
r##"
//- minicore: module_path
const C$0: &'static str = module_path!();
"##,
expect![[r#"
*C*
```rust
test
```
```rust
const C: &'static str = "test"
```
"#]],
);
check(
r##"
//- minicore: module_path
mod foo {
const C$0: &'static str = module_path!();
}
"##,
expect![[r#"
*C*
```rust
test::foo
```
```rust
const C: &'static str = "test::foo"
```
"#]],
);
check(
r##"
//- minicore: module_path
mod baz {
const _: () = {
mod bar {
const C$0: &'static str = module_path!();
}
}
}
"##,
expect![[r#"
*C*
```rust
test::bar
```
```rust
const C: &'static str = "test::baz::bar"
```
"#]],
);
}