rust-lang / rust-lang/rust

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

Open
#158,506 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-generic_const_items F-min_generic_const_args needs-triage
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the linked playground on the reported nightly with and without min_generic_const_args, comparing the u8::MAX and const { u8::MAX } forms. Trace the compiler's handling of the associated-const generic argument and add a regression test covering the shown TAKES_U8 example; done means the non-const form compiles with the feature enabled without an ambiguity diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.