Stream: compiler development

Topic: Rust help or ... should I just go to bed?


view this post on Zulip Anthony Bullard (Jan 07 2025 at 03:55):

I've been staring at this test for awhile - and I'm so confused by these two logs(from the same site) ran in succession on the same test case:

is_multiline: true, item: PncApply(
    @0-1 NumLiteral(
        "1",
    ),
    [
        @2-3 Identifier {
            ident: "i",
        },
        @4-5 SpaceAfter(
            Identifier {
                ident: "p",
            },
            [
                LineComment(
                    "",
                ),
            ],
        ),
    ],
)

is_multiline: false, item: PncApply(
    @0-1 NumLiteral(
        "1",
    ),
    Collection {
        items: [
            @7-8 SpaceBefore(
                Identifier {
                    ident: "i",
                },
                [
                    Newline,
                ],
            ),
            @14-15 SpaceBefore(
                Identifier {
                    ident: "p",
                },
                [
                    Newline,
                ],
            ),
        ],
        final_comments: [
            LineComment(
                "",
            ),
        ],
    },
)

One shows that the enum variant's second arg is a slice and in the other that same enum variant's second arg is an ast::Collection.

Is there something I don't know about in Rust that could be going on here?

view this post on Zulip Richard Feldman (Jan 07 2025 at 04:19):

is it actually a slice, or do we have a custom Debug implementation which is printing it out as [ ... ] in some situations but not all situations?

view this post on Zulip Sam Mohr (Jan 07 2025 at 04:20):

Feels like the latter, but can't tell without seeing the code

view this post on Zulip Anthony Bullard (Jan 07 2025 at 11:29):

I have this line:

println!("Pattern::PncApply args {:#?}", args);

view this post on Zulip Anthony Bullard (Jan 07 2025 at 11:29):

And it also does the same thing

view this post on Zulip Anthony Bullard (Jan 07 2025 at 11:30):

Pattern::PncApply args [
    @2-3 Identifier {
        ident: "i",
    },
    @4-5 SpaceAfter(
        Identifier {
            ident: "p",
        },
        [
            LineComment(
                "",
            ),
        ],
    ),
]

view this post on Zulip Anthony Bullard (Jan 07 2025 at 11:30):

Pattern::PncApply args Collection {
    items: [
        @7-8 SpaceBefore(
            Identifier {
                ident: "i",
            },
            [
                Newline,
            ],
        ),
        @14-15 SpaceBefore(
            Identifier {
                ident: "p",
            },
            [
                Newline,
            ],
        ),
    ],
    final_comments: [
        LineComment(
            "",
        ),
    ],
}

view this post on Zulip Anthony Bullard (Jan 07 2025 at 11:31):

It seems....maybe the derived implementation of Debug prints as just the items array when final_comments in empty?

view this post on Zulip Anthony Bullard (Jan 07 2025 at 11:33):

And that's what it is. TIL. And hopefully you did too!


Last updated: Jul 06 2025 at 12:14 UTC