- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)C-bugCategory: This is a bug.Category: This is a bug.F-trait_alias`#![feature(trait_alias)]``#![feature(trait_alias)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
On 1.45.0-nightly (a74d1862d 2020-05-14), this trait definition/impl works fine:
trait Bounded { const MAX: Self; }
impl Bounded for u32 {
    const MAX: Self = u32::MAX;
}Here, u32::MAX resolves unambiguously to the associated const on u32.
If I merely define a trait alias that uses Bounded:
#![feature(trait_alias)]
trait Bounded { const MAX: Self; }
impl Bounded for u32 {
    const MAX: Self = u32::MAX;
}
trait Num = Bounded + Copy;I get this error:
error[E0034]: multiple applicable items in scope
 --> src/lib.rs:6:28
  |
6 |     const MAX: Self = u32::MAX;
  |                       -----^^^
  |                       |    |
  |                       |    multiple `MAX` found
  |                       help: disambiguate the associated constant for candidate #1: `Bounded::MAX`
  |
note: candidate #1 is defined in an impl of the trait `Bounded` for the type `u32`
 --> src/lib.rs:6:5
  |
6 |     const MAX: Self = u32::MAX;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: candidate #2 is defined in an impl for the type `u32`
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)C-bugCategory: This is a bug.Category: This is a bug.F-trait_alias`#![feature(trait_alias)]``#![feature(trait_alias)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.