From ec5da37dbfbcc55183f7ea4658c8856b9335ad61 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Tue, 5 Jul 2022 16:56:14 +0100 Subject: Refactor Lexer to support an abstract InputSource class This patch allows us to remove the fmemopen lex_string hack to support parsing buffers. This will allow us to support mutliple sources such as metadata imports etc. The patch here updates the parser to hold onto a reference to the lexer rather than 'owning' the lexer which allows us to decouple the move semantics here. Fixes #1203 #1000 --- gcc/rust/ast/rust-ast-full-test.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'gcc/rust/ast') diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc index d98a7cf..7cccd40 100644 --- a/gcc/rust/ast/rust-ast-full-test.cc +++ b/gcc/rust/ast/rust-ast-full-test.cc @@ -4058,8 +4058,7 @@ Module::load_items () RAIIFile file_wrap (module_file.c_str ()); Linemap *linemap = Session::get_instance ().linemap; - - if (file_wrap.get_raw () == nullptr) + if (!file_wrap.ok ()) { rust_error_at (get_locus (), "cannot open module file %s: %m", module_file.c_str ()); @@ -4069,10 +4068,9 @@ Module::load_items () rust_debug ("Attempting to parse file %s", module_file.c_str ()); Lexer lex (module_file.c_str (), std::move (file_wrap), linemap); - Parser parser (std::move (lex)); + Parser parser (lex); auto parsed_items = parser.parse_items (); - for (const auto &error : parser.get_errors ()) error.emit_error (); -- cgit v1.1