Open
Description
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)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Todo
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]min_type_alias_impl_trait: poor diagnostics[/-][+]min_type_alias_impl_trait: poor diagnostics when TAIT is unconstrained[/+]voidc commentedon 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 commentedon 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 commentedon Jan 26, 2023
oli-obk commentedon Jan 26, 2023