Skip to content

[1.38] Regression: proc macro panicked #63894

Closed
@petrochenkov

Description

@petrochenkov

#63628 (comment)

proc macro panicked

[INFO] [stderr]    Compiling custom-slice-macros v0.1.1 (/opt/crater/workdir)
[INFO] [stderr] error: proc macro panicked
[INFO] [stderr]    --> tests/derives.rs:48:13
[INFO] [stderr]     |
[INFO] [stderr] 48  | /             custom_slice_macros::define_slice_types_pair! {
[INFO] [stderr] 49  | |                 #[custom_slice(owned)]
[INFO] [stderr] 50  | |                 $(#[$meta_owned])*
[INFO] [stderr] 51  | |                 struct Owned($owned_inner);
[INFO] [stderr] ...   |
[INFO] [stderr] 59  | |                 fn validate(_: &$slice_inner) -> Result<(), $ty_error> $body
[INFO] [stderr] 60  | |             }
[INFO] [stderr]     | |_____________^
[INFO] [stderr] ...
[INFO] [stderr] 227 | /     gen_test! {
[INFO] [stderr] 228 | |         name: try_from_inner,
[INFO] [stderr] 229 | |         #[custom_slice(derive(TryFromInner))]
[INFO] [stderr] 230 | |         #[custom_slice(error(r#type = "()"))]
[INFO] [stderr] ...   |
[INFO] [stderr] 236 | |         validator: () { Ok(()) },
[INFO] [stderr] 237 | |     }
[INFO] [stderr]     | |_____- in this macro invocation
[INFO] [stderr]     |
[INFO] [stderr]     = help: message: `#[custom_slice(error(type = "..."))]` should be specified

This is a regression from these series of pretty-printing improvements - #62393, #62574, #62667.

Tokens are printed more precisely now, so #[custom_slice(error(r#type = "()"))] is now printed as is, while previously it lost the "rawness" qualifier from type and was printed like this - #[custom_slice(error(type = "()"))].
(Pretty-printing matters because proc macros often have to work with pretty-printed version of their input due to #43081.)

Procedural macro define_slice_types_pair however doesn't recognize r#type as type and complains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions