Skip to content

[Backtracing] Rename unsafeFirst to consumingFirst. #80214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/public/libexec/swift-backtrace/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ extension Sequence {
/// This is not, in general, a safe thing to do, because the sequence might
/// not be restartable. For the cases where we're using it here, it's OK
/// though.
public var unsafeFirst: Element? {
var consumingFirst: Element? {
var iterator = makeIterator()
return iterator.next()
}
Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/libexec/swift-backtrace/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1008,14 +1008,14 @@ Generate a backtrace for the parent process.
let formatter = backtraceFormatter()
switch thread.backtrace {
case let .raw(backtrace):
if let frame = backtrace.frames.unsafeFirst {
if let frame = backtrace.frames.consumingFirst {
let formatted = formatter.format(frame: frame)
writeln("\(formatted)")
}
case let .symbolicated(backtrace):
if let frame = backtrace.frames.drop(while: {
$0.isSwiftRuntimeFailure
}).unsafeFirst {
}).consumingFirst {
let formatted = formatter.format(frame: frame)
writeln("\(formatted)")
}
Expand Down Expand Up @@ -1087,7 +1087,7 @@ Generate a backtrace for the parent process.

switch thread.backtrace {
case let .raw(backtrace):
if let frame = backtrace.frames.unsafeFirst {
if let frame = backtrace.frames.consumingFirst {
rows += formatter.formatRows(
frame: frame
).map{ row in
Expand All @@ -1103,7 +1103,7 @@ Generate a backtrace for the parent process.
case let .symbolicated(backtrace):
if let frame = backtrace.frames.drop(while: {
$0.isSwiftRuntimeFailure
}).unsafeFirst {
}).consumingFirst {
rows += formatter.formatRows(
frame: frame
).map{ row in
Expand Down