std: use std.ArrayList(u8).OutStream instead of std.Buffer.OutStream

This commit is contained in:
daurnimator 2020-03-08 18:16:10 +11:00 committed by Andrew Kelley
parent 3fb030e78a
commit e535057364
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
5 changed files with 12 additions and 11 deletions

View File

@ -321,7 +321,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
var last_action = Action.Open;
var last_columns: ?u8 = null;
var toc_buf = try std.Buffer.initSize(allocator, 0);
var toc_buf = std.ArrayList(u8).init(allocator);
defer toc_buf.deinit();
var toc = toc_buf.outStream();
@ -607,7 +607,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
}
fn urlize(allocator: *mem.Allocator, input: []const u8) ![]u8 {
var buf = try std.Buffer.initSize(allocator, 0);
var buf = std.ArrayList(u8).init(allocator);
defer buf.deinit();
const out = buf.outStream();
@ -626,7 +626,7 @@ fn urlize(allocator: *mem.Allocator, input: []const u8) ![]u8 {
}
fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 {
var buf = try std.Buffer.initSize(allocator, 0);
var buf = std.ArrayList(u8).init(allocator);
defer buf.deinit();
const out = buf.outStream();
@ -672,7 +672,7 @@ test "term color" {
}
fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 {
var buf = try std.Buffer.initSize(allocator, 0);
var buf = std.ArrayList(u8).init(allocator);
defer buf.deinit();
var out = buf.outStream();

View File

@ -2953,7 +2953,7 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
return error.ParseError;
}
var buffer = try std.Buffer.initSize(allocator, 0);
var buffer = std.ArrayList(u8).init(allocator);
errdefer buffer.deinit();
anything_changed.* = try std.zig.render(allocator, buffer.outStream(), tree);

View File

@ -158,7 +158,7 @@ pub const Msg = struct {
parse_error: *const ast.Error,
) !*Msg {
const loc_token = parse_error.loc();
var text_buf = try std.Buffer.initSize(comp.gpa(), 0);
var text_buf = std.ArrayList(u8).init(comp.gpa());
defer text_buf.deinit();
const realpath_copy = try mem.dupe(comp.gpa(), u8, tree_scope.root().realpath);
@ -197,7 +197,7 @@ pub const Msg = struct {
realpath: []const u8,
) !*Msg {
const loc_token = parse_error.loc();
var text_buf = try std.Buffer.initSize(allocator, 0);
var text_buf = std.ArrayList(u8).init(allocator);
defer text_buf.deinit();
const realpath_copy = try mem.dupe(allocator, u8, realpath);

View File

@ -411,10 +411,11 @@ fn printErrMsgToFile(
const start_loc = tree.tokenLocationPtr(0, first_token);
const end_loc = tree.tokenLocationPtr(first_token.end, last_token);
var text_buf = try std.Buffer.initSize(allocator, 0);
var text_buf = std.ArrayList(u8).init(allocator);
defer text_buf.deinit();
const out_stream = &text_buf.outStream();
try parse_error.render(&tree.tokens, out_stream);
const text = text_buf.toOwnedSlice();
const text = text_buf.span();
const stream = &file.outStream();
try stream.print("{}:{}:{}: error: {}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });

View File

@ -387,10 +387,10 @@ pub const Type = struct {
};
errdefer comp.gpa().destroy(self);
var name_buf = try std.Buffer.initSize(comp.gpa(), 0);
var name_buf = std.ArrayList(u8).init(comp.gpa());
defer name_buf.deinit();
const name_stream = &std.io.BufferOutStream.init(&name_buf).stream;
const name_stream = name_buf.outStream();
switch (key.data) {
.Generic => |generic| {