Skip to content

Commit c70dbd4

Browse files
committed
jdonszelmann feedback
1 parent 62b3b53 commit c70dbd4

File tree

2 files changed

+7
-5
lines changed
  • compiler

2 files changed

+7
-5
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

0 commit comments

Comments
 (0)