More documentation and simplification of BTreeMap's internals
Salvage the documentation and simplification from #67980, without changing the type locked down by debuginfo.
r? @rkruppe
Miri visitor: detect primitive types based on type, not layout (also, more tests)
I also converted the union-based transmutes to use `mem::transmute` for increased readability.
r? @eddyb @oli-obk
Rollup of 8 pull requests
Successful merges:
- #69422 (Remove use of `unwrap()` from save-analysis)
- #69548 (Turn trailing tokens in `assert!()` into hard errors)
- #69561 (Clean up unstable book)
- #69599 (check_binding_alt_eq_ty: improve precision wrt. `if let`)
- #69641 (Update books)
- #69776 (Fix & test leak of some BTreeMap nodes on panic during `into_iter`)
- #69805 (resolve: Modernize some naming)
- #69810 (test(bindings_after_at): add dynamic drop tests for bindings_after_at)
Failed merges:
r? @ghost
check_binding_alt_eq_ty: improve precision wrt. `if let`
Follow up to https://github.com/rust-lang/rust/pull/69452 -- this tweaks the `check_binding_alt_eq_ty` logic wrt. wording so that `if let` doesn't include "in this arm" (because there can only ever be one arm).
r? @estebank
Clean up unstable book
- #58402's feature was renamed to `tidy_test_never_used_anywhere_else` and it is now used for tidy only
- `read_initializer` link is wrong and the doc should be auto-generated so removed
- Add dummy doc for `link_cfg`
- Stop generating `compiler_builtins_lib` doc in favor of b8ccc0f8a6
- Make `rustc_attrs` tracking issue "None"
Turn trailing tokens in `assert!()` into hard errors
I didn't have time to build the compiler and thus edited the tests manually, I hope it will still pass.
Closes#69531
r? @Centril do you want to queue the Crater experiment?
Rollup of 8 pull requests
Successful merges:
- #69667 (Remove the `no_debug` feature)
- #69687 (resolve, inconsistent binding mode: tweak wording)
- #69708 (On mismatched delimiters, only point at empty blocks that are in the same line)
- #69765 (reduce test size for Miri)
- #69773 (fix various typos)
- #69787 (mir::Local is Copy we can pass it by value in these cases)
- #69794 (Add `Layout::dangling()` to return a well-aligned `NonNull<u8>`)
- #69797 (Correct version that relaxed orphan rules)
Failed merges:
r? @ghost
Add `Layout::dangling()` to return a well-aligned `NonNull<u8>`
Adds a convenient function to `Layout` to create a `NonNull<u8>` out of a layout to be returned on ZST allocations.
This is the first item on the roadmap to support ZSTs in `AllocRef`: https://github.com/rust-lang/wg-allocators/issues/38#issuecomment-595861542
r? @Amanieu
On mismatched delimiters, only point at empty blocks that are in the same line
We point at empty blocks when we have mismatched braces to detect cases where editors auto insert `}` after writing `{`. Gate this to only the case where the entire span is in the same line so we never point at explicitly empty blocks.
resolve, inconsistent binding mode: tweak wording
Now that we can have e.g. `let Ok(x) | Err(x) = res;`, it's no longer appropriate to refer to "the same *match arm*", so let's tweak the wording.
r? @estebank
Pass correct place to `discriminant_switch_effect`
PR #69562, which fixed a bug that was causing clippy to ICE, mistakenly passed the place holding the *result* of `Rvalue::Discriminant` instead of the place holding its *operand* to `apply_discriminant_switch_effect` as the enum place. As a result, no effect was applied at all, and we lost the perf benefits from marking inactive enum variants as uninitialized.
**edit:** The regression test has been split into #69744.
r? @oli-obk
Rollup of 9 pull requests
Successful merges:
- #67741 (When encountering an Item in a pat context, point at the item def)
- #68985 (Parse & reject postfix operators after casts)
- #69656 (Use .next() instead of .nth(0) on iterators.)
- #69680 (rustc_expand: Factor out `Annotatable::into_tokens` to a separate method)
- #69690 (test(pattern): add tests for combinations of pattern features)
- #69706 (Use subslice patterns in slice methods)
- #69727 (Avoid using `unwrap()` in suggestions)
- #69754 (Update deprecation version to 1.42 for Error::description)
- #69782 (Don't redundantly repeat field names (clippy::redundant_field_names))
Failed merges:
r? @ghost
Update deprecation version to 1.42 for Error::description
Error::description is deprecated as of version 1.42, as the commit was
not in the release for 1.41.
Fixes#69751
Use subslice patterns in slice methods
For all of the methods that pick off the first or last element, we can
use subslice patterns to implement them directly, rather than relying on
deeper indexing function calls. At a minimum, this means the generated
code will rely less on inlining for performance, but in some cases it
also optimizes better.
test(pattern): add tests for combinations of pattern features
Reference issue #67311
Tests combinations of the following pattern features:
- bindings_after_at
- or_patterns
- slice_patterns
- box_patterns
r? @Centril
Parse & reject postfix operators after casts
This adds an explicit error messages for when parsing `x as Type[0]` or similar expressions. Our add an extra parse case for parsing any postfix operator (dot, indexing, method calls, await) that triggers directly after parsing `as` expressions.
My friend and I worked on this together, but they're still deciding on a github username and thus I'm submitting this for both of us.
It will immediately error out, but will also provide the rest of the parser with a useful parse tree to deal with.
There's one decision we made in how this produces the parse tree. In the situation `&x as T[0]`, one could imagine this parsing as either `&((x as T)[0])` or `((&x) as T)[0]`. We chose the latter for ease of implementation, and as it seemed the most intuitive.
Feedback welcome! This is our first change to the parser section, and it might be completely horrible.
Fixes#35813.
When encountering an Item in a pat context, point at the item def
```
error[E0308]: mismatched types
--> $DIR/const-in-struct-pat.rs:8:17
|
LL | struct foo;
| ----------- `foo` defined here
...
LL | let Thing { foo } = t;
| ^^^ expected struct `std::string::String`, found struct `foo`
|
= note: `foo` is interpreted as a unit struct, not a new binding
help: you can bind the struct field to a different name
|
LL | let Thing { foo: other_foo } = t;
| ^^^^^^^^^^^^^^
```
```
error[E0308]: mismatched types
--> $DIR/const.rs:14:9
|
LL | const FOO: Foo = Foo{bar: 5};
| ----------------------------- constant defined here
...
LL | FOO => {},
| ^^^
| |
| expected `&Foo`, found struct `Foo`
| `FOO` is interpreted as a constant, not a new binding
| help: use different name to introduce a new binding: `other_foo`
```
Fix#55631, fix#48062, cc #42876.