Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen

In particular I wanted the change that makes `suspend;` illegal in the
parser.
This commit is contained in:
Andrew Kelley
2021-04-24 10:44:41 -07:00
73 changed files with 1160 additions and 468 deletions

View File

@@ -269,7 +269,12 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
try renderToken(ais, tree, suspend_token, .space);
return renderExpression(gpa, ais, tree, body, space);
} else {
return renderToken(ais, tree, suspend_token, space);
// TODO remove this special case when 0.9.0 is released.
assert(space == .semicolon);
try renderToken(ais, tree, suspend_token, .space);
try ais.writer().writeAll("{}");
try ais.insertNewline();
return;
}
},
@@ -2310,9 +2315,9 @@ fn renderComments(ais: *Ais, tree: ast.Tree, start: usize, end: usize) Error!boo
// to the underlying writer, fixing up invaild whitespace.
const disabled_source = tree.source[ais.disabled_offset.?..comment_start];
try writeFixingWhitespace(ais.underlying_writer, disabled_source);
ais.disabled_offset = null;
// Write with the canonical single space.
try ais.writer().writeAll("// zig fmt: on\n");
try ais.underlying_writer.writeAll("// zig fmt: on\n");
ais.disabled_offset = null;
} else if (ais.disabled_offset == null and mem.eql(u8, comment_content, "zig fmt: off")) {
// Write with the canonical single space.
try ais.writer().writeAll("// zig fmt: off\n");