Skip to content

Commit dc2cea7

Browse files
committed
Address Codex review feedback
- pub(super) at ingot root now falls back to pub(ingot) semantics, matching Rust where pub(super) at crate root equals pub(crate) - pub(in path) now emits a parser error explaining it's not yet supported, rather than silently lowering to Private
1 parent ed37505 commit dc2cea7

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

crates/hir/src/analysis/name_resolution/visibility_checker.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ pub fn is_scope_visible_from(db: &dyn HirAnalysisDb, scope: ScopeId, from_scope:
6666
let Some(def_scope) = def_scope_for_vis(db, scope) else {
6767
return false;
6868
};
69-
let Some(parent_of_def) = def_scope.parent(db) else {
70-
return false;
71-
};
72-
from_scope.is_transitive_child_of(db, parent_of_def)
69+
match def_scope.parent(db) {
70+
Some(parent_of_def) => from_scope.is_transitive_child_of(db, parent_of_def),
71+
// At the ingot root, pub(super) behaves like pub(ingot)
72+
// (matches Rust where pub(super) at crate root = pub(crate)).
73+
None => scope.ingot(db) == from_scope.ingot(db),
74+
}
7375
}
7476

7577
Visibility::Private => {

crates/parser/src/parser/item.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,11 @@ pub(super) fn parse_vis_restriction<S: TokenStream>(parser: &mut Parser<S>) -> P
200200
ParsedVis::PubSuper
201201
}
202202
Some(SyntaxKind::InKw) => {
203+
parser.error_msg_on_current_token(
204+
"`pub(in path)` is not yet supported; use `pub(ingot)` or `pub(super)`",
205+
);
203206
parser.bump();
204-
// Parse the module path after `in`.
205-
// Reuse the use-path parser for `foo::bar::baz` style paths.
207+
// Parse the module path so the CST is well-formed for future use.
206208
let _ = parser.parse(UsePathScope::default());
207209
ParsedVis::PubIn
208210
}

0 commit comments

Comments
 (0)