Ensure getAndPopFront/getAndPopBack don't promote system to safe

This commit is contained in:
Nathan Sashihara 2019-04-19 09:34:30 -04:00
parent 76bda0ac8d
commit b2a1a849f8

View File

@ -1566,6 +1566,12 @@ in (!range.empty)
{ {
static if (hasLvalueElements!R) 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())(); auto el = (() @trusted => &range.front())();
} }
else else
@ -1613,6 +1619,12 @@ in (!range.empty)
{ {
static if (hasLvalueElements!R) 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())(); auto el = (() @trusted => &range.back())();
} }
else else