Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Jules-Bertholet
Copy link
Contributor

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

@rustbot
Copy link
Collaborator

rustbot commented Jun 28, 2025

r? @compiler-errors

rustbot has assigned @compiler-errors.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 28, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 28, 2025

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. T-lang Relevant to the language team labels Jun 28, 2025
@rustbot

This comment has been minimized.

@fmease
Copy link
Member

fmease commented Jun 28, 2025

more importantly cc @rust-lang/types rather than T-lang

@fmease fmease added T-types Relevant to the types team, which will review and decide on the PR/issue. and removed T-lang Relevant to the language team T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 28, 2025
@fmease fmease changed the title Remove E0719 Allow specifying multiple associated type bindings for same GAT if gen args differ Jun 28, 2025
This hard error serves no purpose.
Fixes rust-lang#143143
@fmease fmease changed the title Allow specifying multiple associated type bindings for same GAT if gen args differ Allow specifying multiple associated type bindings Jun 28, 2025
@Jules-Bertholet Jules-Bertholet changed the title Allow specifying multiple associated type bindings Allow specifying multiple bounds for same associated type (remove E0719) Jun 28, 2025
@fmease fmease changed the title Allow specifying multiple bounds for same associated type (remove E0719) Allow specifying multiple bounds for same associated item (remove E0719) Jun 28, 2025
@rust-log-analyzer

This comment has been minimized.

@Jules-Bertholet Jules-Bertholet requested a review from fmease June 28, 2025 17:20
Copy link
Member

@fmease fmease Jun 28, 2025

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't specific multiple associated type bindings for same GAT even if args differ
5 participants