std.heap: delete LoggingAllocator and friends

I don't think these belong in std, at least not in their current form.

If someone wants to add these back I'd like to review the patch before
it lands.

Reverts 629e2e7844
This commit is contained in:
Andrew Kelley
2025-02-03 21:07:49 -08:00
parent 0d8166be3f
commit f1717777a2
4 changed files with 0 additions and 329 deletions

View File

@@ -493,49 +493,6 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
\\
);
// It is required to override the log function in order to print to stdout instead of stderr
cases.add("std.heap.LoggingAllocator logs to std.log",
\\const std = @import("std");
\\
\\pub const std_options: std.Options = .{
\\ .log_level = .debug,
\\ .logFn = log,
\\};
\\
\\pub fn main() !void {
\\ var allocator_buf: [10]u8 = undefined;
\\ const fba = std.heap.FixedBufferAllocator.init(&allocator_buf);
\\ var fba_wrapped = std.mem.validationWrap(fba);
\\ var logging_allocator = std.heap.loggingAllocator(fba_wrapped.allocator());
\\ const allocator = logging_allocator.allocator();
\\
\\ var a = try allocator.alloc(u8, 10);
\\ try std.testing.expect(allocator.resize(a, 5));
\\ a = a[0..5];
\\ try std.testing.expect(a.len == 5);
\\ try std.testing.expect(!allocator.resize(a, 20));
\\ allocator.free(a);
\\}
\\
\\pub fn log(
\\ comptime level: std.log.Level,
\\ comptime scope: @TypeOf(.EnumLiteral),
\\ comptime format: []const u8,
\\ args: anytype,
\\) void {
\\ const level_txt = comptime level.asText();
\\ const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): ";
\\ const stdout = std.io.getStdOut().writer();
\\ nosuspend stdout.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return;
\\}
,
\\debug: alloc - success - len: 10, ptr_align: 0
\\debug: shrink - success - 10 to 5, buf_align: 0
\\error: expand - failure - 5 to 20, buf_align: 0
\\debug: free - len: 5
\\
);
cases.add("valid carriage return example", "const io = @import(\"std\").io;\r\n" ++ // Testing CRLF line endings are valid
"\r\n" ++
"pub \r fn main() void {\r\n" ++ // Testing isolated carriage return as whitespace is valid