Use error object instead of lambda for error collection.
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::visit):
Collect error instead of lambda.
* resolve/rust-early-name-resolver-2.0.h (std::function<void):
Remove type alias.
* rust-diagnostics.h: Change collection type.
* rust-session-manager.cc (Session::expansion): Change
collection container.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
// if the definition still does not have a value, then it's an error
if (!definition.has_value ())
{
- collect_error ([&] () {
- rust_error_at (invoc.get_locus (), ErrorCode::E0433,
- "could not resolve macro invocation");
- });
+ collect_error (Error (invoc.get_locus (), ErrorCode::E0433,
+ "could not resolve macro invocation"));
return;
}
namespace Rust {
namespace Resolver2_0 {
-using ResolveError = std::function<void ()>;
-
class Early : public DefaultResolver
{
using DefaultResolver::visit;
void go (AST::Crate &crate);
- const std::vector<ResolveError> &get_macro_resolve_errors () const
+ const std::vector<Error> &get_macro_resolve_errors () const
{
return macro_resolve_errors;
}
};
TextualScope textual_scope;
- std::vector<ResolveError> macro_resolve_errors;
+ std::vector<Error> macro_resolve_errors;
- void collect_error (ResolveError e) { macro_resolve_errors.push_back (e); }
+ void collect_error (Error e) { macro_resolve_errors.push_back (e); }
};
} // namespace Resolver2_0
#define RUST_DIAGNOSTICS_H
#include "rust-linemap.h"
+#include "util/optional.h"
// This macro is used to specify the position of format string & it's
// arguments within the function's paramter list.
/* expand by calling cxtctxt object's monotonic_expander's expand_crate
* method. */
MacroExpander expander (crate, cfg, *this);
- std::vector<Resolver2_0::ResolveError> macro_errors;
+ std::vector<Error> macro_errors;
while (!fixed_point_reached && iterations < cfg.recursion_limit)
{
// Fixed point reached: Emit unresolved macros error
for (auto &error : macro_errors)
- error ();
+ error.emit ();
if (iterations == cfg.recursion_limit)
{