Rollup of 17 pull requests
Successful merges:
- #64325 (Stabilize nested self receivers in 1.41.0)
- #66222 (Use `eq_opaque_type_and_type` when type-checking closure signatures)
- #66305 (Add by-value arrays to `improper_ctypes` lint)
- #66399 (rustc_metadata: simplify the interactions between Lazy and Table.)
- #66534 (Allow global references via ForeignItem and Item for the same symbol name during LLVM codegen)
- #66700 (Fix pointing at arg for fulfillment errors in function calls)
- #66704 (Intra doc enum variant field)
- #66718 (Refactor `parse_enum_item` to use `parse_delim_comma_seq`)
- #66722 (Handle non_exhaustive in borrow checking)
- #66744 (Fix shrink_to panic documentation)
- #66761 (Use LLVMDisposePassManager instead of raw delete in rustllvm)
- #66769 (Add core::{f32,f64}::consts::TAU.)
- #66774 (Clean up error codes)
- #66777 (Put back tidy check on error codes)
- #66797 (Fixes small typo in array docs r? @steveklabnik)
- #66798 (Fix spelling typos)
- #66800 (Combine similar tests for const match)
Failed merges:
r? @ghost
Fixes small typo in array docs r? @steveklabnik
Fixes a small typo in the array documentation.
Also, wasn't sure which [message](https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#pull-requests) to put this in, and will definitely update the commit message if it is supposed to be the PR description but for "safety" - r? @steveklabnik
Put back tidy check on error codes
I just realized that the tidy checks were not run anymore on the error code long explanations. This add it back.
cc @Dylan-DPC
r? @Mark-Simulacrum
Use LLVMDisposePassManager instead of raw delete in rustllvm
LLVM has a dedicated API call which wraps the destructor invocation for the PassManager.
Rust invokes it [otherwhere](d63b24ffcc/src/librustc_codegen_llvm/back/write.rs (L446-L447)), but not in the `LLVMRustWriteOutputFile`.
Since `LLVMDisposePassManager` might be extended to perform additional cleanup actions in the future, this change replaces raw destructor invocation with that API call.
Fix shrink_to panic documentation
While the potential for panicking is already documented for the
`Vec::shrink_to` method, it is not clearly labeled with the usual
`# Panics` heading.
r? @steveklabnik
Refactor `parse_enum_item` to use `parse_delim_comma_seq`
Followup after https://github.com/rust-lang/rust/pull/66641
Some errors got more verbose but I think they make sense with the help message.
Intra doc enum variant field
Part of #43466.
Add intra-doc link support for this:
```rust
enum Foo {
X {
y: u8, // can be found with Foo::X::y
}
}
```
r? @kinnison
Allow global references via ForeignItem and Item for the same symbol name during LLVM codegen
Combining CGUs can result in code that references a static variable through both
an Item and a ForeignItem with the same name. We don't care that the global was
already created by a ForeignItem reference when we see the Item reference, as
long as the LLVM types of the ForeignItem and Item match.
Fixes#66464
rustc_metadata: simplify the interactions between Lazy and Table.
These are small post-#59953 cleanups (including undoing some contrivances from that PR).
r? @michaelwoerister
Add by-value arrays to `improper_ctypes` lint
Hi,
C doesn't have a notion of passing arrays by value, only by reference/pointer.
Rust currently will pass it correctly by reference by it looks very misleading, and can confuse the borrow checker to think a move had occurred.
Fixes#58905 and fixes#24578.
We could also improve the borrow checker here but I think it's kinda a waste of work if we instead just tell the user it's an invalid FFI call.
(My first PR to `rustc` so if I missed some test or formatting guideline please tell me :) )
Use `eq_opaque_type_and_type` when type-checking closure signatures
This handles the case where a user explicitly annotations a closure
signature with a opaque return type.
Fixes#63263
Stabilize nested self receivers in 1.41.0
Previously, only `Self`, `&Self`, `&mut Self`, `Arc<Self>`, `Rc<Self>`,
and `Box<Self>` were available as stable method receivers.
This commit stabilizes nested uses of all the above types.
However, nested receivers remain non-object-safe.
* `Place` is no longer recursive.
* The `cmt` type alias is removed
* `Upvar` places no longer include the dereferences of the environment
closure or of by reference captures.
* All non-dereference projections are combined to a single variant.
* Various unnecessary types and methods have been removed.
rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo.
This PR introduces a MIR "user variable" debuginfo system, which amounts to mapping a variable name, in some `SourceScope`, to a `Place`, so that:
* each name can appear multiple times (e.g. due to macro hygiene), even in the same scope
* each `Place` can appear multiple times (e.g. in the future from optimizations like NRVO, which collapse multiple MIR locals into one)
* the `Place`s aren't limited to just locals, so they can describe the (right now quite ad-hoc) closure upvars and generator saved state fields, and can be properly transformed by optimizations (e.g. inlining - see `src/test/mir-opt/inline-closure-captures.rs`)
The main motivation for this was that #48300 and further optimizations were blocked on being able to describe complex debuginfo transformations (see https://github.com/rust-lang/rust/pull/48300#discussion_r170020762).
<hr/>
In the textual representation, the "user variable" debuginfo can be found in each scope, and consists of `debug NAME => PLACE;` "declarations", e.g. the MIR for `let x = ...; let y = ...; ...` is now:
```rust
let _1: T; // in scope 0 at ...
scope 1 {
debug x => _1; // in scope 1 at ...
let _2: T; // in scope 1 at ...
scope 2 {
debug y => _2; // in scope 2 at ...
}
}
```
For reference, this is how the information was represented before this PR:
(notably, the scopes in which the variables are visible for debuginfo weren't even shown anywhere, making `scope 2` look pointless, and user variable names were part of MIR locals)
```rust
let _1: T; // "x" in scope 0 at ...
scope 1 {
let _2: T; // "y" in scope 1 at ...
scope 2 {
}
}
```
cc @nikomatsakis @michaelwoerister