Skip to content

Associated item module hints #55089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leonardo-m opened this issue Oct 15, 2018 · 4 comments
Closed

Associated item module hints #55089

leonardo-m opened this issue Oct 15, 2018 · 4 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@leonardo-m
Copy link

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?

@estebank
Copy link
Contributor

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

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-associated-items Area: Associated items (types, constants & functions) labels Oct 15, 2018
@estebank
Copy link
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
Copy link
Contributor

Found it! #26760

@leonardo-m
Copy link
Author

Close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

2 participants