Skip to content

min_generic_const_args makes {u,i}*::{MIN, MAX} ambiguous #158506

Open

Description

@Lars-Schumann

Enabling mgca somehow breaks these associated consts.

I tried this code: playground

#![allow(incomplete_features)]
#![feature(generic_const_items, min_generic_const_args)]

const TAKES_U8<const FOO: u8>: () = ();
const _: () = TAKES_U8::<{ u8::MAX }>;

I expected to see this happen: compiles.

Instead, this happened: fails to compile. (but compiles fine without mgca enabled)

error[E0223]: ambiguous associated constant
 --> src/lib.rs:5:28
  |
5 | const _: () = TAKES_U8::<{ u8::MAX }>;
  |                            ^^^^^^^
  |
help: you are looking for the module in `std`, not the primitive type
  |
5 | const _: () = TAKES_U8::<{ std::u8::MAX }>;
  |                            +++++

It also compiles fine if you add the const keyword like this:

const _: () = TAKES_U8::<const { u8::MAX }>;

Meta

tested on playground, 1.98.0-nightly (2026-06-26 ce9954c0cfc4bf26b82a)

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 27, 2026
  2. changed the title [-]`min_generic_const_args` makes `{u,i}*::{MIN, MAX}` ambigous[/-] [+]`min_generic_const_args` makes `{u,i}*::{MIN, MAX}` ambiguous[/+] on Jun 28, 2026
  3. added
    F-gca_min_const_items`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)
    on Jun 28, 2026
  4. peter-lyons-kehl commented on Jul 14, 2026

    @peter-lyons-kehl
    Contributor

    Another example:

    #![allow(incomplete_features)]
    #![feature(min_generic_const_args)]
    
    pub type UsingUsizeMax = [(); usize::MAX];

    with rustc 1.97.0 (2d8144b78 2026-07-07)

    Feature tracking issue: min_generic_const_args.

  5. chenyukang commented on Aug 31, 2026

    @chenyukang
    Member

    @khyperia

    seems the original issue was resolved by #158617
    however, the underlying direct-representation issue remains: using direct_const_arg!(u8::MAX) or enabling macroless_generic_const_args still produces E0223 because HIR type lowering only probes inherent associated items for ADTs.

    https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=1e454a3a903bc8f77a779caf651c4740

  6. khyperia commented on Aug 31, 2026

    @khyperia
    Member

    makes sense! seems this is a feature(inherent_associated_types) issue then, feature(generic_const_args) uses that for inherent consts (tbh it should maybe be called feature(inherent_associated_terms), haha). For example:

    #![feature(min_generic_const_args)]
    
    struct S;
    impl S {
        type const MAX: usize = 2;
    }
    
    type A = [(); core::direct_const_arg!(S::MAX)];

    produces

    error[E0658]: inherent associated types are unstable
     --> src/main.rs:9:39
      |
    9 | type C = [(); core::direct_const_arg!(S::MAX)];
      |                                       ^^^^^^
      |
      = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
      = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
    

    it's just that when you do u8::MAX, inherent_associated_types is so borked/unimplemented that we don't even get around to being able to emit a feature gate for it.

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

    C-bugCategory: This is a bug.F-gca_min_const_items`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)F-generic_const_items`#![feature(generic_const_items)]`needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions