fmt: don't add newlines for UnsafeExpr (#6048)
parent
e291c38119
commit
c33dbbc216
|
@ -56,6 +56,7 @@ jobs:
|
|||
./v fmt -verify vlib/v/fmt/fmt.v
|
||||
./v fmt -verify vlib/v/parser/parser.v
|
||||
./v fmt -verify vlib/v/gen/cgen.v
|
||||
./v fmt -verify vlib/v/gen/x64/gen.v
|
||||
# - name: Test v binaries
|
||||
# run: ./v -silent build-vbinaries
|
||||
|
||||
|
|
|
@ -1060,9 +1060,10 @@ pub fn (mut f Fmt) expr(node ast.Expr) {
|
|||
f.write(')')
|
||||
}
|
||||
ast.UnsafeExpr {
|
||||
f.writeln('unsafe {')
|
||||
f.stmts(node.stmts)
|
||||
f.writeln('}')
|
||||
f.write('unsafe {')
|
||||
es := node.stmts[0] as ast.ExprStmt
|
||||
f.expr(es.expr)
|
||||
f.write('}')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn unsafe_fn() {
|
||||
unsafe {
|
||||
malloc(2)
|
||||
_ = malloc(2)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn unsafe_fn() {
|
||||
unsafe { malloc(2) }
|
||||
unsafe { _ = malloc(2) }
|
||||
}
|
||||
|
||||
fn fn_with_defer() {
|
||||
|
|
|
@ -24,14 +24,8 @@ fn test_ptr_assign() {
|
|||
|
||||
fn test_ptr_infix() {
|
||||
v := 4
|
||||
mut q := unsafe {
|
||||
&v - 1
|
||||
}
|
||||
|
||||
q = unsafe {
|
||||
q + 3
|
||||
}
|
||||
|
||||
mut q := unsafe {&v - 1}
|
||||
q = unsafe {q + 3}
|
||||
_ := q
|
||||
_ := v
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue