stabilize #[panic_handler]
closes#44489
### Update(2018-09-07)
This was proposed for stabilization in https://github.com/rust-lang/rust/issues/44489#issuecomment-398965881 and its FCP with disposition to merge / accept is nearly over. The summary of what's being stabilized can be found in https://github.com/rust-lang/rust/issues/44489#issuecomment-416645946
Documentation PRs:
- Reference. https://github.com/rust-lang-nursery/reference/pull/362
- Nomicon. https://github.com/rust-lang-nursery/nomicon/pull/75
---
`#[panic_implementation]` was implemented recently in #50338. `#[panic_implementation]` is basically the old `panic_fmt` language item but in a less error prone (\*) shape. There are still some issues and questions to sort out around this feature (cf. #44489) but this PR is meant to start a discussion about those issues / questions with the language team.
(\*) `panic_fmt` was not type checked; changes in its function signature caused serious, silent binary size regressions like the one observed in #43054
Some unresolved questions from #44489:
> Should the Display of PanicInfo format the panic information as "panicked at 'reason',
> src/main.rs:27:4", as "'reason', src/main.rs:27:4", or simply as "reason".
The current implementation formats `PanicInfo` as the first alternative, which is how panic messages are formatted by the `std` panic handler. The `Display` implementation is more than a convenience: `PanicInfo.message` is unstable so it's not possible to replicate the `Display` implementation on stable.
> Is this design compatible, or can it be extended to work, with unwinding implementations for
> no-std environments?
I believe @whitequark made more progress with unwinding in no-std since their last comment in #44489. Perhaps they can give us an update?
---
Another unresolved question is where this feature should be documented. The feature currently doesn't have any documentation.
cc @rust-lang/lang
cc @jackpot51 @alevy @phil-opp
do not propagate closure requirements if we can prove them locally
Fixes#53570
cc @mikhail-m1 -- you're the one who last touched this code
r? @pnkfelix
This allows it to print out the "late-bound regions" from the closure
context more easily. Besides, all the state that is being printed it
is private to the `UniversalRegions`.
[nll] teach SCC about `'static`
r? @nikomatsakis
I think this is right? I am seeing better performance on the `html5ever` benchmark but I'd like a perf run to quantify the exact speedup. There's a few ui tests failing due to changes in the error messages. The main issue seems to be that returns aren't being detected correctly?
`mir_check_cast_unsize.rs` before:
```
error: unsatisfied lifetime constraints
--> mir_check_cast_unsize.rs:17:46
|
17 | fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
| ________--____________________________________^
| | |
| | lifetime `'a` defined here
18 | | //~^ ERROR unsatisfied lifetime constraints
19 | | x
20 | | //~^ WARNING not reporting region error due to nll
21 | | }
| |_^ return requires that `'a` must outlive `'static`
```
`mir_check_cast_unsize.rs` after:
```
error: unsatisfied lifetime constraints
--> mir_check_cast_unsize.rs:19:5
|
17 | fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
| -- lifetime `'a` defined here
18 | //~^ ERROR unsatisfied lifetime constraints
19 | x
| ^ cast requires that `'a` must outlive `'static`
```
We're shipping a rust-enabled lldb, but the "lldb" executable is not
installed into the "bin" directory by rustup. See the discussion in
https://github.com/rust-lang-nursery/rustup.rs/pull/1492 for
background on this decision. There, we agreed to have rust-lldb
prefer the rust-enabled lldb if it is installed.
This patch changes dist.rs to put lldb into rustlib, following what
was done for the other LLVM tools in #53955, and then fixes rust-lldb
to prefer that lldb, if it exists.
See issue #48168
Rollup of 17 pull requests
Successful merges:
- #53299 (Updated core/macros.rs to note it works in a no_std environment.)
- #53376 (Cross reference io::copy and fs::copy in docs.)
- #53455 (Individual docs for {from,to}_*_bytes)
- #53550 (librustc_lint: In recursion warning, change 'recurring' to 'recursing')
- #53860 (Migrate (some) of run-pass/ to ui)
- #53874 (Implement Unpin for Box, Rc, and Arc)
- #53895 (tidy: Cleanups and clippy warning fixes)
- #53946 (Clarify `ManuallyDrop` docs)
- #53948 (Minimized clippy test from when NLL disabled two-phase borrows)
- #53959 (Add .git extension to submodule paths missing it)
- #53966 (A few cleanups and minor improvements to mir/dataflow)
- #53967 (propagate build.python into cmake)
- #53979 (Remove `#[repr(transparent)]` from atomics)
- #53991 (Add unchecked_shl/shr check for intrinsics to fix miri's test suit)
- #53992 (migrate run-pass/borrowck to ui/run-pass)
- #53994 (migrate run-pass/*/ to ui/run-pass)
- #54023 (update clippy submodule)
Remove `#[repr(transparent)]` from atomics
Added in #52149 the discussion in #53514 is showing how we may not want to
actually add this attribute to the atomic types. While we continue to
debate #53514 this commit reverts the addition of the `transparent` attribute.
This should be a more conservative route which leaves us the ability to tweak
this in the future but in the meantime allows us to continue discussion as well.
propagate build.python into cmake
If a suitable value of Python is not on `PATH`, one can still invoke x.py
manually, which propagates `BOOTSTRAP_PYTHON` into the bootstrap
environment. But building LLVM will abort with error messages about not
being able to find Python, and instructions to set `PYTHON_EXECUTABLE`,
because nothing is done with `BOOTSTRAP_PYTHON` when invoking cmake.
Setting `build.python` in config.toml had no effect in this scenario,
either
To fix this, let's provide `PYTHON_EXECUTABLE` when invoking cmake; for
the "normal" case of Python in `PATH`, this doesn't alter any behavior.
For more unusual cases, however, this ensures cmake finds Python
properly. (This change also ensures there are no differences between
what bootstrap is using, and what cmake uses, which may be useful for
consistency's sake.)
A few cleanups and minor improvements to mir/dataflow
- simplify `dot::GraphWalk::edges` and optimize its vector's allocation
- turn a `kill` loop into `kill_all`
- remove the `prepost` parameter from `dataflow_path` (it doesn't seem to do anything)
- a couple of other minor improvements
Add .git extension to submodule paths missing it
Fixes a problem where submodules could not be cloned under some git
configurations. Specifically, when url.git@github.com:.insteadOf =
https://github.com/ is set.
tidy: Cleanups and clippy warning fixes
This eliminates various clippy warnings in the tidy tool, as well as
making some related cleanups. These changes should not introduce any
functional differences.
Migrate (some) of run-pass/ to ui
This is a step towards addressing #53764. Much still remains.
I went through a large portion of the `*.rs` files that were directly stored into `src/test/run-pass/` and moved them into various subdirectories of a newly created `src/test/ui/run-pass/`.
(yes, it would have perhaps been nice to meld it more directly with directories already in `src/test/ui/`; but the sad truth is that opens up the reality of filename collisions, and one of my short term goals for resolving #53764 is to keep the *filenames* invariant, even as their parents directories and contents are mildly revised...)
librustc_lint: In recursion warning, change 'recurring' to 'recursing'
The existing wording seems incorrect.
Aside: This warning, 'function cannot return without recursing' is not perfectly clear - it implies that the function _can_ return, it's just got to recurse. But really the fn cannot return period. Clearer wording: 'function recurses infinitely; it cannot return'; or 'function is infinitely self-recursive; it cannot return, and this is probably an error'. I like that.
Updated core/macros.rs to note it works in a no_std environment.
Fixes#45797
This PR updates the documentation of `write!` to note it works in a `no_std` environment, and adds an
example to showcase this. In a `no_std` environment, the author of the code is responsible for the
implementation of the `Write` trait. This example will work out of the box with `no_std`, but the
implementation of `Write` is expected to be provided by the user.
r? @steveklabnik