Skip to content

Spurious compiler_builtins::int in error message #71090

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 Apr 13, 2020 · 1 comment
Closed

Spurious compiler_builtins::int in error message #71090

leonardo-m opened this issue Apr 13, 2020 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@leonardo-m
Copy link

leonardo-m commented Apr 13, 2020

This wrong code:

fn foo<T>(x: T) {
    let _ = x.overflowing_add(1);
}
fn main() {
    foo(1);
}

Gives (rustc 1.44.0-nightly (3712e11 2020-04-12)):

error[E0599]: no method named `overflowing_add` found for type parameter `T` in the current scope
 --> C:\lavoro\bugs\bug.rs:2:15
  |
2 |     let _ = x.overflowing_add(1);
  |               ^^^^^^^^^^^^^^^ method not found in `T`
  |
  = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `overflowing_add`, perhaps you need to restrict type parameter `T` with it:
  |
1 | fn foo<T: compiler_builtins::int::Int>(x: T) {
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I think it's better to omit the second part of the error message, with the compiler_builtins::int::Int ghost trait.

@leonardo-m leonardo-m added the C-bug Category: This is a bug. label Apr 13, 2020
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 13, 2020
@estebank estebank added D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. labels Apr 27, 2020
@alexcrichton
Copy link
Member

Fixed since #72629 was included with #72759

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants