Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whether an enum struct variant is multi-line depends on doc comments of previous variants #6120

Closed
RalfJung opened this issue Mar 18, 2024 · 1 comment

Comments

@RalfJung
Copy link
Member

rustfmt considers this to be correctly formatted:

/// Some item that needs to monomorphize successfully for a MIR body to be considered well-formed.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, HashStable, TyEncodable, TyDecodable)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum MentionedItem<'tcx> {
    /// A function that gets called. We don't necessarily know its precise type yet, since it can be
    /// hidden behind a generic.
    Fn(Ty<'tcx>),
    /// A type that has its drop shim called.
    Drop(Ty<'tcx>),
    /// Unsizing casts might require vtables, so we have to record them.
    UnsizeCast { source_ty: Ty<'tcx>, target_ty: Ty<'tcx> },
    /// A closure that is coerced to a function pointer.
    Closure(Ty<'tcx>),
}

And this:

/// Some item that needs to monomorphize successfully for a MIR body to be considered well-formed.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, HashStable, TyEncodable, TyDecodable)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum MentionedItem<'tcx> {
    Fn(Ty<'tcx>),
    Drop(Ty<'tcx>),
    /// Unsizing casts might require vtables, so we have to record them.
    UnsizeCast {
        source_ty: Ty<'tcx>,
        target_ty: Ty<'tcx>,
    },
    /// A closure that is coerced to a function pointer.
    Closure(Ty<'tcx>),
}

For some reason, adding doc comments to Fn and Drop variants changes whether the UnsizeCast variant should be multi-line. That doesn't make any sense to me...

rustfmt.toml:

version = "Two"
use_small_heuristics = "Max"
merge_derives = false
@ytmimi
Copy link
Contributor

ytmimi commented Mar 18, 2024

Similar to #6106 but I'm pretty sure this is a duplicate of #5662

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants