Skip to content

poor diagnostics when type-alias-impl-trait appears in impl #96569

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
aliemjay opened this issue Apr 30, 2022 · 0 comments · Fixed by #96673
Closed

poor diagnostics when type-alias-impl-trait appears in impl #96569

aliemjay opened this issue Apr 30, 2022 · 0 comments · Fixed by #96673
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@aliemjay
Copy link
Member

aliemjay commented Apr 30, 2022

Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=38b4af731292bf171e1011d9e54abd70

A type alias with at least one lifetime or type parameter:

#![feature(type_alias_impl_trait)]

type Ty<T> = impl Sized;
fn defining<T>(s: T) -> Ty<T> { s }

trait Tr {}
impl<T> Tr for Ty<T> {}

The current output is:

error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
 --> src/lib.rs:7:6
  |
7 | impl<T> Tr for Ty<T> {}
  |      ^ unconstrained type parameter

Ideally the output should look like when the type alias has no lifetime of type paramters:

error: cannot implement trait on type alias impl trait
 --> src/lib.rs:7:13
  |
7 | impl<T> Tr for Ty<T> {}
  |               ^^^^^^
  |
note: type alias impl trait defined here
 --> src/lib.rs:3:14
  |
3 | type Ty<T> = impl Sized;
  |              ^^^^^^^^^^

These diagnostics where introduced in #95973. cc @oli-obk.

@rustbot label T-compiler F-type_alias_impl_trait

@aliemjay aliemjay added 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. labels Apr 30, 2022
@rustbot rustbot added the F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` label Apr 30, 2022
@JohnTitor JohnTitor added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label May 1, 2022
@oli-obk oli-obk self-assigned this May 3, 2022
@bors bors closed this as completed in 5f8a2f6 May 5, 2022
@oli-obk oli-obk moved this from Todo to Done in type alias impl trait stabilization Sep 9, 2022
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 C-enhancement Category: An issue proposing an enhancement or a PR with one. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

4 participants