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

adt_const_params feature gate error leaks {type error} (TyKind::Error) #118179

Closed
fmease opened this issue Nov 22, 2023 · 2 comments · Fixed by #131038
Closed

adt_const_params feature gate error leaks {type error} (TyKind::Error) #118179

fmease opened this issue Nov 22, 2023 · 2 comments · Fixed by #131038
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. D-papercut Diagnostics: An error or lint that needs small tweaks. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Nov 22, 2023

The following code

struct G<T, const N: Vec<T>>(T);
fn main() {}

currently yields

error[E0770]: the type of const parameters must not depend on other generic parameters
 --> src/lib.rs:1:26
  |
1 | struct G<T, const N: Vec<T>>(T);
  |                          ^ the type must not depend on the parameter `T`
  |
  = note: type parameters may not be used in the type of const parameters

error: `Vec<{type error}, {type error}>` is forbidden as the type of a const generic parameter
 --> src/lib.rs:1:22
  |
1 | struct G<T, const N: Vec<T>>(T);
  |                      ^^^^^^
  |
  = note: the only supported types are integers, `bool` and `char`
  = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types

Ideally, we would replace the {type error} with _ or prevent the second error from being be emitted (this can be achieved by bailing out early if the relevant type .references_errors()).

@fmease fmease added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. 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. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Nov 22, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 22, 2023
@fmease fmease added P-low Low priority and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Nov 22, 2023
@onkoe
Copy link
Contributor

onkoe commented Sep 29, 2024

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 30, 2024
…8179, r=compiler-errors

Fix `adt_const_params` leaking `{type error}` in error msg

Fixes the confusing diagnostic described in rust-lang#118179. (users would see `{type error}` in some situations, which is pretty weird)

`adt_const_params` tracking issue: rust-lang#95174
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 30, 2024
Rollup merge of rust-lang#131038 - onkoe:fix/adt_const_params_leak_118179, r=compiler-errors

Fix `adt_const_params` leaking `{type error}` in error msg

Fixes the confusing diagnostic described in rust-lang#118179. (users would see `{type error}` in some situations, which is pretty weird)

`adt_const_params` tracking issue: rust-lang#95174
@fmease
Copy link
Member Author

fmease commented Oct 16, 2024

Fixed by #131038.

@fmease fmease closed this as completed Oct 16, 2024
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 D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. D-papercut Diagnostics: An error or lint that needs small tweaks. P-low Low priority 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.

3 participants