fmt: mark imports as used, when types from them are used in struct declarations (#8810)
parent
a34a1ab864
commit
0d69d97143
|
@ -674,6 +674,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for embed in node.embeds {
|
for embed in node.embeds {
|
||||||
|
f.mark_types_import_as_used(embed.typ)
|
||||||
styp := f.table.type_to_str(embed.typ)
|
styp := f.table.type_to_str(embed.typ)
|
||||||
f.writeln('\t$styp')
|
f.writeln('\t$styp')
|
||||||
}
|
}
|
||||||
|
@ -728,6 +729,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
|
||||||
}
|
}
|
||||||
f.write(strings.repeat(` `, field_align.max_len - field.name.len - comments_len))
|
f.write(strings.repeat(` `, field_align.max_len - field.name.len - comments_len))
|
||||||
f.write(field_types[i])
|
f.write(field_types[i])
|
||||||
|
f.mark_types_import_as_used(field.typ)
|
||||||
attrs_len := inline_attrs_len(field.attrs)
|
attrs_len := inline_attrs_len(field.attrs)
|
||||||
has_attrs := field.attrs.len > 0
|
has_attrs := field.attrs.len > 0
|
||||||
if has_attrs {
|
if has_attrs {
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
import math { max, min }
|
import math { max, min }
|
||||||
|
import cli { Command }
|
||||||
import math.complex { complex, Complex }
|
import math.complex { complex, Complex }
|
||||||
import os {
|
import os {
|
||||||
user_os,
|
user_os,
|
||||||
file_ext,
|
file_ext,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct App {
|
||||||
|
command Command
|
||||||
|
}
|
||||||
|
|
||||||
fn imaginary(im f64) Complex {
|
fn imaginary(im f64) Complex {
|
||||||
return complex(0, im)
|
return complex(0, im)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
import math { max,
|
import math { max,
|
||||||
min,
|
min,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import cli { Command }
|
||||||
import math.complex { complex, Complex }
|
import math.complex { complex, Complex }
|
||||||
import os {
|
import os {
|
||||||
input, user_os, file_ext }
|
input, user_os, file_ext }
|
||||||
|
|
||||||
|
struct App {
|
||||||
|
command Command
|
||||||
|
}
|
||||||
|
|
||||||
fn imaginary(im f64) Complex {
|
fn imaginary(im f64) Complex {
|
||||||
return complex(0, im)
|
return complex(0, im)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue