diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-08-30 17:13:36 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-08-31 14:27:34 +0000 |
commit | 4d49db696bc79a9a9b33c1817bfd372dcc46ac61 (patch) | |
tree | dc814bc6ac75d6be14e990fab4985a706e23d1c1 /gcc | |
parent | 764a6c27038a5df8c0c14b1df446382b0c0fdf18 (diff) | |
download | gcc-4d49db696bc79a9a9b33c1817bfd372dcc46ac61.zip gcc-4d49db696bc79a9a9b33c1817bfd372dcc46ac61.tar.gz gcc-4d49db696bc79a9a9b33c1817bfd372dcc46ac61.tar.bz2 |
Collect error instance instead of lambda functions
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 6 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-early-name-resolver-2.0.h | 8 | ||||
-rw-r--r-- | gcc/rust/rust-diagnostics.h | 1 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 4 |
4 files changed, 8 insertions, 11 deletions
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc index a201bc4..e6603cf 100644 --- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc @@ -135,10 +135,8 @@ Early::visit (AST::MacroInvocation &invoc) // 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; } diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.h b/gcc/rust/resolve/rust-early-name-resolver-2.0.h index 67785d0..f2b63c9 100644 --- a/gcc/rust/resolve/rust-early-name-resolver-2.0.h +++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.h @@ -28,8 +28,6 @@ namespace Rust { namespace Resolver2_0 { -using ResolveError = std::function<void ()>; - class Early : public DefaultResolver { using DefaultResolver::visit; @@ -39,7 +37,7 @@ public: 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; } @@ -83,9 +81,9 @@ private: }; 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 diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h index 84ab07f..e88a762 100644 --- a/gcc/rust/rust-diagnostics.h +++ b/gcc/rust/rust-diagnostics.h @@ -22,6 +22,7 @@ #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. diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 13380a4..140bc2c 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -874,7 +874,7 @@ Session::expansion (AST::Crate &crate) /* 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) { @@ -903,7 +903,7 @@ Session::expansion (AST::Crate &crate) // Fixed point reached: Emit unresolved macros error for (auto &error : macro_errors) - error (); + error.emit (); if (iterations == cfg.recursion_limit) { |