about summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-05-09 17:40:04 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-05-11 15:45:19 -0700
commit0dcde02cc7bdd47f48af12e911829390c2864c47 (patch)
tree6819f4016c4f82ecb114286f369b76fb853bc83f /src/libstd/sys/unix/stack_overflow.rs
parent4802f097c86452cd2e09d44e88dbcb8e08266552 (diff)
downloadrust-0dcde02cc7bdd47f48af12e911829390c2864c47.tar.gz
rust-0dcde02cc7bdd47f48af12e911829390c2864c47.zip
Ignore arguments when looking for `IndexMut` for subsequent `mut` obligation
Given code like `v[&field].boo();` where `field: String` and
`.boo(&mut self)`, typeck will have decided that `v` is accessed using
`Index`, but when `boo` adds a new `mut` obligation,
`convert_place_op_to_mutable` is called. When this happens, for *some
reason* the arguments' dereference adjustments are completely ignored
causing an error saying that `IndexMut` is not satisfied:

```
error[E0596]: cannot borrow data in an index of `Indexable` as mutable
  --> src/main.rs:30:5
   |
30 |     v[&field].boo();
   |     ^^^^^^^^^ cannot borrow as mutable
   |
   = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Indexable`
```

This is not true, but by changing `try_overloaded_place_op` to retry
when given `Needs::MutPlace` without passing the argument types, the
example successfully compiles.

I believe there might be more appropriate ways to deal with this.
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions