Skip to content

Commit 5d0cfcd

Browse files
dkorpeldlang-bot
authored andcommitted
Fix scope usage of SysTime/TimeZone
1 parent 62780da commit 5d0cfcd

File tree

5 files changed

+59
-58
lines changed

5 files changed

+59
-58
lines changed

std/datetime/interval.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -8349,7 +8349,7 @@ private:
83498349
}
83508350

83518351
{
8352-
SysTime stFunc(scope const SysTime st) { return cast(SysTime) st; }
8352+
SysTime stFunc(scope const SysTime st) { return SysTime.init; }
83538353
auto interval = Interval!SysTime(SysTime(DateTime(2010, 7, 4, 12, 1, 7)),
83548354
SysTime(DateTime(2012, 1, 7, 14, 0, 0)));
83558355
auto ir = IntervalRange!(SysTime, Direction.fwd)(interval, &stFunc);
@@ -8794,7 +8794,7 @@ private:
87948794
}
87958795

87968796
{
8797-
SysTime stFunc(scope const SysTime st) { return cast(SysTime) st; }
8797+
SysTime stFunc(scope const SysTime st) { return SysTime.init; }
87988798
auto posInfInterval = PosInfInterval!SysTime(SysTime(DateTime(2010, 7, 4, 12, 1, 7)));
87998799
auto ir = PosInfIntervalRange!SysTime(posInfInterval, &stFunc);
88008800
}
@@ -9076,7 +9076,7 @@ private:
90769076
}
90779077

90789078
{
9079-
SysTime stFunc(scope const SysTime st) { return cast(SysTime)(st); }
9079+
SysTime stFunc(scope const SysTime st) { return SysTime.init; }
90809080
auto negInfInterval = NegInfInterval!SysTime(SysTime(DateTime(2012, 1, 7, 14, 0, 0)));
90819081
auto ir = NegInfIntervalRange!(SysTime)(negInfInterval, &stFunc);
90829082
}

std/datetime/systime.d

+14-13
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ public:
503503
given $(REF DateTime,std,datetime,date) is assumed to
504504
be in the given time zone.
505505
+/
506-
this(DateTime dateTime, immutable TimeZone tz = null) @safe nothrow
506+
this(DateTime dateTime, return scope immutable TimeZone tz = null) return scope @safe nothrow
507507
{
508508
try
509509
this(dateTime, Duration.zero, tz);
@@ -554,7 +554,7 @@ public:
554554
$(REF DateTimeException,std,datetime,date) if `fracSecs` is negative or if it's
555555
greater than or equal to one second.
556556
+/
557-
this(DateTime dateTime, Duration fracSecs, immutable TimeZone tz = null) @safe
557+
this(DateTime dateTime, Duration fracSecs, return scope immutable TimeZone tz = null) return scope @safe
558558
{
559559
enforce(fracSecs >= Duration.zero, new DateTimeException("A SysTime cannot have negative fractional seconds."));
560560
enforce(fracSecs < seconds(1), new DateTimeException("Fractional seconds must be less than one second."));
@@ -611,7 +611,7 @@ public:
611611
given $(REF Date,std,datetime,date) is assumed to be in the
612612
given time zone.
613613
+/
614-
this(Date date, immutable TimeZone tz = null) @safe nothrow
614+
this(Date date, return scope immutable TimeZone tz = null) return scope @safe nothrow
615615
{
616616
_timezone = tz is null ? LocalTime() : tz;
617617

@@ -664,7 +664,7 @@ public:
664664
$(LREF SysTime). If null,
665665
$(REF LocalTime,std,datetime,timezone) will be used.
666666
+/
667-
this(long stdTime, immutable TimeZone tz = null) @safe pure nothrow
667+
this(long stdTime, return scope immutable TimeZone tz = null) return scope @safe pure nothrow
668668
{
669669
_stdTime = stdTime;
670670
_timezone = tz is null ? LocalTime() : tz;
@@ -693,7 +693,7 @@ public:
693693

694694
Returns: The `this` of this `SysTime`.
695695
+/
696-
ref SysTime opAssign()(auto ref const(SysTime) rhs) return @safe pure nothrow scope
696+
ref SysTime opAssign()(auto ref const(SysTime) rhs) return scope @safe pure nothrow
697697
{
698698
_stdTime = rhs._stdTime;
699699
_timezone = rhs._timezone;
@@ -710,6 +710,7 @@ public:
710710
st = other;
711711
assert(st == other);
712712

713+
version (none) // https://issues.dlang.org/show_bug.cgi?id=21175
713714
static void testScope(scope ref SysTime left, const scope SysTime right) @safe
714715
{
715716
left = right;
@@ -2184,7 +2185,7 @@ public:
21842185
hours - adjust the time to this $(LREF SysTime)'s time zone before
21852186
returning.
21862187
+/
2187-
@property immutable(TimeZone) timezone() @safe const pure nothrow scope
2188+
@property immutable(TimeZone) timezone() @safe const pure nothrow return scope
21882189
{
21892190
return _timezone;
21902191
}
@@ -2238,7 +2239,7 @@ public:
22382239
/++
22392240
Returns whether DST is in effect for this $(LREF SysTime).
22402241
+/
2241-
@property bool dstInEffect() @safe const nothrow scope
2242+
@property bool dstInEffect() @safe const nothrow return scope
22422243
{
22432244
return _timezone.dstInEffect(_stdTime);
22442245
}
@@ -2261,7 +2262,7 @@ public:
22612262
Returns what the offset from UTC is for this $(LREF SysTime).
22622263
It includes the DST offset in effect at that time (if any).
22632264
+/
2264-
@property Duration utcOffset() @safe const nothrow scope
2265+
@property Duration utcOffset() @safe const nothrow return scope
22652266
{
22662267
return _timezone.utcOffsetAt(_stdTime);
22672268
}
@@ -9586,13 +9587,13 @@ private:
95869587

95879588
@property override bool hasDST() @safe const nothrow @nogc { return false; }
95889589

9589-
override bool dstInEffect(long stdTime) @safe const nothrow @nogc { return false; }
9590+
override bool dstInEffect(long stdTime) @safe const scope nothrow @nogc { return false; }
95909591

9591-
override long utcToTZ(long stdTime) @safe const nothrow @nogc { return 0; }
9592+
override long utcToTZ(long stdTime) @safe const scope nothrow @nogc { return 0; }
95929593

9593-
override long tzToUTC(long adjTime) @safe const nothrow @nogc { return 0; }
9594+
override long tzToUTC(long adjTime) @safe const scope nothrow @nogc { return 0; }
95949595

9595-
override Duration utcOffsetAt(long stdTime) @safe const nothrow @nogc { return Duration.zero; }
9596+
override Duration utcOffsetAt(long stdTime) @safe const scope nothrow @nogc { return Duration.zero; }
95969597

95979598
private:
95989599

@@ -9628,7 +9629,7 @@ private:
96289629
return _timezoneStorage is null ? InitTimeZone() : _timezoneStorage;
96299630
}
96309631

9631-
pragma(inline, true) @property void _timezone(immutable TimeZone tz) @safe pure nothrow @nogc scope
9632+
pragma(inline, true) @property void _timezone(return scope immutable TimeZone tz) @safe pure nothrow @nogc scope
96329633
{
96339634
_timezoneStorage = tz;
96349635
}

0 commit comments

Comments
 (0)