make `mem::discriminant` const
implements #69821, which could be used as a tracking issue for `const_discriminant`.
Should this be added to the meta tracking issue #57563?
@Lokathor
Make Point `Copy` in arithmetic documentation
Small composite types like `Point { x: i32, y: i32}` are plain
old data and we should encourage users to derive `Copy` on them.
This changes the semantics of the edited examples slightly: instead
of consuming the operands during addition, it will copy them. This
is desired behaviour.
Use TypeRelating for instantiating query responses
`eq` can add constraints to `RegionConstraintData`, which isn't allowed during borrow checking outside of a `CustomTypeOp`. Use `TypeRelating` instead to always push constraints to the obligations list.
closes#69490
Stabilize const for integer {to,from}_{be,le,ne}_bytes methods
All of these functions can be implemented simply and naturally as const functions, e.g. `u32::from_le_bytes` can be implemented as
```rust
(bytes[0] as u32)
| (bytes[1] as u32) << 8
| (bytes[2] as u32) << 16
| (bytes[3] as u32) << 24
```
So stabilizing the constness will not expose that internally they are implemented using transmute which is not const in stable.
Cleanup `rmeta::MacroDef`
Avoid using rountrip parsing in the encoder and in `fn load_macro_untracked`.
The main reason I was interested in this was to remove `rustc_parse` as a dependency of `rustc_metadata` but it seems like this had other benefits as well.
Fixes#49511.
r? @eddyb
cc @matthewjasper @estebank @petrochenkov
Small composite types like `Point { x: i32, y: i32}` are plain
old data and we should encourage users to derive `Copy` on them.
This changes the semantics of the edited examples slightly: instead
of consuming the operands during addition, it will copy them. This
is desired behaviour.
Co-Authored-By: Jake Goulding <shepmaster@mac.com>
Rollup of 10 pull requests
Successful merges:
- #69475 (Remove the `no_force` query attribute)
- #69514 (Remove spotlight)
- #69677 (rustc_metadata: Give decoder access to whole crate store)
- #69714 (Make PlaceRef take just one lifetime)
- #69799 (Allow ZSTs in `AllocRef`)
- #69817 (test(patterns): add patterns feature tests to borrowck test suite)
- #69836 (Check if output is immediate value)
- #69847 (clean up E0393 explanation)
- #69861 (Add note about localization to std::fmt docs)
- #69877 (Vec::new is const stable in 1.39 not 1.32)
Failed merges:
r? @ghost
Allow ZSTs in `AllocRef`
Allows ZSTs in all `AllocRef` methods. The implementation of `AllocRef` for `Global` and `System` were adjusted to reflect those changes.
This is the second item on the roadmap to support ZSTs in `AllocRef`: https://github.com/rust-lang/wg-allocators/issues/38#issuecomment-595861542
After this has landed, I will adapt `RawVec`, but since this will be a pretty big overhaul, it makes sense to do a different PR for it.
~~Requires #69794 to land first~~
r? @Amanieu
Remove spotlight
I had a few comments saying that this feature was at best misunderstood or not even used so I decided to organize a poll about on [twitter](https://twitter.com/imperioworld_/status/1232769353503956994). After 87 votes, the result is very clear: it's not useful. Considering the amount of code we have just to run it, I think it's definitely worth it to remove it.
r? @kinnison
cc @ollie27
Remove the `no_force` query attribute
This removes the `no_force` query attribute and instead uses the `DepNodeParams` trait to find out if a query can be forced.
Also the `analysis` query is moved to the query macro.
r? @eddyb
unix: Don't override existing SIGSEGV/BUS handlers
Although `stack_overflow::init` runs very early in the process, even
before `main`, there may already be signal handlers installed for things
like the address sanitizer. In that case, just leave it alone, and don't
bother trying to allocate our own signal stacks either.
Fixes#69524.
Permit attributes on 'if' expressions
Previously, attributes on 'if' expressions (e.g. `#[attr] if true {}`)
were disallowed during parsing. This made it impossible for macros to
perform any custom handling of such attributes (e.g. stripping them
away), since a compilation error would be emitted before they ever had a
chance to run.
This PR permits attributes on 'if' expressions ('if-attrs' from here on).
Both built-in attributes (e.g. `#[allow]`, `#[cfg]`) and proc-macro attributes are supported.
We still do *not* accept attributes on 'other parts' of an if-else
chain. That is, the following code snippet still fails to parse:
```rust
if true {} #[attr] else if false {} else #[attr] if false {} #[attr]
else {}
```
Closes https://github.com/rust-lang/rust/issues/68618