Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add regression test for #112852
  • Loading branch information
GuillaumeGomez committed Jul 14, 2023
commit 449cc6549f9f7a6e1d73e1d7a45b856c0b5f7320
14 changes: 14 additions & 0 deletions tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![feature(no_core)]
#![no_core]

// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
// @!has "$.index[*][?(@.inner.impl)]"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!has tests are fragile when the schema changes. The ideal way to write it would be a version that has two structs, and asserts that exactly one shows up.

// @count "$.index[*][?(@.inner.impl)]" 1
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
// @has "$.index[*][?(@.name=='PubTrait')]"
pub trait PubTrait {}

#[doc(hidden)]
pub mod hidden {
    pub struct HiddenPubStruct;

    impl crate::PubTrait for HiddenPubStruct {}
}

pub mod not_hidden {
    pub struct NotHiddenPubStruct;

    impl crate::PubTrait for HiddenPubStruct {}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's still not ideal (I really don't like @!has) but in JSON what you suggested is already much better. Going to update.

// @has "$.index[*][?(@.name=='PubTrait')]"
pub trait PubTrait {}

#[doc(hidden)]
pub mod hidden {
pub struct HiddenPubStruct;

impl crate::PubTrait for HiddenPubStruct {}
}