Skip to content

Commit 9cf744c

Browse files
Merge #1172
1172: Resolve visibility paths r=CohenArthur a=CohenArthur This tackles the remaining issues in #1158. ~~It also contains the commit from #1168 so you should wait for bors to merge that before reviewing it :D~~ done The paths get resolved but their `NodeId`s are not used in the privacy visibility resolver yet. Closes #1158 Co-authored-by: Arthur Cohen <[email protected]>
2 parents 1ada076 + 1c56e96 commit 9cf744c

10 files changed

+987
-165
lines changed

gcc/rust/Make-lang.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ GRS_OBJS = \
8787
rust/rust-ast-lower-pattern.o \
8888
rust/rust-name-resolver.o \
8989
rust/rust-ast-resolve.o \
90+
rust/rust-ast-resolve-base.o \
9091
rust/rust-ast-resolve-item.o \
9192
rust/rust-ast-resolve-pattern.o \
9293
rust/rust-ast-resolve-expr.o \

gcc/rust/ast/rust-ast.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ class SimplePathSegment : public PathSegment
349349

350350
Location get_locus () const { return locus; }
351351
NodeId get_node_id () const { return node_id; }
352+
const std::string &get_segment_name () const { return segment_name; }
352353

353354
// TODO: visitor pattern?
354355
};
@@ -404,6 +405,11 @@ class SimplePath
404405
= {AST::SimplePathSegment (std::move (str), locus)};
405406
return SimplePath (std::move (single_segments));
406407
}
408+
409+
const std::vector<SimplePathSegment> &get_segments () const
410+
{
411+
return segments;
412+
}
407413
};
408414

409415
// path-to-string inverse comparison operator

gcc/rust/ast/rust-item.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ struct Visibility
701701

702702
std::string as_string () const;
703703
const SimplePath &get_path () const { return in_path; }
704+
SimplePath &get_path () { return in_path; }
704705

705706
protected:
706707
// Clone function implementation - not currently virtual but may be if

gcc/rust/privacy/rust-visibility-resolver.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ VisibilityResolver::go (HIR::Crate &crate)
4545
}
4646
}
4747

48+
// FIXME: At this point in the pipeline, we should not be dealing with
49+
// `AST::SimplePath`s anymore! We need to be dealing with their "resolved
50+
// counterpart", so probably a NodeId/HirId/DefId.
51+
52+
// static bool
53+
// resolve_module_path (std::vector<HIR::Module> &module_stack,
54+
// const AST::SimplePath &restriction, DefId &id)
55+
// {
56+
// return false;
57+
// }
58+
4859
bool
4960
VisibilityResolver::resolve_visibility (const HIR::Visibility &visibility,
5061
ModuleVisibility &to_resolve)

0 commit comments

Comments
 (0)