diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2023-04-27 21:21:19 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-28 05:55:20 +0200 |
commit | 7e6341587ba174309989ddebf7cc6a489751b0a8 (patch) | |
tree | c6c3c2cd4473340f03c513c8995a4a7751f6237b /Meta/Lagom | |
parent | cc35bab143e022baf570e910c0a14dbf62ff2cdd (diff) | |
download | serenity-7e6341587ba174309989ddebf7cc6a489751b0a8.zip |
AK+Everywhere: Disallow Error::from_string_view(FooString)
That pattern seems to show up a lot in code written by people that
aren't intimately familiar with the lifetime model of Error and Strings.
This commit makes the compiler detect it and present a more helpful
diagnostic than "garbage string at runtime".
Diffstat (limited to 'Meta/Lagom')
-rw-r--r-- | Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index 3cecec74d7..4a016c55ce 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -372,7 +372,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read); if (file_or_error.is_error()) { s_error_string = DeprecatedString::formatted("Unable to open file {}", path); - return Error::from_string_view(s_error_string); + return Error::from_string_view(s_error_string.view()); } auto file = file_or_error.release_value(); auto string = MUST(file->read_until_eof()); @@ -429,7 +429,7 @@ static ErrorOr<ExposedTo> parse_exposure_set(IDL::Interface& interface) auto maybe_exposed = interface.extended_attributes.get("Exposed"); if (!maybe_exposed.has_value()) { s_error_string = DeprecatedString::formatted("Interface {} is missing extended attribute Exposed", interface.name); - return Error::from_string_view(s_error_string); + return Error::from_string_view(s_error_string.view()); } auto exposed = maybe_exposed.value().trim_whitespace(); if (exposed == "*"sv) @@ -459,18 +459,18 @@ static ErrorOr<ExposedTo> parse_exposure_set(IDL::Interface& interface) whom |= ExposedTo::AudioWorklet; } else { s_error_string = DeprecatedString::formatted("Unknown Exposed attribute candidate {} in {} in {}", candidate, exposed, interface.name); - return Error::from_string_view(s_error_string); + return Error::from_string_view(s_error_string.view()); } } if (whom == ExposedTo::Nobody) { s_error_string = DeprecatedString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name); - return Error::from_string_view(s_error_string); + return Error::from_string_view(s_error_string.view()); } return whom; } s_error_string = DeprecatedString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name); - return Error::from_string_view(s_error_string); + return Error::from_string_view(s_error_string.view()); } ErrorOr<void> add_to_interface_sets(IDL::Interface& interface, Vector<IDL::Interface&>& intrinsics, Vector<IDL::Interface&>& window_exposed, Vector<IDL::Interface&>& dedicated_worker_exposed, Vector<IDL::Interface&>& shared_worker_exposed) |