Skip to content

Associated item module hints #55089

@leonardo-m

Description

@leonardo-m
fn foo(n: usize) {
    assert!(n <= u32::MAX as usize);
}
fn main() {}

Gives:

error[E0599]: no associated item named `MAX` found for type `u32` in the current scope
 --> ...\test.rs:2:18
  |
2 |     assert!(n <= u32::MAX as usize);
  |                  ^^^^^^^^ associated item not found in `u32`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.

Perhaps here we want to give a hint where to find the u32::MAX?

Activity

estebank

estebank commented on Oct 15, 2018

@estebank
Contributor

I'm convinced there's an open ticket for this, but I'm failing to find it. Closest I could find was #29841.

added
A-diagnosticsArea: Messages for errors, warnings, and lints
A-associated-itemsArea: Associated items (types, constants & functions)
on Oct 15, 2018
estebank

estebank commented on Oct 15, 2018

@estebank
Contributor

This case in particular could be handled explicitly, I believe, as I don't think we have this problem in general in std, only for the numeric types. That being said, if someone has the time to build a generic solution, that'd be of course more useful than a targeted approach.

estebank

estebank commented on Oct 15, 2018

@estebank
Contributor

Found it! #26760

leonardo-m

leonardo-m commented on Oct 15, 2018

@leonardo-m
Author

Close?

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-associated-itemsArea: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @estebank@leonardo-m

        Issue actions

          Associated item module hints · Issue #55089 · rust-lang/rust