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

min_type_alias_impl_trait: poor diagnostics when TAIT is unconstrained #86733

Open
nikomatsakis opened this issue Jun 29, 2021 · 4 comments
Open
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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

@nikomatsakis
Copy link
Contributor

The minimized example (playground:

#![feature(min_type_alias_impl_trait)]

type Foo = impl Copy;

enum Wrapper<T> {
    First(T),
    Second
}

fn produce() -> Wrapper<Foo> {
    Wrapper::Second
}

gives what appears to me to be the correct error:

error: could not find defining uses
 --> src/lib.rs:3:12
  |
3 | type Foo = impl Copy;
  |            ^^^^^^^^^

but the diagnostics are not very good.

Originally posted by @nikomatsakis in #66426 (comment)

@nikomatsakis nikomatsakis changed the title min_type_alias_impl_trait: poor diagnostics min_type_alias_impl_trait: poor diagnostics when TAIT is unconstrained Jun 29, 2021
@nikomatsakis nikomatsakis added A-diagnostics Area: Messages for errors, warnings, and lints F-min_type_alias_impl_trait T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 29, 2021
@voidc
Copy link
Contributor

voidc commented Jul 7, 2021

I'd be interested in taking a stab at this. However, I'm not quite sure what the desired behavior is. I looked at PR #66431 which implemented the fallback to a non-defining use for unconstrained opaque types. One possibility would be to somewhere store every location at which such a fallback occurs, to later show a warning/note when no other defining use is found. I would also appreciate some mentoring instructions on how to approach this.

@oli-obk oli-obk added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` and removed F-min_type_alias_impl_trait labels Mar 30, 2022
@oli-obk
Copy link
Contributor

oli-obk commented May 3, 2022

Yea, I think the only way to fix this is to add a new field to https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.BorrowCheckResult.html that maps from opaque type def ids to spans and use that when reporting the unconstrained diagnostic.

@dignifiedquire

This comment was marked as resolved.

@oli-obk

This comment was marked as resolved.

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 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.
Projects
Development

No branches or pull requests

4 participants