namespace Rust {
namespace Resolver2_0 {
-Early::Early (NameResolutionContext &ctx) : DefaultResolver (ctx) {}
+Early::Early (NameResolutionContext &ctx) : DefaultResolver (ctx), dirty (false)
+{}
void
Early::insert_once (AST::MacroInvocation &invocation, NodeId resolved)
// Once this is done, we finalize their resolution
FinalizeImports (std::move (import_mappings), toplevel, ctx).go (crate);
+ dirty = toplevel.is_dirty ();
// We now proceed with resolving macros, which can be nested in almost any
// items
textual_scope.push ();
{
using DefaultResolver::visit;
+ bool dirty;
+
public:
Early (NameResolutionContext &ctx);
+ bool is_dirty () { return dirty; }
+
void go (AST::Crate &crate);
const std::vector<Error> &get_macro_resolve_errors () const
namespace Resolver2_0 {
TopLevel::TopLevel (NameResolutionContext &resolver)
- : DefaultResolver (resolver)
+ : DefaultResolver (resolver), dirty (false)
{}
template <typename T>
node_locations.emplace (node_id, locus);
auto result = ctx.insert (identifier, node_id, ns);
-
- if (!result && result.error ().existing != node_id)
+ if (result)
+ dirty = true;
+ else if (result.error ().existing != node_id)
{
rich_location rich_loc (line_table, locus);
rich_loc.add_range (node_locations[result.error ().existing]);
void go (AST::Crate &crate);
+ bool is_dirty () { return dirty; }
+
// Each import will be transformed into an instance of `ImportKind`, a class
// representing some of the data we need to resolve in the
// `EarlyNameResolver`. Basically, for each `UseTree` that we see in
Namespace ns);
private:
+ // If a new export has been defined whilst visiting the visitor is considered
+ // dirty
+ bool dirty;
+
// FIXME: Do we move these to our mappings?
std::unordered_map<NodeId, location_t> node_locations;
if (saw_errors ())
break;
+ bool visitor_dirty = false;
+
if (flag_name_resolution_2_0)
{
Resolver2_0::Early early (ctx);
early.go (crate);
macro_errors = early.get_macro_resolve_errors ();
+ visitor_dirty = early.is_dirty ();
}
else
Resolver::EarlyNameResolver ().go (crate);
ExpandVisitor (expander).go (crate);
- fixed_point_reached = !expander.has_changed ();
+ fixed_point_reached = !expander.has_changed () && !visitor_dirty;
expander.reset_changed_state ();
iterations++;