Skip to content

Conversation

hkBst
Copy link
Member

@hkBst hkBst commented Sep 15, 2025

After looking at #40850, I thought I'd try to improve wording around error E0608 a bit. Hopefully I've succeeded.

@rustbot
Copy link
Collaborator

rustbot commented Sep 15, 2025

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

@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 Sep 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 15, 2025

r? @fee1-dead

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

@rust-log-analyzer

This comment has been minimized.

// fixed expression:
err.help(
"tuples are indexed (like structs) with dot (`._`) not with brackets (`[_]`), \
element names are their positions: tuple = (tuple.0, tuple.1, ...)",
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this line ("element names..") is a bit too extraneous. People trying to do x[0] might not really be very confused on which indices each field ends up (and it is probably better to leave this role to some other place teaching tuples)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've removed this bit, and also the reference to structs.

Copy link
Member Author

Choose a reason for hiding this comment

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

@rustbot ready

@rustbot rustbot 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 Sep 16, 2025
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 16, 2025
| ^^^
|
= help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`)
= help: tuples are indexed with dot (`._`): tuple = (tuple.0, tuple.1, ...)
Copy link
Contributor

@jdonszelmann jdonszelmann Sep 18, 2025

Choose a reason for hiding this comment

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

I still don't think this message is better than the original. I like your changes to the error code docs, but the ._ confuses me and tuple = in the example too. I'd approve this if the error message and help stayed the same as it was.
Your changes to the case where you provide an integer as index is improved though, I like the "to access element 0, use .0" :)

@rustbot author

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for reviewing!

Copy link
Member Author

@hkBst hkBst Sep 29, 2025

Choose a reason for hiding this comment

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

I've made some small changes to address your comments. Let me know if it is any better!

@rustbot ready

Copy link
Member Author

Choose a reason for hiding this comment

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

The basic idea is to use the fact that a tuple is equal to its elements as a harness for the tuple index syntax...

Copy link
Contributor

Choose a reason for hiding this comment

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

well I get that that's what it's trying to convey, I just don't think it's any clearer than giving a single example like before

Copy link
Contributor

Choose a reason for hiding this comment

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

@rustbot author

Copy link
Contributor

Choose a reason for hiding this comment

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

again, I think your change to the message when providing an integer as index is good! I just really don't think this part is very clear while I think the way it was was perfectly clear

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright I took out that idea, and now it's much closer to what was there before.

@rustbot ready

@rustbot rustbot 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 Sep 18, 2025
Copy link
Contributor

@jdonszelmann jdonszelmann left a comment

Choose a reason for hiding this comment

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

@jdonszelmann jdonszelmann self-assigned this Sep 18, 2025
@jdonszelmann
Copy link
Contributor

@hkBst I think this is a cool change, still feel like fixing it up?

@hkBst
Copy link
Member Author

hkBst commented Sep 25, 2025

@jdonszelmann I'll get back to it in a bit. Just giving it some time, so I can look at it fresh. :)

@jdonszelmann
Copy link
Contributor

Very good! No rush, just saw it in my review queue hehe

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 29, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot 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 Sep 30, 2025
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 30, 2025
|
= help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`)
= help: tuples are indexed with a dot and a constant index, e.g.: `tuple.0`
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

i.e. I prefer the comma

Copy link
Contributor

Choose a reason for hiding this comment

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

also it's not a constant. i.e. it can't be replaced by tuple.const{3 + 3} or whatever (though that'd be cool). Genuinely, it was pretty good as it was! like, it is tuple indexing syntax, that's fundamentally what it is, and in the compiler it acts much more like an identifier than a constant. For example, it's perfectly valid to initialize a tuple struct like this:

struct Foo(u32);

fn main() {
    let x = Foo {0: 3}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right that "constant" is perhaps not quite right. Perhaps "literal" or "literal integer"? Indexing a tuple may use "tuple indexing syntax", but that name does not seem to have much (any?) explanatory power, which is why I am trying to describe it instead of naming it.

My usage of "e.g.:" seems indeed to be unusual, but the colon can stand on its own I think.

Genuinely, it was pretty good as it was!

It is adequate, but I think we can do better. Perhaps "tuple elements are accessed" is better than "tuples are indexed" though?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've pushed another version of this...

Copy link
Member Author

Choose a reason for hiding this comment

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

@rustbot ready

@rustbot rustbot 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 Sep 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 1, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 1, 2025
@jdonszelmann
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 1, 2025

📌 Commit 86f2d42 has been approved by jdonszelmann

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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 1, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 2, 2025
indexing: reword help

After looking at rust-lang#40850, I thought I'd try to improve wording around error E0608 a bit. Hopefully I've succeeded.
bors added a commit that referenced this pull request Oct 2, 2025
Rollup of 10 pull requests

Successful merges:

 - #146281 (Support `#[rustc_align_static]` inside `thread_local!`)
 - #146535 (mbe: Implement `unsafe` attribute rules)
 - #146585 (indexing: reword help)
 - #147004 (Tweak handling of "struct like start" where a struct isn't supported)
 - #147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
 - #147225 (Don't enable shared memory by default with Wasm atomics)
 - #147227 (implement `Box::take`)
 - #147231 (Extending `#[rustc_force_inline]` to be applicable to inherent methods)
 - #147233 (Initialize llvm submodule if not already the case to run citool)
 - #147236 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 2, 2025
indexing: reword help

After looking at rust-lang#40850, I thought I'd try to improve wording around error E0608 a bit. Hopefully I've succeeded.
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 2, 2025
indexing: reword help

After looking at rust-lang#40850, I thought I'd try to improve wording around error E0608 a bit. Hopefully I've succeeded.
bors added a commit that referenced this pull request Oct 2, 2025
Rollup of 9 pull requests

Successful merges:

 - #146281 (Support `#[rustc_align_static]` inside `thread_local!`)
 - #146535 (mbe: Implement `unsafe` attribute rules)
 - #146585 (indexing: reword help)
 - #147004 (Tweak handling of "struct like start" where a struct isn't supported)
 - #147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
 - #147225 (Don't enable shared memory by default with Wasm atomics)
 - #147227 (implement `Box::take`)
 - #147233 (Initialize llvm submodule if not already the case to run citool)
 - #147236 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7320d3e into rust-lang:master Oct 2, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 2, 2025
rust-timer added a commit that referenced this pull request Oct 2, 2025
Rollup merge of #146585 - hkBst:indexing-1, r=jdonszelmann

indexing: reword help

After looking at #40850, I thought I'd try to improve wording around error E0608 a bit. Hopefully I've succeeded.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Oct 3, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#146281 (Support `#[rustc_align_static]` inside `thread_local!`)
 - rust-lang/rust#146535 (mbe: Implement `unsafe` attribute rules)
 - rust-lang/rust#146585 (indexing: reword help)
 - rust-lang/rust#147004 (Tweak handling of "struct like start" where a struct isn't supported)
 - rust-lang/rust#147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
 - rust-lang/rust#147225 (Don't enable shared memory by default with Wasm atomics)
 - rust-lang/rust#147227 (implement `Box::take`)
 - rust-lang/rust#147233 (Initialize llvm submodule if not already the case to run citool)
 - rust-lang/rust#147236 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants