From cd197654e7e6fb957fad5e9a8f3d162a5208dcc8 Mon Sep 17 00:00:00 2001 From: Jack Stouffer Date: Mon, 7 May 2018 11:03:54 -0400 Subject: [PATCH] Remove template wide trusted in std.array --- std/array.d | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/std/array.d b/std/array.d index 4d2d5f09c..6fa865621 100644 --- a/std/array.d +++ b/std/array.d @@ -229,15 +229,15 @@ Returns: a `dchar[]`, `const(dchar)[]`, or `immutable(dchar)[]` depending on the constness of the input. */ -@trusted ElementType!String[] array(String)(scope String str) +ElementType!String[] array(String)(scope String str) if (isNarrowString!String) { import std.utf : toUTF32; - /* This function is @trusted because the following cast - * is unsafe - converting a dstring[] to a dchar[], for example. - * Our special knowledge of toUTF32 is needed to know the cast is safe. + auto temp = str.toUTF32; + /* Unsafe cast. Allowed because toUTF32 makes a new array + and copies all the elements. */ - return cast(typeof(return)) str.toUTF32; + return () @trusted { return cast(ElementType!String[]) temp; } (); } ///