The callbacks have precisely two states: the default, and the one
present throughout almost all of the rustc run (the filled in value
which has access to TyCtxt).
We used to store this as a thread local, and reset it on each thread to
the non-default value. But this is somewhat wasteful, since there is no
reason to set it globally -- while the callbacks themselves access TLS,
they do not do so in a manner that fails in when we do not have TLS to
work with.
Generalize `array_into_iter` lint to also lint for boxed arrays
`Box` is special in that a method call on a box can move the value out
of the box. Thus, the same backwards-compatibility problem can arise
for boxed arrays as for simple arrays.
---
CC #66145
r? @matthewjasper (as you reviewed the first PR)
`description` has been documented as soft-deprecated since 1.27.0 (17
months ago). There is no longer any reason to call it or implement it.
This commit:
- adds #[rustc_deprecated(since = "1.41.0")] to Error::description;
- moves description (and cause, which is also deprecated) below the
source and backtrace methods in the Error trait;
- reduces documentation of description and cause to take up much less
vertical real estate in rustdocs, while preserving the example that
shows how to render errors without needing to call description;
- removes the description function of all *currently unstable* Error
impls in the standard library;
- marks #[allow(deprecated)] the description function of all *stable*
Error impls in the standard library;
- replaces miscellaneous uses of description in example code and the
compiler.
This still doesn't handle the case entirely correctly, requiring a more
targeted approach with a better suggestion, but at least now the
suggested syntax makes *some* sense.
(Mostly) finish formatting the repository
Silences tidy line length warnings on rustfmt-controlled files.
This leaves two things out of formatting: CloudABI (mostly because it's not really ours to control, it's upstream code that's mostly generated), and tests. The latter is a hard problem and maybe not one to worry too much about, we rarely edit old tests and reformatting them as we go if possible isn't too bad (they're generally small).
Differentiate todo! and unimplemented!
This updates the panic message and docs to make it clear that `todo!` is for unfinished code and `unimplemented!` is for partial trait or enum impls.
r? @Centril
Refactorings to borrowck region diagnostic reporting
This PR is a followup to #66886 and #67404
EDIT: updated
In this PR: Clean up how errors are collected from NLL: introduce `borrow_check::diagnostics::RegionErrors` to collect errors. This is later passed to `MirBorrowckCtx::report_region_errors` after the `MirBorrowckCtx` is created. This will allow us to refactor away some of the extra context structs floating around (but we don't do it in this PR). `borrow_check::region_infer` is now mostly free of diagnostic generating code. The signatures of most of the functions in `region_infer` lose somewhere between 4 and 7 arguments :)
Left for future (feedback appreciated):
- Merge `ErrorRegionCtx` with `MirBorrowckCtx`, as suggested by @matthewjasper in https://github.com/rust-lang/rust/pull/66886#issuecomment-559949499
- Maybe move the contents of `borrow_check::nll` into `borrow_check` and remove the `nll` submodule altogether.
- Find a way to make `borrow_check::diagnostics::region_errors` less of a strange appendage to `RegionInferenceContext`. I'm not really sure how to do this yet. Ideas welcome.
`Box` is special in that a method call on a box can move the value out
of the box. Thus, the same backwards-compatibility problem can arise
for boxed arrays as for simple arrays.
Show the actual value of constant values in the documentation
Fixes#66099, making rustdoc show evaluated constant scalar values.
![image](https://user-images.githubusercontent.com/2358365/68474827-c7a95e80-0226-11ea-818a-ded7bbff861f.png)
where `main.rs` is
```
pub const VAL3: i32 = i32::max_value();
pub const VAL4: i32 = i32::max_value() - 1;
```
As a fallback, when a constant value is not evaluated (either because of an error or because it isn't a scalar), the original expression is used for consistency.
I mimicked the way min/max values of integers are [`pretty_print`ed](https://github.com/rust-lang/rust/blob/master/src/librustc/ty/print/pretty.rs#L900), to show both the value a the "hint". While a little goofy for `std`, in user crates I think it's actually rather helpful.
Rollup of 7 pull requests
Successful merges:
- #67337 (Ensure that evaluating or validating a constant never reads from a static)
- #67543 (Add regression tests for fixed ICEs)
- #67547 (Cleanup err codes)
- #67551 (Add long error code explanation message for E0627)
- #67561 (remove `description` from `Error` impls in docs)
- #67569 (Clean up unsafety in char::encode_utf8)
- #67572 (Use the chocolatey CDN directly to avoid the flaky API)
Failed merges:
r? @ghost