mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 12:06:07 +00:00
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".
This commit is contained in:
parent
cc35bab143
commit
7e6341587b
Notes:
sideshowbarker
2024-07-17 09:41:18 +09:00
Author: https://github.com/alimpfard
Commit: 7e6341587b
Pull-request: https://github.com/SerenityOS/serenity/pull/18542
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/trflynn89
7 changed files with 29 additions and 14 deletions
|
@ -45,7 +45,7 @@ static ErrorOr<int> weekday_index(StringView weekday_name)
|
|||
if (auto numeric_weekday = AK::StringUtils::convert_to_int(weekday_name); numeric_weekday.has_value())
|
||||
return numeric_weekday.value();
|
||||
|
||||
return Error::from_string_view(TRY(String::formatted("Unknown weekday name: '{}'", weekday_name)));
|
||||
return Error::from_string_view("Unknown weekday name"sv);
|
||||
}
|
||||
|
||||
static ErrorOr<int> default_weekday_start()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue