Commit Graph

81874 Commits

Author SHA1 Message Date
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
bors
8958ed6722 Auto merge of #53216 - kennytm:rollup, r=kennytm
Rollup of 15 pull requests

Successful merges:

 - #52773 (Avoid unnecessary pattern matching against Option and Result)
 - #53082 (Fix doc link (again))
 - #53094 (Automatically expand section if url id point to one of its component)
 - #53106 (atomic ordering docs)
 - #53110 (Account for --remap-path-prefix in save-analysis)
 - #53116 (NetBSD: fix signedess of char)
 - #53179 (Whitelist wasm32 simd128 target feature)
 - #53183 (Suggest comma when missing in macro call)
 - #53207 (Add individual docs for rotate_{left, right})
 - #53211 ([nll] enable feature(nll) on various crates for bootstrap)
 - #53214 ([nll] enable feature(nll) on various crates for bootstrap: part 2)
 - #53215 (Slightly refactor syntax_ext/format)
 - #53217 (inline some short functions)
 - #53219 ([nll] enable feature(nll) on various crates for bootstrap: part 3)
 - #53222 (A few cleanups for rustc_target)
2018-08-09 19:05:14 +00:00
kennytm
9f55705a24
Rollup merge of #53207 - llogiq:num-rotate-docs, r=QuietMisdreavus
Add individual docs for rotate_{left, right}
2018-08-10 01:55:31 +08:00
kennytm
f067f3a45d
Rollup merge of #53222 - ljedrz:cleanup_rustc_target, r=Mark-Simulacrum
A few cleanups for rustc_target

- remove redundant struct field names
- shorten a self-assignment
- prefer `unwrap_or_else` in case of function calls
- collapse an `if`
- collapse a double `map()`
- match on dereferenced objects
- consume `self` if it implements `Copy`
2018-08-10 01:04:10 +08:00
kennytm
762855d23a
Rollup merge of #53215 - ljedrz:refactor_format, r=estebank
Slightly refactor syntax_ext/format

expand_preparsed_format_args:
- move a potential error `return` earlier in the processing
- pre-allocate some of the required space for `cx.pieces` and `cx.str_pieces`
- create `cx`-independent objects before `cx`
- build `pieces` and `errs` using `collect` instead of a `push` loop

describe_num_args:
- return `Cow<str>` instead of `String`
2018-08-10 01:03:45 +08:00
kennytm
e2d0e3f6ac
Rollup merge of #53219 - memoryruins:nll_bootstrap_3, r=nikomatsakis
[nll] enable feature(nll) on various crates for bootstrap: part 3

#53172
2018-08-10 01:01:33 +08:00
kennytm
62d70c9d47
Rollup merge of #53214 - memoryruins:nll_bootstrap_2, r=nikomatsakis
[nll] enable feature(nll) on various crates for bootstrap: part 2

#53172
2018-08-10 01:01:31 +08:00
kennytm
bb0151c6d4
Rollup merge of #53211 - memoryruins:nll_bootstrap, r=nikomatsakis
[nll] enable feature(nll) on various crates for bootstrap

#53172
2018-08-10 01:01:30 +08:00
kennytm
746abc3265
Rollup merge of #53082 - felixrabe:fix-doc-link-again, r=GuillaumeGomez
Fix doc link (again)

Similar to #52404. The link for comparison:

-   https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-sized (broken)

-   https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait (correct, stable 2nd ed)

-   https://doc.rust-lang.org/nightly/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait (correct, nightly 2nd ed)

-   https://doc.rust-lang.org/nightly/book/2018-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait (correct, nightly 2018 ed)

This commit is the result of (first) searching via ripgrep (0.8.1 -SIMD -AVX):

    rg -l dynamically-sized-types-and-sized

and then replacing all relevant occurrences via:

    find src/{libcore,test/ui} -type f -print0 | xargs -0 sed -i.bak \
      s/dynamically-sized-types-and-sized/dynamically-sized-types-and-the-sized-trait/g
    find src/{libcore,test/ui} -type f -name '*.bak' -print0 | xargs -0 rm

(Note: Tested on on macOS 10.13 (BSD). `sed -i.bak` should work on Linux
(GNU sed) as well, but not tested.)
2018-08-10 01:01:28 +08:00
kennytm
410f63dbb7
Rollup merge of #53217 - strake:inline, r=nagisa
inline some short functions

I found these were outline in binaries i link. I think they ought to be inline, considering their size.
2018-08-10 01:01:27 +08:00
kennytm
db74946803
Rollup merge of #53106 - RalfJung:ordering, r=stjepang
atomic ordering docs

Discussion in https://github.com/rust-lang/rfcs/pull/2503 revealed that this could be improved. I hope this helps.
2018-08-10 01:01:24 +08:00
kennytm
8188f12aaa
Rollup merge of #53183 - estebank:println-comma, r=oli-obk
Suggest comma when missing in macro call

When missing a comma in a macro call, suggest it, regardless of
position. When a macro call doesn't match any of the patterns, check
if the call's token stream could be missing a comma between two idents,
and if so, create a new token stream containing the comma and try to
match against the macro patterns. If successful, emit the suggestion.

This works on arbitrary macros, with no need of special support from
the macro writers.

```
error: no rules expected the token `d`
  --> $DIR/missing-comma.rs:26:18
   |
LL |     foo!(a, b, c d, e);
   |                 -^
   |                 |
   |                 help: missing comma here
```
Follow up to #52397.
2018-08-10 01:01:22 +08:00
kennytm
7f886cf12b
Rollup merge of #53179 - gnzlbg:patch-3, r=alexcrichton
Whitelist wasm32 simd128 target feature

r? @alexcrichton
2018-08-10 01:01:20 +08:00
Andre Bogus
cc2503a4f4 Add individual docs for rotate_{left, right} 2018-08-09 17:10:27 +02:00
ljedrz
25a58af064 A few cleanups for rustc_target 2018-08-09 15:42:43 +02:00
bors
b73535f1e9 Auto merge of #53031 - michaelwoerister:cross-lto, r=alexcrichton
Apply some fixes to cross-language LTO (especially when targeting MSVC)

This PR contains a few fixes that were needed in order to get Firefox compiling with Rust/C++ cross-language ThinLTO on Windows. The commits are self-contained and should be self-explanatory.

r? @alexcrichton
2018-08-09 13:20:14 +00:00
memoryruins
d25dbc5d84 [nll] libunwind: enable feature(nll) for bootstrap 2018-08-09 06:52:12 -04:00
memoryruins
58836e8a6f [nll] libterm: enable feature(nll) for bootstrap 2018-08-09 06:51:56 -04:00
memoryruins
01c598aa0d [nll] libsyntax_pos: enable feature(nll) for bootstrap 2018-08-09 06:51:42 -04:00
memoryruins
f331401e1e [nll] librustc_target: enable feature(nll) for bootstrap 2018-08-09 06:51:13 -04:00
memoryruins
a37360c330 [nll] librustc_incremental: enable feature(nll) for bootstrap 2018-08-09 06:50:57 -04:00
memoryruins
fd4b1a73bf [nll] librustc_driver: enable feature(nll) for bootstrap 2018-08-09 06:50:40 -04:00
memoryruins
c6be5551be [nll] librustc_cratesio_shim: enable feature(nll) for bootstrap 2018-08-09 06:50:25 -04:00
memoryruins
b340f56316 [nll] librustc_apfloat: enable feature(nll) for bootstrap 2018-08-09 06:49:31 -04:00
memoryruins
7e78e7570f [nll] libpanic_unwind: enable feature(nll) for bootstrap 2018-08-09 06:49:12 -04:00
memoryruins
04bd6146c3 [nll] libpanic_abort: enable feature(nll) for bootstrap 2018-08-09 06:48:53 -04:00
memoryruins
3ed965ab58 [nll] libfmt_macros: enable feature(nll) for bootstrap 2018-08-09 06:48:10 -04:00
M Farkas-Dyck
b78201aee5 inline some short functions 2018-08-09 01:27:48 -08:00
kennytm
23601d08e6
Rollup merge of #53116 - jakllsch:netbsd-unsigned-char, r=alexcrichton
NetBSD: fix signedess of char
2018-08-09 16:58:44 +08:00
kennytm
c24ba7e4f8
Rollup merge of #53110 - Xanewok:save-analysis-remap-path, r=nrc
Account for --remap-path-prefix in save-analysis

