Suggest to replace tuple constructor through projection by compiler-errors · Pull Request #135090 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation6 Commits1 Checks6 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

compiler-errors

See the code example. when Self::Assoc normalizes to a struct that has a tuple constructor, you cannot construct the type via Self::Assoc(field, field). Instead, suggest to replace it with the correct named struct.

Fixes #120871

@rustbot

r? @davidtwco

rustbot has assigned @davidtwco.
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

Jan 4, 2025

jieyouxu

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! One test comment, but otherwise looks good.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: maybe also //@ run-rustfix since the suggestion is machine-applicable?

@jieyouxu jieyouxu added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Jan 5, 2025

@lqd

Member

lqd commented

Jan 5, 2025

• Loading

(I was also already reviewing it lmao)

This LGTM, so feel free to r=me. I do have a question though: do you think it'd be worthwhile to support tuples in the same manner? (If so, I can take a look at that, no need to do this in this PR at all).

@compiler-errors

@compiler-errors

@bors r=lqd,jieyouxu rollup

do you think it'd be worthwhile to support tuples in the same manner? (If so, I can take a look at that, no need to do this in this PR at all).

@lqd: Perhaps? I don't know. You're welcome to try it out, tho. Maybe also look into cases where users try to construct tuples through type aliases like type Foo = (i32, i32) and then Foo(1, 2), if that's not already handled?

@bors

📌 Commit 304ccf4 has been approved by lqd,jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jan 6, 2025

jhpratt added a commit to jhpratt/rust that referenced this pull request

Jan 7, 2025

@jhpratt

…-projection, r=lqd,jieyouxu

Suggest to replace tuple constructor through projection

See the code example. when Self::Assoc normalizes to a struct that has a tuple constructor, you cannot construct the type via Self::Assoc(field, field). Instead, suggest to replace it with the correct named struct.

Fixes rust-lang#120871

This was referenced

Jan 7, 2025

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jan 7, 2025

@bors

Rollup of 9 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Jan 7, 2025

@rust-timer

Rollup merge of rust-lang#135090 - compiler-errors:invalid-tuple-ctor-projection, r=lqd,jieyouxu

Suggest to replace tuple constructor through projection

See the code example. when Self::Assoc normalizes to a struct that has a tuple constructor, you cannot construct the type via Self::Assoc(field, field). Instead, suggest to replace it with the correct named struct.

Fixes rust-lang#120871

Labels

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.