// stop; we do not keep looking for another file with the same name
// later in the search path.
-Import::Stream *
+std::pair<Import::Stream *, std::vector<ProcMacro::Procmacro>>
Import::open_package (const std::string &filename, Location location,
const std::string &relative_import_path)
{
if (!indir.empty () && indir[indir.size () - 1] != '/')
indir += '/';
indir += fn;
- Stream *s = Import::try_package_in_directory (indir, location);
- if (s != NULL)
+ auto s = Import::try_package_in_directory (indir, location);
+ if (s.first != NULL)
return s;
}
}
- Stream *s = Import::try_package_in_directory (fn, location);
- if (s != NULL)
+ auto s = Import::try_package_in_directory (fn, location);
+ if (s.first != NULL)
return s;
- return NULL;
+ return std::make_pair (NULL, std::vector<ProcMacro::Procmacro>{});
}
// Try to find the export data for FILENAME.
-Import::Stream *
+std::pair<Import::Stream *, std::vector<ProcMacro::Procmacro>>
Import::try_package_in_directory (const std::string &filename,
Location location)
{
fd = Import::try_suffixes (&found_filename);
if (fd < 0)
- return NULL;
+ return std::make_pair (NULL, std::vector<ProcMacro::Procmacro>{});
}
// The export data may not be in this file.
Stream *s = Import::find_export_data (found_filename, fd, location);
if (s != NULL)
- return s;
+ return std::make_pair (s, std::vector<ProcMacro::Procmacro>{});
close (fd);
"%s exists but does not contain any Rust export data",
found_filename.c_str ());
- return NULL;
+ return std::make_pair (NULL, std::vector<ProcMacro::Procmacro>{});
}
// Given import "*PFILENAME", where *PFILENAME does not exist, try
#include "rust-system.h"
#include "rust-location.h"
+#include "rust-proc-macro.h"
namespace Rust {
// returns a pointer to a Stream object to read the data that it
// exports. LOCATION is the location of the import statement.
// RELATIVE_IMPORT_PATH is used as a prefix for a relative import.
- static Stream *open_package (const std::string &filename, Location location,
- const std::string &relative_import_path);
+ static std::pair<Stream *, std::vector<ProcMacro::Procmacro>>
+ open_package (const std::string &filename, Location location,
+ const std::string &relative_import_path);
- static Stream *try_package_in_directory (const std::string &, Location);
+ static std::pair<Stream *, std::vector<ProcMacro::Procmacro>>
+ try_package_in_directory (const std::string &, Location);
// Constructor.
Import (Stream *, Location);
// -frust-extern
auto cli_extern_crate = extern_crates.find (crate_name);
- Import::Stream *s;
+ std::pair<Import::Stream *, std::vector<ProcMacro::Procmacro>> s;
if (cli_extern_crate != extern_crates.end ())
{
auto path = cli_extern_crate->second;
{
s = Import::open_package (import_name, locus, relative_import_path);
}
- if (s == NULL)
+ if (s.first == NULL)
{
rust_error_at (locus, "failed to locate crate %<%s%>",
import_name.c_str ());
return UNKNOWN_NODEID;
}
- Imports::ExternCrate extern_crate (*s);
+ Imports::ExternCrate extern_crate (*s.first);
bool ok = extern_crate.load (locus);
if (!ok)
{