static Stream *open_package (const std::string &filename, Location location,
const std::string &relative_import_path);
+ static Stream *try_package_in_directory (const std::string &, Location);
+
// Constructor.
Import (Stream *, Location);
void clear_stream () { this->stream_ = NULL; }
private:
- static Stream *try_package_in_directory (const std::string &, Location);
-
static int try_suffixes (std::string *);
static Stream *find_export_data (const std::string &filename, int fd,
}
std::string relative_import_path = "";
- Import::Stream *s
- = Import::open_package (crate_name, locus, relative_import_path);
+ std::string import_name = crate_name;
+
+ // The path to the extern crate might have been specified by the user using
+ // -frust-extern
+ auto cli_extern_crate = extern_crates.find (crate_name);
+
+ Import::Stream *s;
+ if (cli_extern_crate != extern_crates.end ())
+ {
+ auto path = cli_extern_crate->second;
+ s = Import::try_package_in_directory (path, locus);
+ }
+ else
+ {
+ s = Import::open_package (import_name, locus, relative_import_path);
+ }
if (s == NULL)
{
rust_error_at (locus, "failed to locate crate %<%s%>",
- crate_name.c_str ());
+ import_name.c_str ());
return UNKNOWN_NODEID;
}