extra: use a mutex to wrap linenoise calls and make them threadsafe.

Fixes #3921.
extra: stop rl from leaking each line that is read.
extra: improvements & bug fixes to rl.

- Removes a layer of indirection in the storage of the completion
  callback.
- Handles user tab completion in a task in which `complete` hasn't been
  properly. Previously, if `complete` was called in one task, and `read`
  called in another, attempting to get completions would crash. This
  makes the completion handlers non-ambiguously task-local only.
- Fix a mismatch in return values between the Rust code and linenoise.
Add a test for extra::rl.

This test has to be run by a human, to check inputs etc. Fortunately, it
won't bitrot (syntactically, or type-check-ly; it might bitrot
semantically), as it is designed so that the test runner compiles it with
`--cfg robot_mode`, which is used to disable the actual running of code.
Add linenoise lock helpers to rustrt.def.in.
auto merge of #9096 : huonw/rust/linenoise, r=brson

- Wrap calls into linenoise in a mutex so that the functions don't have to be `unsafe` any more (fixes #3921)
- Stop leaking every line that linenoise reads.
- Handle the situation of `rl::complete(some_function); do spawn { rl::read(""); }` which would crash (`fail!` that turned into an abort, possibly due to failing with the lock locked) when the user attempted to tab-complete anything.
- Add a test for the various functions; it has to be run by hand to verify anything works, but it won't bitrot.