Rollup of 10 pull requests
Successful merges:
- #96557 (Allow inline consts to reference generic params)
- #96590 (rustdoc: when running a function-signature search, tweak the tab bar)
- #96650 (Collect function instance used in `global_asm!` sym operand)
- #96733 (turn `append_place_to_string` from recursion into iteration)
- #96748 (Fixes reexports in search)
- #96752 (Put the incompatible_closure_captures lint messages in alphabetical order)
- #96754 (rustdoc: ensure HTML/JS side implementors don't have dups)
- #96772 (Suggest fully qualified path with appropriate params)
- #96776 (Fix two minor issues in hir.rs)
- #96782 (a small `mirror_expr` cleanup)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Fix two minor issues in hir.rs
I found these two places in hir.rs which could use a bit of improvements while going through the code.
No functional change.
Put the incompatible_closure_captures lint messages in alphabetical order
Looks like they were in hash order before, which was causing me trouble in #94598, so this PR sorts the errors by trait name.
Fixes reexports in search
Fixes#96681.
At some point we stopped reexporting items in search so this PR fixes it.
It also adds a regression test.
r? ```@notriddle```
turn `append_place_to_string` from recursion into iteration
This PR fixes the FIXME in the impl of `append_place_to_string` which turns `append_place_to_string` from recursion into iteration, meanwhile simplifying the code relatively.
Collect function instance used in `global_asm!` sym operand
The constants used in SymFn operands have FnDef type,
so the type of the constant identifies the function.
Fixes#96623.
Allow inline consts to reference generic params
Tracking issue: #76001
The RFC says that inline consts cannot reference to generic parameters (for now), same as array length expressions. And expresses that it's desirable for it to reference in-scope generics, when array length expressions gain that feature as well.
However it is possible to implement this for inline consts before doing this for all anon consts, because inline consts are only used as values and they won't be used in the type system. So we can have:
```rust
fn foo<T>() {
let x = [4i32; std::mem::size_of::<T>()]; // NOT ALLOWED (for now)
let x = const { std::mem::size_of::<T>() }; // ALLOWED with this PR!
let x = [4i32; const { std::mem::size_of::<T>() }]; // NOT ALLOWED (for now)
}
```
This would make inline consts super useful for compile-time checks and assertions:
```rust
fn assert_zst<T>() {
const { assert!(std::mem::size_of::<T>() == 0) };
}
```
This would create an error during monomorphization when `assert_zst` is instantiated with non-ZST `T`s. A error during mono might sound scary, but this is exactly what a "desugared" inline const would do:
```rust
fn assert_zst<T>() {
struct F<T>(T);
impl<T> F<T> {
const V: () = assert!(std::mem::size_of::<T>() == 0);
}
let _ = F::<T>::V;
}
```
It should also be noted that the current inline const implementation can already reference the type params via type inference, so this resolver-level restriction is not any useful either:
```rust
fn foo<T>() -> usize {
let (_, size): (PhantomData<T>, usize) = const {
const fn my_size_of<T>() -> (PhantomData<T>, usize) {
(PhantomData, std::mem::size_of::<T>())
}
my_size_of()
};
size
}
```
```@rustbot``` label: F-inline_const
Fixing #95444 by only displaying passes that take more than 5 millise…
As discussed in #95444, I have added the code to test and only display prints that are greater than 5 milliseconds.
r? `@jyn514`