Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustdoc-Json: Pub mod in private mod adds both to index #101105

Closed
aDotInTheVoid opened this issue Aug 28, 2022 · 2 comments · Fixed by #128834
Closed

Rustdoc-Json: Pub mod in private mod adds both to index #101105

aDotInTheVoid opened this issue Aug 28, 2022 · 2 comments · Fixed by #128834
Labels
A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@aDotInTheVoid
Copy link
Member

#![feature(no_core)]
#![no_core]

mod m1 {
    pub mod m2{}
}

Produces

{
  "crate_version": null,
  "external_crates": {},
  "format_version": 18,
  "includes_private": false,
  "index": {
    "0:0:1567": {
      "crate_id": 0,
      "id": "0:0:1567",
      "inner": {"is_crate": true, "is_stripped": false, "items": []},
      "kind": "module",
      "name": "bug"
    },
    "0:1:1565": {
      "crate_id": 0,
      "id": "0:1:1565",
      "inner": {"is_crate": false, "is_stripped": true, "items": ["0:2:1566"]},
      "kind": "module",
      "name": "m1"
    },
    "0:2:1566": {
      "crate_id": 0,
      "id": "0:2:1566",
      "inner": {"is_crate": false, "is_stripped": false, "items": []},
      "kind": "module",
      "name": "m2"
    }
  },
  "root": "0:0:1567"
}

@rustbot modify labels: +A-rustdoc-json +T-rustdoc

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 28, 2022
@aDotInTheVoid
Copy link
Member Author

aDotInTheVoid commented Aug 28, 2022

Interestingly, if the inner item is a pub fn, we get the correct result.

#![feature(no_core)]
#![no_core]

mod m1 {
    pub fn m2 (){}
}
{
  "crate_version": null,
  "external_crates": {},
  "format_version": 18,
  "includes_private": false,
  "index": {
    "0:0:1567": {
      "crate_id": 0,
      "id": "0:0:1567",
      "inner": {"is_crate": true, "is_stripped": false, "items": []},
      "kind": "module",
      "name": "bug"
    }
  },
  "root": "0:0:1567"
}

@aDotInTheVoid
Copy link
Member Author

Caused by

// Flatten items that recursively store other items. We include orphaned items from
// stripped modules and etc that are otherwise reachable.
if let ItemKind::StrippedItem(inner) = &*item.kind {
inner.inner_items().for_each(|i| self.item(i.clone()).unwrap());
}

which needs to be more conservitive

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 8, 2024
…nTheVoid

rustdoc: strip unreachable modules

Modules are now stripped based on the same logic that's used to strip other item kinds
Fixes rust-lang#101105
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 8, 2024
…nTheVoid

rustdoc: strip unreachable modules

Modules are now stripped based on the same logic that's used to strip other item kinds
Fixes rust-lang#101105
@bors bors closed this as completed in c2a0d9c Aug 9, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 9, 2024
Rollup merge of rust-lang#128834 - its-the-shrimp:fix_101105, r=aDotInTheVoid

rustdoc: strip unreachable modules

Modules are now stripped based on the same logic that's used to strip other item kinds
Fixes rust-lang#101105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants