Skip to content

Where-clauses on associated types are not checked for well-formedness #165177

Open

Description

@leeewee

I tried this code:

pub struct NC<T: Copy>(pub T);

pub trait Tr {
    type A where NC<String>: Sized;
}

Expected: E0277 (String: Copy is not satisfied, required by NC). The same clause on a method in the same trait gives exactly that

error[E0277]: the trait bound `String: Copy` is not satisfied
4 |     fn a() where NC<String>: Sized;
  |                              ^^^^^ the trait `Copy` is not implemented for `String`

Actual: compiles, under both solvers, on nightly-2026-10-29 and on stable 1.99.0.

Meta

rustc --version --verbose:

rustc 1.101.0-nightly (92ffebece 2026-10-28)
binary: rustc
commit-hash: 92ffebeceaa0a071066f233873c2438e73d70fe7
commit-date: 2026-10-28
host: x86_64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.4

Stable comparison: rustc 1.99.0 (b940084d7 2026-09-28).

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 30, 2026
  2. ManasDasri commented on Oct 30, 2026

    @ManasDasri

    @rustbot claim

  3. added
    A-associated-itemsArea: Associated items (types, constants & functions)
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 30, 2026
  4. removed
    A-associated-itemsArea: Associated items (types, constants & functions)
    on Oct 30, 2026
  5. fmease commented on Oct 30, 2026

    @fmease
  6. fmease commented on Oct 30, 2026

    @fmease
  7. theemathas commented on Oct 30, 2026

    @theemathas
  8. fmease commented on Oct 30, 2026

    @fmease
  9. fmease commented on Oct 30, 2026

    @fmease
    Member

    Not the case for assoc fns but it's also the case for assoc consts (under GCI).

    Contrary to assoc tys & assoc consts, for assoc fns we do call check_where_clauses in check_fn_or_method in check_associated_item. That's the oversight.

    I wonder if the assoc ty case is a regression 🤔 a lot of refactorings happened in that area in the last two years moving things from HIR to middle::ty checks... doesn't look like it. Well, I've only checked 1.65 which is the version that stably intro'ed GATs.

  10. self-assigned this
    on Oct 30, 2026
  11. added
    A-GATsArea: Generic associated types (GATs)
    on Oct 30, 2026
  12. fmease commented on Oct 30, 2026

    @fmease
    Member

    @ManasDasri, ah, sorry I forgot that you used to be assigned. Ping me in your future PR so I can perf it & issue a crater run :)

  13. removed their assignment
    on Oct 30, 2026
  14. added a commit that references this issue on Oct 31, 2026
  15. added a commit that references this issue on Oct 31, 2026
  16. added a commit that references this issue on Oct 31, 2026
  17. added
    S-found-by-fuzzingStatus: This issue was found using fuzzing. It may not arise in practical cases.
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-GATsArea: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)C-bugCategory: This is a bug.S-found-by-fuzzingStatus: This issue was found using fuzzing. It may not arise in practical cases.T-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions