diff options
| author | bors <bors@rust-lang.org> | 2025-10-02 11:14:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-10-02 11:14:37 +0000 |
| commit | 94ecb52bbeeccc990545d4ebc9e9c35dcaf285e3 (patch) | |
| tree | b3836c3f29d9f4ce549e329a6234adc437c1d5aa /compiler/rustc_error_codes | |
| parent | 4b9c62b4da3e17cee99d3d2052f1c576b188e2a8 (diff) | |
| parent | 2d1efe76bcf0871a580476841141441742198310 (diff) | |
| download | rust-94ecb52bbeeccc990545d4ebc9e9c35dcaf285e3.tar.gz rust-94ecb52bbeeccc990545d4ebc9e9c35dcaf285e3.zip | |
Auto merge of #147261 - matthiaskrgr:rollup-yh3fgvc, r=matthiaskrgr
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
Diffstat (limited to 'compiler/rustc_error_codes')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0608.md | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0608.md b/compiler/rustc_error_codes/src/error_codes/E0608.md index d0ebc3a26f0..3c29484f575 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0608.md +++ b/compiler/rustc_error_codes/src/error_codes/E0608.md @@ -1,5 +1,5 @@ -An attempt to use index on a type which doesn't implement the `std::ops::Index` -trait was performed. +Attempted to index a value whose type doesn't implement the +`std::ops::Index` trait. Erroneous code example: @@ -7,8 +7,8 @@ Erroneous code example: 0u8[2]; // error: cannot index into a value of type `u8` ``` -To be able to index into a type it needs to implement the `std::ops::Index` -trait. Example: +Only values with types that implement the `std::ops::Index` trait +can be indexed with square brackets. Example: ``` let v: Vec<u8> = vec![0, 1, 2, 3]; @@ -16,3 +16,10 @@ let v: Vec<u8> = vec![0, 1, 2, 3]; // The `Vec` type implements the `Index` trait so you can do: println!("{}", v[2]); ``` + +Tuples and structs are indexed with dot (`.`), not with brackets (`[]`), +and tuple element names are their positions: +```ignore(pseudo code) +// this (pseudo code) expression is true for any tuple: +tuple == (tuple.0, tuple.1, ...) +``` |