Fixes #52549.

Didn't add a test since save-analysis is still unstable, only tested this locally. Should I add a test for that? If so, is run-make-fulldeps an appropriate format?

Session is already created with remapped working directory, so use that instead of the actual cwd.
This was the only place affected, since the rest of the paths in save-analysis are directly derived from files in spans from `sess.codemap()`, which already creates remapped ones.

r? @nrc
2018-08-09 16:58:42 +08:00
kennytm
dad5b6c554
Rollup merge of #53094 - GuillaumeGomez:automatic-expand, r=nrc
Automatically expand section if url id point to one of its component

Fixes #52517.

r? @nrc
2018-08-09 16:58:41 +08:00
kennytm
c6f55bca7f
Rollup merge of #52773 - ljedrz:unncecessary_patterns, r=nikomatsakis
Avoid unnecessary pattern matching against Option and Result
2018-08-09 16:58:39 +08:00
memoryruins
034a96a081 [nll] librustc_tsan: enable feature(nll) for bootstrap 2018-08-09 04:11:06 -04:00
memoryruins
cb49252f57 [nll] librustc_traits: enable feature(nll) for bootstrap 2018-08-09 04:10:46 -04:00
memoryruins
9fcc6dab8d [nll] librustc_save_analysis: enable feature(nll) for bootstrap 2018-08-09 04:10:26 -04:00
memoryruins
03a5694c2d [nll] librustc_resolve: enable feature(nll) for bootstrap 2018-08-09 04:10:08 -04:00
memoryruins
87fb6fc6ef [nll] librustc_privacy: enable feature(nll) for bootstrap 2018-08-09 04:09:50 -04:00
memoryruins
a6b7163c74 [nll] librustc_plugin: enable feature(nll) for bootstrap 2018-08-09 04:09:29 -04:00
memoryruins
95b64188c9 [nll] librustc_passes: enable feature(nll) for bootstrap 2018-08-09 04:09:07 -04:00
memoryruins
80e8e97d93 [nll] librustc_errors: enable feature(nll) for bootstrap 2018-08-09 04:08:45 -04:00
memoryruins
742a95149f [nll] librustc_asan: enable feature(nll) for bootstrap 2018-08-09 04:08:17 -04:00
memoryruins
d2e0c782a9 [nll] libarena: enable feature(nll) for bootstrap 2018-08-09 04:07:59 -04:00
ljedrz
aab063a40e Use Cow<str> in describe_num_args 2018-08-09 09:59:13 +02:00
Michael Woerister
49972e93ff Relax the target-cpu-on-function codegen test so it just checks for presence of the attribute. 2018-08-09 09:39:02 +02:00
bors
fbb6275f4f Auto merge of #53108 - RalfJung:mutex, r=alexcrichton
clarify partially initialized Mutex issues

Using a `sys_common::mutex::Mutex` without calling `init` is dangerous, and yet there are some places that do this. I tried to find all of them and add an appropriate comment about reentrancy.

I found two places where (I think) reentrancy can actually occur, and was not able to come up with an argument for why this is okay. Someone who knows `io::lazy` and/or `sys_common::at_exit_imp` should have a careful look at this.
2018-08-09 07:30:14 +00:00
ljedrz
c7646d54dd Refactor expand_preparsed_format_args 2018-08-09 08:55:49 +02:00
memoryruins
ce7f0c483d liballoc: enable feature(nll) for bootstrap 2018-08-09 01:50:49 -04:00
memoryruins
fa1bdd696d liballoc_jemalloc: enable feature(nll) for bootstrap 2018-08-09 01:50:37 -04:00
memoryruins
1c3d20eb41 liballoc_system: enable feature(nll) for bootstrap 2018-08-09 01:50:22 -04:00
memoryruins
98d94223a5 libgraphviz: enable feature(nll) for bootstrap 2018-08-09 01:50:08 -04:00