Skip to content

rustfmt internal error #136065

Closed
Closed
@float3

Description

@float3

I tried this code:

fn show_translation_unit() {
    let m = buffers.iter()
    .map( 
        |(i, b)| format!("\n
        Pass 
            {{
                Name \"{}\"

                CGPROGRAM
                #include \"UnityCustomRenderTexture.cginc\"
                #pragma target 5.0
                #pragma vertex CustomRenderTextureVertexShader
                #pragma fragment frag  
        
                #include \"UnityCG.cginc\"
                // Built-in properties
                sampler2D _MainTex_{};   float4 _MainTex_{}_TexelSize;
                sampler2D _SecondTex_{}; float4 _SecondTex_{}_TexelSize;
                sampler2D _ThirdTex_{};  float4 _ThirdTex_{}_TexelSize;
                sampler2D _FourthTex_{}; float4 _FourthTex_{}_TexelSize;                
                float4 _Mouse;
                float _GammaCorrect;
                float _Resolution;
                float _WorldSpace;
                float4 _Offset;

                //Def CRT Res
                #ifdef iResolution
                    #undef iResolution
                    #define iResolution float3(_CustomRenderTextureWidth, _CustomRenderTextureHeight, _Resolution)
                #endif
                // GLSL Compatability macros
                #ifndef COMMON_INCLUDE_BLOCK
                #define COMMON_INCLUDE_BLOCK
                    #define glsl_mod(x,y) (((x)-(y)*floor((x)/(y))))
                    #define texelFetch(ch, uv, lod) tex2Dlod(ch, float4((uv).xy * ch##_TexelSize.xy + ch##_TexelSize.xy * 0.5, 0, lod))
                    #define textureLod(ch, uv, lod) tex2Dlod(ch, float4(uv, 0, lod))
                    #define iResolution float3(_CustomRenderTextureWidth, _CustomRenderTextureHeight, _Resolution)
                    #define iFrame (floor(_Time.y / 60))
                    #define iChannelTime float4(_Time.y, _Time.y, _Time.y, _Time.y)
                    #define iDate float4(2020, 6, 18, 30)
                    #define iSampleRate (44100)
                #endif    
                #define iChannelResolution float4x4(                      \\
                    _MainTex_{}_TexelSize.z,   _MainTex_{}_TexelSize.w,   0, 0, \\
                    _SecondTex_{}_TexelSize.z, _SecondTex_{}_TexelSize.w, 0, 0, \\
                    _ThirdTex_{}_TexelSize.z,  _ThirdTex_{}_TexelSize.w,  0, 0, \\
                    _FourthTex_{}_TexelSize.z, _FourthTex_{}_TexelSize.w, 0, 0)                
                {}
                ENDCG
            }}        
            ", i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,b))
    .collect::<Vec<_>>()
    .concat();
}

I expected to see this happen: succesful rustfmt

Instead, this happened:

error[internal]: left behind trailing whitespace
 --> [path removed]/transpiler.rs:3:3:10
  |
3 |     .map( 
  |          ^
  |

warning: rustfmt has failed to format. See previous 1 errors.

Meta

rustfmt --version:

rustfmt 1.8.0-stable (9fc6b43126 2025-01-07)
rustfmt 1.8.0-nightly (1e9b0177da 2025-01-24)
rustfmt 1.8.0-beta (4416507043 2025-01-20)

happens on all of them

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions