Skip to content

Commit dd1b7ad

Browse files
committed
jdonszelmann feedback
1 parent 62b3b53 commit dd1b7ad

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

compiler/rustc_error_codes/src/error_codes/E0608.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,9 @@ let v: Vec<u8> = vec![0, 1, 2, 3];
1717
println!("{}", v[2]);
1818
```
1919

20-
Tuples and structs are indexed with dot (`._`), not with brackets (`[_]`).
21-
Tuple element names are their positions: tuple = (tuple.0, tuple.1, ...)
20+
Tuples and structs are indexed with dot (`.`), not with brackets (`[]`),
21+
and tuple element names are their positions:
22+
```ignore(pseudo code)
23+
// this (pseudo code) expression is true for any tuple:
24+
tuple == (tuple.0, tuple.1, ...)
25+
```

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3552,9 +3552,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35523552
);
35533553
// Try to give some advice about indexing tuples.
35543554
if let ty::Tuple(types) = base_t.kind() {
3555-
err.help(
3556-
"tuples are indexed with dot (`._`): tuple = (tuple.0, tuple.1, ...)",
3557-
);
3555+
err.help("tuples are indexed with dot: `tuple == (tuple.0, tuple.1, ...)`");
35583556
// If index is an unsuffixed integer, show the fixed expression:
35593557
if let ExprKind::Lit(lit) = idx.kind
35603558
&& let ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) = lit.node

tests/ui/indexing/index_message.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0608]: cannot index into a value of type `({integer},)`
44
LL | let _ = z[0];
55
| ^^^ help: to access tuple element `0`, use: `.0`
66
|
7-
= help: tuples are indexed with dot (`._`): tuple = (tuple.0, tuple.1, ...)
7+
= help: tuples are indexed with dot: `tuple == (tuple.0, tuple.1, ...)`
88

99
error: aborting due to 1 previous error
1010

tests/ui/issues/issue-27842.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ error[E0608]: cannot index into a value of type `({integer}, {integer}, {integer
44
LL | let _ = tup[0];
55
| ^^^ help: to access tuple element `0`, use: `.0`
66
|
7-
= help: tuples are indexed with dot (`._`): tuple = (tuple.0, tuple.1, ...)
7+
= help: tuples are indexed with dot: `tuple == (tuple.0, tuple.1, ...)`
88

99
error[E0608]: cannot index into a value of type `({integer}, {integer}, {integer})`
1010
--> $DIR/issue-27842.rs:9:16
1111
|
1212
LL | let _ = tup[i];
1313
| ^^^
1414
|
15-
= help: tuples are indexed with dot (`._`): tuple = (tuple.0, tuple.1, ...)
15+
= help: tuples are indexed with dot: `tuple == (tuple.0, tuple.1, ...)`
1616

1717
error[E0608]: cannot index into a value of type `({integer},)`
1818
--> $DIR/issue-27842.rs:14:16
1919
|
2020
LL | let _ = tup[3];
2121
| ^^^
2222
|
23-
= help: tuples are indexed with dot (`._`): tuple = (tuple.0, tuple.1, ...)
23+
= help: tuples are indexed with dot: `tuple == (tuple.0, tuple.1, ...)`
2424

2525
error: aborting due to 3 previous errors
2626

tests/ui/span/suggestion-non-ascii.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0608]: cannot index into a value of type `({integer},)`
44
LL | println!("☃{}", tup[0]);
55
| ^^^ help: to access tuple element `0`, use: `.0`
66
|
7-
= help: tuples are indexed with dot (`._`): tuple = (tuple.0, tuple.1, ...)
7+
= help: tuples are indexed with dot: `tuple == (tuple.0, tuple.1, ...)`
88

99
error: aborting due to 1 previous error
1010

tests/ui/typeck/coercion-check-for-indexing-expression-issue-40861.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0608]: cannot index into a value of type `()`
44
LL | ()[f(&[1.0])];
55
| ^^^^^^^^^^^
66
|
7-
= help: tuples are indexed with dot (`._`): tuple = (tuple.0, tuple.1, ...)
7+
= help: tuples are indexed with dot: `tuple == (tuple.0, tuple.1, ...)`
88

99
error: aborting due to 1 previous error
1010

0 commit comments

Comments
 (0)