diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-08-02 16:45:42 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 19:00:33 +0100 |
commit | 750ac3263c8db064b1d6b3ae33ec6a2036e38bb8 (patch) | |
tree | 7a12d738f3cccce0b0592be1fd4eb90e3469bc20 /gcc/rust/expand | |
parent | 04d6111e6e68cb4b7f53027ed35a47241dfc7165 (diff) | |
download | gcc-750ac3263c8db064b1d6b3ae33ec6a2036e38bb8.zip gcc-750ac3263c8db064b1d6b3ae33ec6a2036e38bb8.tar.gz gcc-750ac3263c8db064b1d6b3ae33ec6a2036e38bb8.tar.bz2 |
gccrs: Improve byte vector to string conversion
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(MacroBuiltin::include_str_handler): Use vector::data.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r-- | gcc/rust/expand/rust-macro-builtins.cc | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index 718d740..b36a46f 100644 --- a/gcc/rust/expand/rust-macro-builtins.cc +++ b/gcc/rust/expand/rust-macro-builtins.cc @@ -576,10 +576,8 @@ MacroBuiltin::include_str_handler (location_t invoc_locus, if (expect_single) rust_error_at (invoc_locus, "%s was not a valid utf-8 file", target_filename.c_str ()); - else if (!bytes.empty ()) - str = std::string ((const char *) &bytes[0], bytes.size ()); else - return tl::nullopt; + str = std::string ((const char *) bytes.data (), bytes.size ()); auto node = AST::SingleASTNode (make_string (invoc_locus, str)); auto str_tok = make_token (Token::make_string (invoc_locus, std::move (str))); |