Update the error message for a missing global allocator
Don’t mention `#[default_lib_allocator]` (which is an implementation detail irrelevant to most users) and instead suggest using `#[global_allocator]`, which is often the correct fix.
NLL diagnostics: revise `fn check_access_permissions`
NLL: revise `fn check_access_permissions` so that its (still branchy) shares more code paths between the different cases, and also provide more diagnostics in more cases (though the added diagnostics still do not always meet the quality bar established by AST-borrowck)
----
Transcribing "checklist" suggested by Niko, except I am rendering it as a table to make it clear that I do not regard every item in the list to be a "must have" for landing this PR.
goal | does this PR do it?
-----|------------------------------
no suggestions for `ref mut` | yes
suggestions for direct local assignment (`{ let x = 3; x = 4; }`) | yes (see commits at end)
suggestions for direct field assignment (`{ let x = (3, 4); x.0 = 5; }` | yes (see commits at end)
suggestions for upvars (`let x = 3; let c = \|\| { &mut x; }`) | yes
Note that I added support for a couple of rows via changes that are not strictly part of `fn check_access_permissions`. If desired I can remove those commits from this PR and leave them for a later PR.
Fix#51031Fix#51032
(bug #51191 needs a little more investigation before closing.)
Fix#51578
Rename OOM to allocation error
The acronym is not descriptive unless one has seen it before.
* Rename the `oom` function to `handle_alloc_error`. It was **stabilized in 1.28**, so if we do this at all we need to land it this cycle.
* Rename `set_oom_hook` to `set_alloc_error_hook`
* Rename `take_oom_hook` to `take_alloc_error_hook`
Bikeshed: `on` v.s. `for`, `alloc` v.s. `allocator`, `error` v.s. `failure`
Don’t mention `#[default_lib_allocator]` (which is an implementation detail
irrelevant to most users) and instead suggest using `#[global_allocator]`,
which is often the correct fix.
(since I made this mistake at first but the tests didn't catch it):
we should not suggest adding `mut` to a reassigned `ref` or `ref mut` binding.
(The Rust language, since at least 1.0, does not have `mut ref mut` or
`ref mut mut` etc.)
Tried to unify various common code paths and also vaguely approximate
the AST-borrowck diagnostics.
The change in (subjective) quality of diagnostics is not a universal
improvement. But I think this is a better code base to work from
for future fixes.