rust/src
bors fb65d7563c Auto merge of #52788 - LukasKalbertodt:improve-index-mut-error, r=estebank
Add help message for missing `IndexMut` impl

Code:
```rust
let mut map = HashMap::new();
map.insert("peter", 23);
map["peter"] = 27;
```

Before:
```
error[E0594]: cannot assign to immutable indexed content
 --> src/main.rs:7:5
  |
7 |     map["peter"] = 27;
  |     ^^^^^^^^^^^^^^^^^ cannot borrow as mutable
```

With this change (just the `help` was added):
```
error[E0594]: cannot assign to immutable indexed content
 --> index-error.rs:7:5
  |
7 |     map["peter"] = 27;
  |     ^^^^^^^^^^^^^^^^^ cannot borrow as mutable
  |
  = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for std::collections::HashMap<&str, i32>
```

---

Yesterday I did some pair programming with a Rust-beginner. We created a type and implemented `Index` for it. Trying to modify the value returned by the index operation returns in a rather vague error that was not very clear for the Rust beginner. So I tried to improve the situation.

## Notes/questions for reviewers:
- Is the formulation OK like that? I'm fine with changing it.
- Can we be absolutely sure that `IndexMut` is actually not implemented in the case my `help` message is added? I'm fairly sure myself, but there could be some cases I didn't think of. Also, I don't know the compiler very well, so I don't know what exactly certain enum variants are used for.
  - It would be nice to test if `IndexMut` is in fact not implemented for the type, but I couldn't figure out how to check that. If you think that additional check would be beneficial, could you tell me how to check if a trait is implemented?
- Do you think I should change the error message instead of only adding an additional help message?
2018-08-09 22:05:18 +00:00
..
bootstrap Building librustc_codegen_llvm in a separate directory 2018-08-06 07:00:34 -06:00
build_helper Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
ci Rollup merge of #52940 - kennytm:move-checktool-protection-week, r=alexcrichton 2018-08-04 14:35:49 +08:00
dlmalloc@c99638dc2e
doc Rollup merge of #52831 - dsciarra:rm-ref-to-author-file, r=alexcrichton 2018-08-01 10:12:47 +02:00
etc Remove unnecessary or invalid feature attributes 2018-08-05 15:54:48 +01:00
grammar
jemalloc@1f5a28755e
liballoc liballoc: enable feature(nll) for bootstrap 2018-08-09 01:50:49 -04:00
liballoc_jemalloc liballoc_jemalloc: enable feature(nll) for bootstrap 2018-08-09 01:50:37 -04:00
liballoc_system liballoc_system: enable feature(nll) for bootstrap 2018-08-09 01:50:22 -04:00
libarena [nll] libarena: enable feature(nll) for bootstrap 2018-08-09 04:07:59 -04:00
libbacktrace@f4d02bbdbf
libcompiler_builtins@d549d85b17 Update LLVM submodule to 7.0 2018-08-04 17:30:14 -07:00
libcore Rollup merge of #53207 - llogiq:num-rotate-docs, r=QuietMisdreavus 2018-08-10 01:55:31 +08:00
libfmt_macros [nll] libfmt_macros: enable feature(nll) for bootstrap 2018-08-09 06:48:10 -04:00
libgraphviz libgraphviz: enable feature(nll) for bootstrap 2018-08-09 01:50:08 -04:00
liblibc@6bdbf5dc93 Update libc and activate align feature 2018-08-08 10:52:10 +02:00
libpanic_abort [nll] libpanic_abort: enable feature(nll) for bootstrap 2018-08-09 06:48:53 -04:00
libpanic_unwind [nll] libpanic_unwind: enable feature(nll) for bootstrap 2018-08-09 06:49:12 -04:00
libproc_macro Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
libprofiler_builtins Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
librustc Auto merge of #53216 - kennytm:rollup, r=kennytm 2018-08-09 19:05:14 +00:00
librustc_allocator rustc: Tweak visibility of some lang items 2018-08-07 08:42:38 -07:00
librustc_apfloat [nll] librustc_apfloat: enable feature(nll) for bootstrap 2018-08-09 06:49:31 -04:00
librustc_asan [nll] librustc_asan: enable feature(nll) for bootstrap 2018-08-09 04:08:17 -04:00
librustc_borrowck Auto merge of #52788 - LukasKalbertodt:improve-index-mut-error, r=estebank 2018-08-09 22:05:18 +00:00
librustc_codegen_llvm Auto merge of #53216 - kennytm:rollup, r=kennytm 2018-08-09 19:05:14 +00:00
librustc_codegen_utils Use diagnostic API on Session 2018-08-04 06:54:36 -06:00
librustc_cratesio_shim [nll] librustc_cratesio_shim: enable feature(nll) for bootstrap 2018-08-09 06:50:25 -04:00
librustc_data_structures Auto merge of #52644 - varkor:lib-feature-gate-2, r=withoutboats 2018-08-06 16:58:27 +00:00
librustc_driver [nll] librustc_driver: enable feature(nll) for bootstrap 2018-08-09 06:50:40 -04:00
librustc_errors Rollup merge of #53214 - memoryruins:nll_bootstrap_2, r=nikomatsakis 2018-08-10 01:01:31 +08:00
librustc_incremental [nll] librustc_incremental: enable feature(nll) for bootstrap 2018-08-09 06:50:57 -04:00
librustc_lint Rollup merge of #53211 - memoryruins:nll_bootstrap, r=nikomatsakis 2018-08-10 01:01:30 +08:00
librustc_llvm [RISCV] Enable LLVM backend. 2018-08-01 15:32:22 +02:00
librustc_lsan Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
librustc_metadata librustc_metadata: enable feature(nll) for bootstrap 2018-08-09 01:49:07 -04:00
librustc_metadata_utils Move unused trait functions to inherent functions 2018-08-03 11:44:09 -06:00
librustc_mir Rollup merge of #52773 - ljedrz:unncecessary_patterns, r=nikomatsakis 2018-08-09 16:58:39 +08:00
librustc_msan Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
librustc_passes [nll] librustc_passes: enable feature(nll) for bootstrap 2018-08-09 04:09:07 -04:00
librustc_platform_intrinsics Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
librustc_plugin [nll] librustc_plugin: enable feature(nll) for bootstrap 2018-08-09 04:09:29 -04:00
librustc_privacy [nll] librustc_privacy: enable feature(nll) for bootstrap 2018-08-09 04:09:50 -04:00
librustc_resolve Rollup merge of #53214 - memoryruins:nll_bootstrap_2, r=nikomatsakis 2018-08-10 01:01:31 +08:00
librustc_save_analysis Rollup merge of #53214 - memoryruins:nll_bootstrap_2, r=nikomatsakis 2018-08-10 01:01:31 +08:00
librustc_target Rollup merge of #53222 - ljedrz:cleanup_rustc_target, r=Mark-Simulacrum 2018-08-10 01:04:10 +08:00
librustc_traits [nll] librustc_traits: enable feature(nll) for bootstrap 2018-08-09 04:10:46 -04:00
librustc_tsan [nll] librustc_tsan: enable feature(nll) for bootstrap 2018-08-09 04:11:06 -04:00
librustc_typeck Rollup merge of #52773 - ljedrz:unncecessary_patterns, r=nikomatsakis 2018-08-09 16:58:39 +08:00
librustdoc Rollup merge of #53094 - GuillaumeGomez:automatic-expand, r=nrc 2018-08-09 16:58:41 +08:00
libserialize Rollup merge of #52778 - ljedrz:readable_serialize, r=kennytm 2018-08-01 10:12:40 +02:00
libstd Auto merge of #53216 - kennytm:rollup, r=kennytm 2018-08-09 19:05:14 +00:00
libsyntax Rollup merge of #53183 - estebank:println-comma, r=oli-obk 2018-08-10 01:01:22 +08:00
libsyntax_ext Rollup merge of #53215 - ljedrz:refactor_format, r=estebank 2018-08-10 01:03:45 +08:00
libsyntax_pos [nll] libsyntax_pos: enable feature(nll) for bootstrap 2018-08-09 06:51:42 -04:00
libterm [nll] libterm: enable feature(nll) for bootstrap 2018-08-09 06:51:56 -04:00
libtest Auto merge of #52805 - ljedrz:format_str_literal, r=petrochenkov 2018-07-30 06:29:39 +00:00
libunwind [nll] libunwind: enable feature(nll) for bootstrap 2018-08-09 06:52:12 -04:00
llvm@e19f07f5a6 Update LLVM submodule to 7.0 2018-08-04 17:30:14 -07:00
llvm-emscripten@2717444753
rtstartup
rustc Update libc and activate align feature 2018-08-08 10:52:10 +02:00
rustllvm Auto merge of #51007 - AstralSorcerer:master, r=nagisa 2018-08-07 02:12:35 +00:00
stdsimd@05c2f61c38 update the stdsimd submodule 2018-07-24 11:08:11 -05:00
test Auto merge of #52788 - LukasKalbertodt:improve-index-mut-error, r=estebank 2018-08-09 22:05:18 +00:00
tools Update clippy submodule 2018-08-08 13:19:30 +02:00
Cargo.lock Update libc to 0.2.43 in Cargo.lock 2018-08-08 10:52:10 +02:00
Cargo.toml Update Cargo submodule 2018-08-02 18:09:19 -07:00
README.md
stage0.txt Switch to bootstrapping from 1.29 beta 2018-08-01 11:59:08 -06:00

This directory contains the source code of the rust project, including:

  • rustc and its tests
  • libstd
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc guide.

Their is also useful content in the following READMEs, which are gradually being moved over to the guide: