|
| 1 | +// Test for the Path::name field within a single crate. |
| 2 | +// |
| 3 | +// See https://github.com/rust-lang/rust/issues/135600 |
| 4 | +// and https://github.com/rust-lang/rust/pull/134880#issuecomment-2596386111 |
| 5 | +// |
| 6 | +// ignore-tidy-linelength |
| 7 | +//@ aux-build: defines_and_reexports.rs |
| 8 | +extern crate defines_and_reexports; |
| 9 | + |
| 10 | +mod priv_mod { |
| 11 | + pub struct InPrivMod; |
| 12 | +} |
| 13 | + |
| 14 | +pub mod pub_mod { |
| 15 | + pub struct InPubMod; |
| 16 | +} |
| 17 | + |
| 18 | +use priv_mod::InPrivMod as InPrivMod3; |
| 19 | +pub use priv_mod::{InPrivMod, InPrivMod as InPrivMod2}; |
| 20 | +use pub_mod::InPubMod as InPubMod3; |
| 21 | +pub use pub_mod::{InPubMod, InPubMod as InPubMod2}; |
| 22 | + |
| 23 | +//@ is "$.index[*][?(@.name=='T0')].inner.type_alias.type.resolved_path.path" '"priv_mod::InPrivMod"' |
| 24 | +pub type T0 = priv_mod::InPrivMod; |
| 25 | +//@ is "$.index[*][?(@.name=='T1')].inner.type_alias.type.resolved_path.path" '"InPrivMod"' |
| 26 | +pub type T1 = InPrivMod; |
| 27 | +//@ is "$.index[*][?(@.name=='T2')].inner.type_alias.type.resolved_path.path" '"InPrivMod2"' |
| 28 | +pub type T2 = InPrivMod2; |
| 29 | +//@ is "$.index[*][?(@.name=='T3')].inner.type_alias.type.resolved_path.path" '"priv_mod::InPrivMod"' |
| 30 | +pub type T3 = InPrivMod3; |
| 31 | + |
| 32 | +//@ is "$.index[*][?(@.name=='U0')].inner.type_alias.type.resolved_path.path" '"pub_mod::InPubMod"' |
| 33 | +pub type U0 = pub_mod::InPubMod; |
| 34 | +//@ is "$.index[*][?(@.name=='U1')].inner.type_alias.type.resolved_path.path" '"InPubMod"' |
| 35 | +pub type U1 = InPubMod; |
| 36 | +//@ is "$.index[*][?(@.name=='U2')].inner.type_alias.type.resolved_path.path" '"InPubMod2"' |
| 37 | +pub type U2 = InPubMod2; |
| 38 | +//@ is "$.index[*][?(@.name=='U3')].inner.type_alias.type.resolved_path.path" '"pub_mod::InPubMod"' |
| 39 | +pub type U3 = InPubMod3; |
| 40 | + |
| 41 | +// Check we only have paths for structs at their original path |
| 42 | +//@ ismany "$.paths[*][?(@.crate_id==0 && @.kind=='struct')].path" '["path_name", "priv_mod", "InPrivMod"]' '["path_name", "pub_mod", "InPubMod"]' |
| 43 | + |
| 44 | +pub use defines_and_reexports::{InPrivMod as XPrivMod, InPubMod as XPubMod}; |
| 45 | +use defines_and_reexports::{InPrivMod as XPrivMod2, InPubMod as XPubMod2}; |
| 46 | + |
| 47 | +//@ is "$.index[*][?(@.name=='X0')].inner.type_alias.type.resolved_path.path" '"defines_and_reexports::m1::InPubMod"' |
| 48 | +pub type X0 = defines_and_reexports::m1::InPubMod; |
| 49 | +//@ is "$.index[*][?(@.name=='X1')].inner.type_alias.type.resolved_path.path" '"defines_and_reexports::InPubMod"' |
| 50 | +pub type X1 = defines_and_reexports::InPubMod; |
| 51 | +//@ is "$.index[*][?(@.name=='X2')].inner.type_alias.type.resolved_path.path" '"defines_and_reexports::InPubMod2"' |
| 52 | +pub type X2 = defines_and_reexports::InPubMod2; |
| 53 | +//@ is "$.index[*][?(@.name=='X3')].inner.type_alias.type.resolved_path.path" '"XPubMod"' |
| 54 | +pub type X3 = XPubMod; |
| 55 | +// N.B. This isn't the path as used *or* the original path! |
| 56 | +//@ is "$.index[*][?(@.name=='X4')].inner.type_alias.type.resolved_path.path" '"defines_and_reexports::InPubMod"' |
| 57 | +pub type X4 = XPubMod2; |
| 58 | + |
| 59 | +//@ is "$.index[*][?(@.name=='Y1')].inner.type_alias.type.resolved_path.path" '"defines_and_reexports::InPrivMod"' |
| 60 | +pub type Y1 = defines_and_reexports::InPrivMod; |
| 61 | +//@ is "$.index[*][?(@.name=='Y2')].inner.type_alias.type.resolved_path.path" '"defines_and_reexports::InPrivMod2"' |
| 62 | +pub type Y2 = defines_and_reexports::InPrivMod2; |
| 63 | +//@ is "$.index[*][?(@.name=='Y3')].inner.type_alias.type.resolved_path.path" '"XPrivMod"' |
| 64 | +pub type Y3 = XPrivMod; |
| 65 | +//@ is "$.index[*][?(@.name=='Y4')].inner.type_alias.type.resolved_path.path" '"defines_and_reexports::InPrivMod"' |
| 66 | +pub type Y4 = XPrivMod2; |
| 67 | + |
| 68 | +// For foreign items, $.paths contains the *origional* path, even if it's not publicly |
| 69 | +// assessable. This should probably be changed. |
| 70 | + |
| 71 | +//@ has "$.paths[*].path" '["defines_and_reexports", "m1", "InPubMod"]' |
| 72 | +//@ has "$.paths[*].path" '["defines_and_reexports", "m2", "InPrivMod"]' |
| 73 | +//@ !has "$.paths[*].path" '["defines_and_reexports", "InPubMod"]' |
| 74 | +//@ !has "$.paths[*].path" '["defines_and_reexports", "InPrivMod"]' |
| 75 | + |
| 76 | +// Tests for the example in the docs of Path::name. |
| 77 | +// If these change, chage the docs. |
| 78 | +//@ is "$.index[*][?(@.name=='Vec1')].inner.type_alias.type.resolved_path.path" '"std::vec::Vec"' |
| 79 | +pub type Vec1 = std::vec::Vec<i32>; |
| 80 | +//@ is "$.index[*][?(@.name=='Vec2')].inner.type_alias.type.resolved_path.path" '"Vec"' |
| 81 | +pub type Vec2 = Vec<i32>; |
| 82 | +//@ is "$.index[*][?(@.name=='Vec3')].inner.type_alias.type.resolved_path.path" '"std::prelude::v1::Vec"' |
| 83 | +pub type Vec3 = std::prelude::v1::Vec<i32>; |
0 commit comments