Merge pull request #87 from n8sh/getAndPopFrontSafety

Ensure getAndPopFront/getAndPopBack don't promote `system` to `safe`
This commit is contained in:
Eugen Wissner 2019-04-22 10:50:58 +02:00 committed by GitHub
commit 73535568b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -1566,6 +1566,12 @@ in (!range.empty)
{
static if (hasLvalueElements!R)
{
if (false)
{
// This code is removed by the compiler but ensures that
// this function isn't @safe if range.front isn't @safe.
auto _ = range.front();
}
auto el = (() @trusted => &range.front())();
}
else
@ -1613,6 +1619,12 @@ in (!range.empty)
{
static if (hasLvalueElements!R)
{
if (false)
{
// This code is removed by the compiler but ensures that
// this function isn't @safe if range.back isn't @safe.
auto _ = range.back();
}
auto el = (() @trusted => &range.back())();
}
else