diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-08-12 12:07:08 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-12 12:07:08 +0900 |
| commit | 43babed7e2ecebc401a6dd792e52700afbe0ec5c (patch) | |
| tree | 5035d3df3212b43b8cb210e871dab8f1b819a4e9 /src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs | |
| parent | 7e503a09b512e400fd2f2dd27f11d515e41dc784 (diff) | |
| parent | 000f5cdd24be7067c3294e1fba2da4a3e88dd849 (diff) | |
| download | rust-43babed7e2ecebc401a6dd792e52700afbe0ec5c.tar.gz rust-43babed7e2ecebc401a6dd792e52700afbe0ec5c.zip | |
Rollup merge of #74960 - nbdd0121:typeck, r=nikomatsakis
Fix regionck failure when converting Index to IndexMut Fixes #74933 Consider an overloaded index expression `base[index]`. Without knowing whether it will be mutated, this will initially be desugared into `<U as Index<T>>::index(&base, index)` for some `U` and `T`. Let `V` be the `expr_ty_adjusted` of `index`. If this expression ends up being used in any mutable context (or used in a function call with `&mut self` receiver before #72280), we will need to fix it up. The current code will rewrite it to `<U as IndexMut<V>>::index_mut(&mut base, index)`. In most cases this is fine as `V` will be equal to `T`, however this is not always true when `V/T` are references, as they may have different region. This issue is quite subtle before #72280 as this code path is only used to fixup function receivers, but after #72280 we've made this a common path. The solution is basically just rewrite it to `<U as IndexMut<T>>::index_mut(&mut base, index)`. `T` can retrieved in the fixup path using `node_substs`.
Diffstat (limited to 'src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs')
0 files changed, 0 insertions, 0 deletions
