Limit the promotion of const fns to the libstd and the `rustc_promotable` attribute
There are so many questions around promoting const fn calls... it seems saner to try to limit automatic promotion to const fns which were explicitly opted in for promotion.
I added the attribute to all public stable const fns that were already promotable (e.g. not Cell::new) in order to not cause any breakage
r? @eddyb
cc @nikomatsakis
NLL fails to suggest "try removing `&mut` here"
Fixes#51191.
This PR adds ``try removing `&mut` here`` suggestions to functions where a mutable borrow is being taken of a `&mut self` or a `self: &mut Self`. This PR also enables the suggestion for adding a `mut` pattern to by-value implicit self arguments without `mut` patterns already.
r? @nikomatsakis
do not promote comparing function pointers
This *could* break existing code that relied on fn ptr comparison getting promoted to `'static` lifetime.
Fixes https://github.com/rust-lang/rust/issues/54696
#53840: Consolidate pattern check errors
#53840 on this PR we are aggregating `cannot bind by-move and by-ref in the same pattern` message present on the different lines into one diagnostic message. Here we are first gathering those `spans` on `vector` then we are throwing them with the help of `MultiSpan`
r? @estebank
Addresses: #53480
we are consolidating `cannot bind by-move and by-ref in the same
pattern` message present on the different lines into single diagnostic
message.
To do this, we are first gathering those spans into the vector
after that we are throwing them with the help of MultiSpan in
a separate block.
Addresses: #53840
This commit improves mutability error suggestions by suggesting the
removal of `&mut` where a mutable borrow is being taken of a `&mut self`
or a `self: &mut Self`.
This commit adds an `ImplicitSelfKind` to the HIR and the MIR that keeps
track of whether a implicit self argument is immutable by-value, mutable
by-value, immutable reference or mutable reference so that the addition
of the `mut` keyword can be suggested for the immutable by-value case.
do not normalize all non-scalar constants to a ConstValue::ScalarPair
We still need `ConstValue::ScalarPair` for match handling (matching slices and strings), but that will never see anything `Undef`. For non-fat-ptr `ScalarPair`, just point to the allocation like larger data structures do.
Fixes https://github.com/rust-lang/rust/issues/54387
r? @eddyb
use closure def-id in returns, but base def-id in locals
The refactorings to handle `let x: impl Trait` wound up breaking `impl Trait` in closure return types. I think there are some deeper problems with the code in question, but this a least should make @eddyb's example work.
Fixes#54593
r? @eddyb
Rollup of 8 pull requests
Successful merges:
- #54564 (Add 1.29.1 release notes)
- #54567 (Include path in stamp hash for debuginfo tests)
- #54577 (rustdoc: give proc-macros their own pages)
- #54590 (std: Don't let `rust_panic` get inlined)
- #54598 (Remove useless lifetimes from `Pin` `impl`s.)
- #54604 (Added help message for `self_in_typedefs` feature gate)
- #54635 (Improve docs for std::io::Seek)
- #54645 (Compute Android gdb version in compiletest)
Before this patch running the following command would generate the given output:
$ rustc +stage1 src/test/ui/liveness/liveness-move-in-while.rs -Zborrowck=mir -Ztwo-phase-borrows
error[E0382]: borrow of moved value: `y`
--> src/main.rs:8:24
|
8 | println!("{}", y); //~ ERROR use of moved value: `y`
| ^ value borrowed here after move
9 | while true { while true { while true { x = y; x.clone(); } } }
| - value moved here
|
= note: move occurs because `y` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
We want to give the user more hint by telling them that the value was moved in the previous iteration of the
loop. After this patch, the error message adds the phrase "in previous iteration of loop" and in totality
looks like this:
$ rustc +stage1 src/test/ui/liveness/liveness-move-in-while.rs -Zborrowck=mir -Ztwo-phase-borrows
error[E0382]: borrow of moved value: `y`
--> src/test/ui/liveness/liveness-move-in-while.rs:17:24
|
17 | println!("{}", y); //~ ERROR use of moved value: `y`
| ^ value borrowed here after move
18 | while true { while true { while true { x = y; x.clone(); } } }
| - value moved here, in previous iteration of loop
|
= note: move occurs because `y` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
[NLL] Get Polonius borrow check to work in simple cases
* Restores the generation of outlives facts from subtyping.
* Restore liveness facts.
* Generate invalidates facts at the start point of each location,
where we check for errors.
* Add a small test for simple cases (previously these cases have compiled, and more recently ICEd).
Closes#54212
cc #53142 (will need test)
### Known limitations
* Two phase borrows aren't implemented for Polonius yet
* Invalidation facts haven't been updated for some of the recent changes to make `Drop` terminators access fewer things.
* Fact generation is not as optimized as it could be.
* Around 30 tests fail in compare mode, often tests that are ignored in nll compare mode
r? @nikomatsakis
Using the `closure_base_def_id` indiscriminantely, as we were doing
before, winds up "going wrong" if the closure type includes the `impl
Trait` from the parent. The problem arises because the return value
for closures is inferred and meant to treat the return
type *opaquely*, so we don't want to be "desugaring" it into the
underlying type.
* Restores the generation of outlives facts from subtyping.
* Restore liveness facts.
* Generate invalidates facts at the start point of each location,
where we check for errors.
* Add a small test for simple cases.
`impl trait` in bindings (feature: impl-trait-existential-types)
This PR enables `impl Trait` syntax (opaque types) to be used in bindings, e.g.
* `let foo: impl Clone = 1;`
* `static foo: impl Clone = 2;`
* `const foo: impl Clone = 3;`
This is part of [RFC 2071](https://github.com/rust-lang/rfcs/blob/master/text/2071-impl-trait-existential-types.md) ([tracking issue](https://github.com/rust-lang/rust/issues/34511)), but exists behind the separate feature gate `impl_trait_in_bindings`.
CC @cramertj @oli-obk @eddyb @Centril @varkor