Skip to content

False positive of lint missing_debug_implementations if Debug is implemented for a free alias type that expands to the relevant type #157757

Closed

Description

@fmease
#![feature(lazy_type_alias)]
#![deny(missing_debug_implementations)]

pub struct Local; //~ ERROR type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manu

pub type Alias = Local;

impl std::fmt::Debug for Alias {
    fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Ok(()) }
}

For some reason missing_debug_implementations doesn't actually query the trait solver (!) (if the fast path doesn't apply), it literally does

        let has_impl = cx
            .tcx
            .non_blanket_impls_for_ty(
                debug,
                cx.tcx.type_of(item.owner_id).instantiate_identity().skip_norm_wip(),
            )
            .next()
            .is_some();

but I don't think that function should be used for "correctness" (well, it's a lint), ideally it would only be used as a fast path (barring more specific use cases).

For comparison, lint missing_copy_implementations calls tcx.type_is_copy_modulo_regions() which has a fast path but then queries the trait solver.


A temporarily solution would be to call expand_free_alias_tys inside non_blanket_impls_for_ty and friends? I haven't thought about correctness yet, so not sure.

I don't think we should call expand_free_alias_tys in fast_reject::simplify_type; that ideal feels very iffy and it would probably trash perf.

Activity

  1. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    F-checked_type_aliases`#![feature(checked_type_aliases)]` (formerly: `lazy_type_alias`)
    L-false-positiveLint: False positive (should not have fired).
    on Jun 11, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 11, 2026
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 11, 2026
  4. changed the title [-]False positive for lint `missing_debug_implementations` if `Debug` is implemented for a free alias type that expands to the relevant type[/-] [+]False positive of lint `missing_debug_implementations` if `Debug` is implemented for a free alias type that expands to the relevant type[/+] on Jun 11, 2026
  5. fmease commented on Jun 11, 2026

    @fmease
    MemberAuthor

    Why does that have its own issue instead of being part of parent issue #157758?

    Well, it's because this way it's easier to track the potential blockers for LTA_unchecked's stabilization:
    Stable code that currently uses eager type aliases in this position would regress if LTA_unchecked became the default.

  6. added 2 commits that reference this issue on Jun 17, 2026
  7. added a commit that references this issue on Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.F-checked_type_aliases`#![feature(checked_type_aliases)]` (formerly: `lazy_type_alias`)L-false-positiveLint: False positive (should not have fired).L-missing_debug_implementationsLint: missing_debug_implementationsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions