Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aDotInTheVoid committed Jan 21, 2025
1 parent 51612c2 commit 1eb4553
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/rustdoc-json/auxiliary/defines_and_reexports.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pub mod m1 {
pub struct InPubMod;
}

mod m2 {
pub struct InPrivMod;
}

pub use m1::{InPubMod, InPubMod as InPubMod2};
pub use m2::{InPrivMod, InPrivMod as InPrivMod2};
36 changes: 35 additions & 1 deletion tests/rustdoc-json/path_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// and https://github.com/rust-lang/rust/pull/134880#issuecomment-2596386111
//
// ignore-tidy-linelength
//@ aux-build: defines_and_reexports.rs
extern crate defines_and_reexports;

mod priv_mod {
pub struct InPrivMod;
Expand Down Expand Up @@ -36,5 +38,37 @@ pub type U2 = InPubMod2;
//@ is "$.index[*][?(@.name=='U3')].inner.type_alias.type.resolved_path.name" '"pub_mod::InPubMod"'
pub type U3 = InPubMod3;

// Check we only have paths for structs at there origonal path
// Check we only have paths for structs at their original path
//@ ismany "$.paths[*][?(@.crate_id==0 && @.kind=='struct')].path" '["path_name", "priv_mod", "InPrivMod"]' '["path_name", "pub_mod", "InPubMod"]'

pub use defines_and_reexports::{InPrivMod as XPrivMod, InPubMod as XPubMod};
use defines_and_reexports::{InPrivMod as XPrivMod2, InPubMod as XPubMod2};

//@ is "$.index[*][?(@.name=='X0')].inner.type_alias.type.resolved_path.name" '"defines_and_reexports::m1::InPubMod"'
pub type X0 = defines_and_reexports::m1::InPubMod;
//@ is "$.index[*][?(@.name=='X1')].inner.type_alias.type.resolved_path.name" '"defines_and_reexports::InPubMod"'
pub type X1 = defines_and_reexports::InPubMod;
//@ is "$.index[*][?(@.name=='X2')].inner.type_alias.type.resolved_path.name" '"defines_and_reexports::InPubMod2"'
pub type X2 = defines_and_reexports::InPubMod2;
//@ is "$.index[*][?(@.name=='X3')].inner.type_alias.type.resolved_path.name" '"XPubMod"'
pub type X3 = XPubMod;
// N.B. This isn't the path as used *or* the original path!
//@ is "$.index[*][?(@.name=='X4')].inner.type_alias.type.resolved_path.name" '"defines_and_reexports::InPubMod"'
pub type X4 = XPubMod2;

//@ is "$.index[*][?(@.name=='Y1')].inner.type_alias.type.resolved_path.name" '"defines_and_reexports::InPrivMod"'
pub type Y1 = defines_and_reexports::InPrivMod;
//@ is "$.index[*][?(@.name=='Y2')].inner.type_alias.type.resolved_path.name" '"defines_and_reexports::InPrivMod2"'
pub type Y2 = defines_and_reexports::InPrivMod2;
//@ is "$.index[*][?(@.name=='Y3')].inner.type_alias.type.resolved_path.name" '"XPrivMod"'
pub type Y3 = XPrivMod;
//@ is "$.index[*][?(@.name=='Y4')].inner.type_alias.type.resolved_path.name" '"defines_and_reexports::InPrivMod"'
pub type Y4 = XPrivMod2;

// For foreign items, $.paths contains the *origional* path, even if it's not publicly
// assessable. This should probably be changed.

//@ has "$.paths[*].path" '["defines_and_reexports", "m1", "InPubMod"]'
//@ has "$.paths[*].path" '["defines_and_reexports", "m2", "InPrivMod"]'
//@ !has "$.paths[*].path" '["defines_and_reexports", "InPubMod"]'
//@ !has "$.paths[*].path" '["defines_and_reexports", "InPrivMod"]'

0 comments on commit 1eb4553

Please sign in to comment.