- let target_module = match directive.target_module.get() {
- Some(module) => module,
- _ => match self.resolve_module_path(&directive.module_path, DontUseLexicalScope, None) {
+ let target_module = if let Some(module) = directive.target_module.get() {
+ module
+ } else {
+ let vis = directive.vis.get();
+ // For better failure detection, pretend that the import will not define any names
+ // while resolving its module path.
+ directive.vis.set(ty::Visibility::PrivateExternal);
+ let result =
+ self.resolve_module_path(&directive.module_path, DontUseLexicalScope, None);
+ directive.vis.set(vis);
+
+ match result {