Skip to content

Commit ba4db84

Browse files
powerboat9CohenArthur
authored andcommitted
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 <[email protected]>
1 parent 8fcbb07 commit ba4db84

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

gcc/rust/expand/rust-macro-builtins.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,8 @@ MacroBuiltin::include_str_handler (location_t invoc_locus,
576576
if (expect_single)
577577
rust_error_at (invoc_locus, "%s was not a valid utf-8 file",
578578
target_filename.c_str ());
579-
else if (!bytes.empty ())
580-
str = std::string ((const char *) &bytes[0], bytes.size ());
581579
else
582-
return tl::nullopt;
580+
str = std::string ((const char *) bytes.data (), bytes.size ());
583581

584582
auto node = AST::SingleASTNode (make_string (invoc_locus, str));
585583
auto str_tok = make_token (Token::make_string (invoc_locus, std::move (str)));

0 commit comments

Comments
 (0)