-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Allow specifying multiple bounds for same associated item (remove E0719) #143146
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @compiler-errors. Use |
Some changes occurred in diagnostic error codes HIR ty lowering was modified cc @fmease |
This comment has been minimized.
This comment has been minimized.
more importantly cc @rust-lang/types rather than T-lang |
This hard error serves no purpose. Fixes rust-lang#143143
b4a13f9
to
66ab8f8
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(commenting on a random file so it's threaded)
Thanks for incorporating my suggestion about adding more tests!
What are the interactions with trait object types? It's possible that lower_trait_object_ty
still ends up rejecting such dyn-Traits (e.g., dyn Trait<X = i32, X = u64>
) due to its intricate and delicate logic but I might not be right. For example, we currently reject:
#![feature(trait_alias)]
trait Iter = Iterator<Item = ()>;
fn f(_: Box<dyn Iter<Item = u64>>) {} //~ ERROR conflicting associated type bounds for `Item` when expanding trait alias
I'm curious about whether that gets triggered for sth. like dyn Trait<X = i32, X = u64>
🤔 If not, I wonder if we should then also lift this trait alias restriction?
I don't know the soundness implications of allowing these equality predicates in trait object types since I haven't spent much thought on it. In my mind, a trait object type with "impossible" existential projection predicates should be fine, it would just be impossible to construct a value of it. Anyhow, I'm not qualified enough to draw a proper conclusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! It looks like we do trigger that error. I added tests, and tweaked the error message to be more generic.
Interestingly, it seems that if you do:
trait Sup {
type Assoc;
}
trait Sub: Sup<Assoc = u32> {}
type Foo = dyn Sub<Assoc = i32>;
Then no error is emitted, but Foo
does not implement Sub
.
This hard error serves no purpose.
Fixes #143143.
(Documentation of E0719: https://doc.rust-lang.org/stable/error_codes/E0719.html)
@rustbot label T-lang needs-fcp