Describe the bug
Rustfmt removes argument attribute when line is long!
To Reproduce
temp.rs#[macro_export]
macro_rules! main {
() => {
#[spirv(fragment)]
pub fn main_fs(
mut out_color: ::spirv_std::storage_class::Output<Vec4>,
#[spirv(frag_coord)] frag_coord: ::spirv_std::storage_class::Input<
::spirv_std::glam::Vec4,
>,
#[spirv(descriptor_set = 1)] iChannel0: ::spirv_std::storage_class::UniformConstant<
::spirv_std::SampledImage<::spirv_std::Image2d>,
>,
#[spirv(descriptor_set = 1)] iChannel1: ::spirv_std::storage_class::UniformConstant<
::spirv_std::SampledImage<::spirv_std::Image2d>,
>,
#[spirv(descriptor_set = 1)] iChannel2: ::spirv_std::storage_class::UniformConstant<
::spirv_std::SampledImage<::spirv_std::Image2d>,
>,
#[spirv(descriptor_set = 1)] iChannel3: ::spirv_std::storage_class::UniformConstant<
::spirv_std::SampledImage<::spirv_std::Image2d>,
>,
#[spirv(descriptor_set = 1)] iResolution: ::spirv_std::storage_class::UniformConstant<
::spirv_std::glam::Vec3A,
>,
#[spirv(descriptor_set = 1)] iTime: ::spirv_std::storage_class::UniformConstant<f32>,
#[spirv(descriptor_set = 1)] iMouse: ::spirv_std::storage_class::UniformConstant<
::spirv_std::glam::Vec4,
>,
#[spirv(descriptor_set = 1)] iDate: ::spirv_std::storage_class::UniformConstant<
::spirv_std::glam::Vec4,
>,
#[spirv(descriptor_set = 1)] iSampleRate: ::spirv_std::storage_class::UniformConstant<
f32,
>,
#[spirv(descriptor_set = 1)] iFrame: ::spirv_std::storage_class::UniformConstant<i32>,
#[spirv(descriptor_set = 1)] iTimeDelta: ::spirv_std::storage_class::UniformConstant<
f32,
>,
#[spirv(descriptor_set = 1)] iFrameRate: ::spirv_std::storage_class::UniformConstant<
f32,
>,
#[spirv(descriptor_set = 1)] iChannelTime: ::spirv_std::storage_class::UniformConstant<
[f32; 4],
>,
#[spirv(descriptor_set = 1)] iChannelResolution: ::spirv_std::storage_class::UniformConstant<
[::spirv_std::glam::Vec3A; 4],
>,
#[spirv(descriptor_set = 1)] unViewport: ::spirv_std::storage_class::UniformConstant<
::spirv_std::glam::Vec4,
>,
#[spirv(descriptor_set = 1)] unCorners: ::spirv_std::storage_class::UniformConstant<
[::spirv_std::glam::Vec3A; 5],
>,
) {
}
};
}
rustfmt temp.rs#[spirv(descriptor_set = 1)] attribute from the iChannelResolution arg!// ...
#[spirv(descriptor_set = 1)] iChannelTime: ::spirv_std::storage_class::UniformConstant<
[f32; 4],
>,
iChannelResolution: ::spirv_std::storage_class::UniformConstant<
[::spirv_std::glam::Vec3A; 4],
>,
#[spirv(descriptor_set = 1)] unViewport: ::spirv_std::storage_class::UniformConstant<
::spirv_std::glam::Vec4,
>,
#[spirv(descriptor_set = 1)] unCorners: ::spirv_std::storage_class::UniformConstant<
[::spirv_std::glam::Vec3A; 5],
>,
) {
}
};
}
Expected behavior
Don't remove any attributes.
Meta
rustfmt 1.4.27-nightly (580d826 2020-11-16)rustfmtSettings:
edition = "2018"
version = "Two"
newline_style = "Unix"
use_small_heuristics = "Max"
hard_tabs = true
merge_imports = true
reorder_impl_items = true
use_field_init_shorthand = true
use_try_shorthand = true
spaces_around_ranges = true
overflow_delimited_expr = true
Simpler snippet, which can be used for repro even with the defaults in the released 1.x versions
#[macro_export]
macro_rules! main {
() => {
#[spirv(fragment)]
pub fn main_fs(
mut out_color: ::spirv_std::storage_class::Output<Vec4>,
#[spirv(descriptor_set = 1)] iChannelResolution: ::spirv_std::storage_class::UniformConstant<
[::spirv_std::glam::Vec3A; 4],
>,
) {
}
};
}
For anyone interested in working on this, note that it's not reproducible in source on master so be sure any fixes are based on the 1.x branches (current branch at time of this posting would be 1.4.29)
Can I working on this? I want to have a try.
@chansuke
Can I working on this? I want to have a try.
Sure! I want to say that subsequent to the last post I've backported some changes that touched the attribute formatting code, so it might be worthwhile to first check whether this can still be reproduced on the latest branch (rustfmt-1.4.31). Obviously if it's still reproducible then the fix from master is still pending, but even if it has already been resolved it would still be helpful to add tests which cover this case to avoid any potential regressions
@calebcartwright Thanks for the comment! I will take a look at the latest branch first.
I have tested on rustfmt-1.4.31 branch and the error is still reproducible.
Most helpful comment
Can I working on this? I want to have a try.