Skip to content
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

rustc recommends specialization for type parameters inside an extern block #45092

Closed
MaikKlein opened this issue Oct 7, 2017 · 3 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@MaikKlein
Copy link
Contributor

extern {
    fn sqrt<T>(f: T) -> T;
}

fn main(){}

playground

help: consider using specialization instead of type parameters

@MaikKlein
Copy link
Contributor Author

MaikKlein commented Oct 7, 2017

I just realized that rustc doesn't refer to the feature specialization but to 'manual' specialization.

rustc --explain E0044


You can't use type parameters on foreign items. Example of erroneous code:

extern { fn some_func<T>(x: T); }

To fix this, replace the type parameter with the specializations that you
need:

extern { fn some_func_i32(x: i32); }
extern { fn some_func_i64(x: i64); } 

@sfackler sfackler added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Oct 7, 2017
@TimNN TimNN added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Oct 10, 2017
@steveklabnik steveklabnik added the P-medium Medium priority label Oct 31, 2017
@QuietMisdreavus QuietMisdreavus added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 31, 2017
bors added a commit that referenced this issue Mar 15, 2018
Reword E0044 and message for `!Send` types

 - Reword E0044 help.
 - Change error message for types that don't implement `Send`

CC #45092, #46678, #24909, #33307.
@steveklabnik steveklabnik added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Jan 8, 2019
@oli-obk oli-obk added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-low Low priority and removed P-medium Medium priority labels May 24, 2019
@oli-obk
Copy link
Contributor

oli-obk commented May 24, 2019

Diagnostics triage: just needs changing the wording to something that gives a clearer message.

@iluuu1994
Copy link
Contributor

E0044 has been reworded in #48138.

error[E0044]: foreign items may not have type parameters
 --> src/main.rs:2:5
  |
2 |     fn sqrt<T>(f: T) -> T;
  |     ^^^^^^^^^^^^^^^^^^^^^^ can't have type parameters
  |
  = help: use specialization instead of type parameters by replacing them with concrete types like `u32`

This can be closed.

@oli-obk oli-obk closed this as completed Jul 26, 2019
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-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants