Skip to content

min_type_alias_impl_trait: poor diagnostics when TAIT is unconstrained #86733

Open
@nikomatsakis

Description

@nikomatsakis
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)

Activity

changed the title [-]min_type_alias_impl_trait: poor diagnostics[/-] [+]min_type_alias_impl_trait: poor diagnostics when TAIT is unconstrained[/+] on Jun 29, 2021
voidc

voidc commented on Jul 7, 2021

@voidc
Contributor

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 commented on May 3, 2022

@oli-obk
Contributor

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.

moved this from Todo to Can do after stabilization in type alias impl trait stabilizationon Sep 9, 2022
moved this from Can do after stabilization to Todo in type alias impl trait stabilizationon Jan 17, 2023
dignifiedquire

dignifiedquire commented on Jan 26, 2023

@dignifiedquire
oli-obk

oli-obk commented on Jan 26, 2023

@oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsF-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nikomatsakis@oli-obk@dignifiedquire@voidc

        Issue actions

          min_type_alias_impl_trait: poor diagnostics when TAIT is unconstrained · Issue #86733 · rust-lang/rust