panic_bounds_check: use caller_location, like PanicFnLangItem
The `PanicFnLangItem` got switched to using `#[caller_location]` at some point, but `PanicBoundsCheckFnLangItem` was kept in the old style. For consistency, switch that one over to use `#[caller_location]` as well.
This is also helpful for Miri as it means the `assert_panic` machine hook never needs to know the current `Span`.
Improve expression & attribute parsing
This PR includes misc improvements to expression and attribute parsing.
1. Some code simplifications
2. Better recovery for various block forms, e.g. `loop statements }` (missing `{` after `loop`). (See e.g., `block-no-opening-brace.rs` among others for examples.)
3. Added recovery for e.g., `unsafe $b` where `$b` refers to a `block` macro fragment. (See `bad-interpolated-block.rs` for examples.)
4. ^--- These are done so that code sharing in block parsing is increased.
5. Added recovery for e.g., `'label: loop { ... }` (See `labeled-no-colon-expr.rs`.)
6. Added recovery for e.g., `&'lifetime expr` (See `regions-out-of-scope-slice.rs`.)
7. Added recovery for e.g., `fn foo() = expr;` (See `fn-body-eq-expr-semi.rs`.)
8. Simplified attribute parsing code & slightly improved diagnostics.
9. Added recovery for e.g., `Box<('a) + Trait>`.
10. Added recovery for e.g, `if true #[attr] {} else #[attr] {} else #[attr] if true {}`.
r? @estebank
tidy: replace `make check` with `./x.py test` in documentation
This PR includes a minor documentation update for tidy. It replaces the `make check` approach with `./x.py test` and describes how to execute the tidy checks (only) with ~~`./x.py test src/tools/tidy`~~ `./x.py test tidy`.
--show-coverage json
The purpose of this change is to be able to use it as a tool in docs.rs in order to provide some more stats to crates' owners. Eventually even create a badge or something along the line.
r? @QuietMisdreavus
parse: Tweak the function parameter edition check
Follow-up to https://github.com/rust-lang/rust/pull/69801.
Edition of a code fragment is inferred from "the place where the code is written".
For individual tokens like edition-specific keywords it may be the span of the token itself ("uninterpolated" span), but for larger code fragments it's probably not, in the test example the trait method is obviously written in "2015 edition code".
r? @Centril
Exhaustiveness checking, `Matrix::push`: recursively expand or-patterns
> There's an implicit invariant that there should be no or-patterns directly in the first column of the matrix, but this invariant is broken exactly when an or-pattern has a child that is itself an or-pattern.
Here we preserve this broken invariant by recursively expanding `PatKind::Or`s in `Matrix::push`.
Fixes https://github.com/rust-lang/rust/issues/69875.
r? @varkor
cc @Nadrieril
cc https://github.com/rust-lang/rust/issues/54883
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