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

Error for mismatched types involving generics seems to be missing something #78206

Closed
camelid opened this issue Oct 21, 2020 · 0 comments · Fixed by #116908
Closed

Error for mismatched types involving generics seems to be missing something #78206

camelid opened this issue Oct 21, 2020 · 0 comments · Fixed by #116908
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-type-system Area: Type system C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@camelid
Copy link
Member

camelid commented Oct 21, 2020

pub fn f<T>(a: &T) -> *const T {
    &1 as *const i32
}

(Playground)

The error includes a label that says "this type parameter", but it doesn't complete the sentence:

   Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
 --> src/lib.rs:2:5
  |
1 | pub fn f<T>(a: &T) -> *const T {
  |          -            -------- expected `*const T` because of return type
  |          |
  |          this type parameter
2 |     &1 as *const i32
  |     ^^^^^^^^^^^^^^^^ expected type parameter `T`, found `i32`
  |
  = note: expected raw pointer `*const T`
             found raw pointer `*const i32`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground`

To learn more, run the command again with --verbose.

@camelid camelid added A-type-system Area: Type system A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-papercut Diagnostics: An error or lint that needs small tweaks. labels Oct 21, 2020
@JohnTitor JohnTitor added C-enhancement Category: An issue proposing an enhancement or a PR with one. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. labels Oct 21, 2020
estebank added a commit to estebank/rust that referenced this issue Oct 18, 2023
fmease added a commit to fmease/rust that referenced this issue Oct 19, 2023
…rrors

Tweak wording of type errors involving type params

Fix rust-lang#78206.
@bors bors closed this as completed in bd8b468 Oct 19, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 19, 2023
Rollup merge of rust-lang#116908 - estebank:issue-78206, r=compiler-errors

Tweak wording of type errors involving type params

Fix rust-lang#78206.
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 21, 2023
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-type-system Area: Type system C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. 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.

2 participants