Skip to content

Commit ce4404a

Browse files
P1n3appl3jyn514
authored andcommitted
Add restricted paths
1 parent c8b4e3c commit ce4404a

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

src/librustdoc/json/conversions.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ impl From<clean::Visibility> for Visibility {
8080
Public => Visibility::Public,
8181
Inherited => Visibility::Default,
8282
Crate => Visibility::Crate,
83-
Restricted(_did, _path) => unimplemented!(),
84-
// Visibility::Restricted(did.into(), path.whole_name()),
83+
Restricted(did, path) => Visibility::Restricted{parent: did.into(), path: path.whole_name()},
8584
}
8685
}
8786
}

src/librustdoc/json/types.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ pub enum Visibility {
101101
/// public traits and variants of public enums.
102102
Default,
103103
Crate,
104-
// FIXME(pineapple): add support for restricted paths
104+
/// For `pub(in path)` visibility. `parent` is the module it's restricted to and `path` is how
105+
/// that module was referenced (like `"super::super"` or `"crate::foo::bar"`).
106+
Restricted {
107+
parent: Id,
108+
path: String,
109+
},
105110
}
106111

107112
#[serde(rename_all = "snake_case")]
@@ -440,7 +445,7 @@ pub struct Import {
440445
/// `use source as name;`
441446
pub name: String,
442447
/// The ID of the item being imported.
443-
pub id: Option<Id>, // TODO when is this None?
448+
pub id: Option<Id>, // FIXME is this actually ever None?
444449
/// Whether this import uses a glob: `use source::*;`
445450
pub glob: bool,
446451
}

src/test/run-make-fulldeps/rustdoc-json/check_missing_items.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python
22

3-
# This test ensures that every ID in the produced json actually resolves to an item either in `index` or `paths`.
4-
# It DOES NOT check that the structure of the produced json is actually in any way correct,
5-
# for example an empty map would pass.
3+
# This test ensures that every ID in the produced json actually resolves to an item either in
4+
# `index` or `paths`. It DOES NOT check that the structure of the produced json is actually in
5+
# any way correct, for example an empty map would pass.
66

77
import sys
88
import json

src/test/run-make-fulldeps/rustdoc-json/compare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _check_subset(expected, actual, trace):
4242
if expected_type is dict:
4343
for key in expected:
4444
if key not in actual:
45-
raise SubsetException("Key `{}` not found in output".format(key))
45+
raise SubsetException("Key `{}` not found in output".format(key), trace)
4646
new_trace = trace.copy()
4747
new_trace.append(key)
4848
_check_subset(expected[key], actual[key], new_trace)
@@ -51,7 +51,7 @@ def _check_subset(expected, actual, trace):
5151
actual_elements = len(actual)
5252
if expected_elements != actual_elements:
5353
raise SubsetException(
54-
"Found {} items, expected {}".format(expected_elements, actual_elements)
54+
"Found {} items, expected {}".format(expected_elements, actual_elements), trace
5555
)
5656
for expected, actual in zip(expected, actual):
5757
new_trace = trace.copy()

0 commit comments

Comments
 (0)