diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/resolve/absolute.cpp | 5 | ||||
-rw-r--r-- | src/resolve/use.cpp | 7 |
3 files changed, 10 insertions, 4 deletions
@@ -114,7 +114,7 @@ output/lib%.hir: $(RUSTCSRC)src/lib%/lib.rs $(RUSTCSRC) $(BIN) @echo "--- [MRUSTC] $@" @mkdir -p output/ @rm -f $@ - $(DBG) $(BIN) $< -o $@ $(PIPECMD) + $(DBG) $(BIN) $< -o $@ --cfg cargobuild $(PIPECMD) # # HACK: Work around gdb returning success even if the program crashed @test -e $@ output/lib%.hir: $(RUSTCSRC)src/lib%/src/lib.rs $(RUSTCSRC) $(BIN) diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp index 646e4aaf..1077702a 100644 --- a/src/resolve/absolute.cpp +++ b/src/resolve/absolute.cpp @@ -1361,7 +1361,10 @@ void Resolve_Absolute_Path(/*const*/ Context& context, const Span& sp, Context:: // - Determine how many components of the `self` path to use const auto& mp_nodes = context.m_mod.path().nodes(); assert( e.count >= 1 ); + // TODO: The first super should ignore any anon modules. unsigned int start_len = e.count > mp_nodes.size() ? 0 : mp_nodes.size() - e.count; + while( start_len > 0 && mp_nodes[start_len-1].name()[0] == '#' ) + start_len --; // - Create a new path ::AST::Path np("", {}); @@ -1372,8 +1375,6 @@ void Resolve_Absolute_Path(/*const*/ Context& context, const Span& sp, Context:: for(auto& en : e.nodes) np_nodes.push_back( mv$(en) ); - // TODO: Resolve to the actual item? - if( !path.is_trivial() ) Resolve_Absolute_PathNodes(context, sp, np_nodes); diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index 0db58a51..ad668b40 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -67,7 +67,12 @@ void Resolve_Use(::AST::Crate& crate) if( e.count > base_path.nodes().size() ) { ERROR(span, E0000, "Too many `super` components"); } - for( unsigned int i = 0; i < base_path.nodes().size() - e.count; i ++ ) + // TODO: Do this in a cleaner manner. + unsigned int n_anon = 0; + // Skip any anon modules in the way (i.e. if the current module is an anon, go to the parent) + while( base_path.nodes().size() > n_anon && base_path.nodes()[ base_path.nodes().size()-1-n_anon ].name()[0] == '#' ) + n_anon ++; + for( unsigned int i = 0; i < base_path.nodes().size() - e.count - n_anon; i ++ ) np.nodes().push_back( base_path.nodes()[i] ); np += path; return np; |