It's crazy to have the integer methods in something close to random
order.
The reordering makes the gaps clear: `const_i64`, `const_i128`,
`const_isize`, and `const_u16`. I guess they just aren't needed.
In `get_fn` there is a complicated set of if/elses to determine if
`hidden` visibility should be applied. There are five calls to
`LLVMRustSetVisibility` and some repetition in the comments.
This commit streamlines it a bit:
- Computes `hidden` and then uses it to determine if a single call to
`LLVMRustSetVisibility` occurs.
- Converts some of the if/elses into boolean expressions.
- Removes the repetitive comments.
Overall this makes it quite a bit shorter, and I find it easier to read.
Stabilize const `MaybeUninit::as_mut_ptr`
This PR stabilizes the following APIs as const stable as of rust `1.83`:
```rs
impl<T> MaybeUninit<T> {
pub const fn as_mut_ptr(&mut self) -> *mut T;
}
```
This is made possible by const_mut_refs being stabilized (yay).
FCP: #75251 [(comment)](https://github.com/rust-lang/rust/issues/75251#issuecomment-2356197443)
Never patterns constitute a read for unsafety
This code is otherwise unsound if we don't emit an unsafety error here. Noticed when fixing #130528, but it's totally unrelated.
r? `@Nadrieril`
Check params for unsafety in THIR
Self-explanatory. I'm not surprised this was overlooked, given the way that THIR visitors work. Perhaps we should provide a better entrypoint.
Fixes#130528
Further improve diagnostics for expressions in pattern position
Follow-up of #118625, see #121697.
```rs
fn main() {
match 'b' {
y.0.0.1.z().f()? as u32 => {},
}
}
```
Before:
```
error: expected one of `=>`, ``@`,` `if`, or `|`, found `.`
--> src/main.rs:3:10
|
3 | y.0.0.1.z().f()? as u32 => {},
| ^ expected one of `=>`, ``@`,` `if`, or `|`
```
After:
```
error: expected a pattern, found an expression
--> src/main.rs:3:9
|
3 | y.0.0.1.z().f()? as u32 => {},
| ^^^^^^^^^^^^^^^^^^^^^^^ arbitrary expressions are not allowed in patterns
|
help: consider moving the expression to a match arm guard
|
3 | val if val == y.0.0.1.z().f()? as u32 => {},
| ~~~ +++++++++++++++++++++++++++++++++
help: consider extracting the expression into a `const`
|
2 + const VAL: /* Type */ = y.0.0.1.z().f()? as u32;
3 ~ match 'b' {
4 ~ VAL => {},
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
3 | const { y.0.0.1.z().f()? as u32 } => {},
| +++++++ +
```
---
r? fmease
`@rustbot` label +A-diagnostics +A-parser +A-patterns +C-enhancement
Rollup of 9 pull requests
Successful merges:
- #97524 (Add `Thread::{into_raw, from_raw}`)
- #127988 (Do not ICE with incorrect empty suggestion)
- #129422 (Gate `repr(Rust)` correctly on non-ADT items)
- #129934 (Win: Open dir for sync access in remove_dir_all)
- #130450 (Reduce confusion about `make_indirect_byval` by renaming it)
- #130476 (Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut`)
- #130487 (Update the minimum external LLVM to 18)
- #130513 (Clarify docs for std::fs::File::write)
- #130522 ([Clippy] Swap `manual_retain` to use diagnostic items instead of paths)
r? `@ghost`
`@rustbot` modify labels: rollup
Update the minimum external LLVM to 18
With this change, we'll have stable support for LLVM 18 and 19.
For reference, the previous increase to LLVM 17 was #122649.
cc `@rust-lang/wg-llvm`
r? nikic
Reduce confusion about `make_indirect_byval` by renaming it
As part of doing so, remove the incorrect handling of the wasm target's `make_indirect_byval` (i.e. using it at all).
Win: Open dir for sync access in remove_dir_all
A small follow up to #129800.
We should explicitly open directories for synchronous access. We ultimately use `GetFileInformationByHandleEx` to read directories which should paper over any issues caused by using async directory reads (or else return an error) but it's better to do the right thing in the first place. Note though that `delete` does not read or write any data so it's not necessary there.
Gate `repr(Rust)` correctly on non-ADT items
#114201 added `repr(Rust)` but didn't add any attribute validation to it like `repr(C)` has, to only allow it on ADT items.
I consider this code to be nonsense, for example:
```
#[repr(Rust)]
fn foo() {}
```
Reminder that it's different from `extern "Rust"`, which *is* valid on function items. But also this now disallows `repr(Rust)` on modules, impls, traits, etc.
I'll crater it, if it looks bad then I'll add an FCW.
---
https://github.com/rust-lang/rust/labels/relnotes: Compatibility (minor breaking change).
Do not ICE with incorrect empty suggestion
When we have two types with the same name, one without type parameters and the other with type parameters and a derive macro, we were before incorrectly suggesting to remove type parameters from the former, which ICEd because we were suggesting to remove nothing. We now gate against this.
The output is still not perfect. E0107 should explicitly detect this case and provide better context, but for now let's avoid the ICE.
Fix#108748.
The previous name is just an LLVMism, which conveys almost nothing about
what is actually meant by the function relative to the ABI.
In doing so, remove an already-addressed FIXME.
Rollup of 5 pull requests
Successful merges:
- #130457 (Cleanup codegen traits)
- #130471 (Add zlib to musl dist image so rust-lld will support zlib compression for debug info there.)
- #130507 (Improve handling of raw-idents in check-cfg)
- #130509 (llvm-wrapper: adapt for LLVM API changes, second try)
- #130510 (doc: the source of `LetStmt` can also be `AssignDesugar`)
r? `@ghost`
`@rustbot` modify labels: rollup
When we have two types with the same name, one without type parameters and the other with type parameters and a derive macro, we were before incorrectly suggesting to remove type parameters from the former, which ICEd because we were suggesting to remove nothing. We now gate against this.
The output is still not perfect. E0107 should explicitly detect this case and provide better context, but for now let's avoid the ICE.
doc: the source of `LetStmt` can also be `AssignDesugar`
For example, the two following statements are desugared into a block whose `LetStmt` source is `AssignDesugar`:
```rust
_ = ignoring_some_result();
(a, b) = (b, a);
```
llvm-wrapper: adapt for LLVM API changes, second try
This is a re-work of https://github.com/rust-lang/rust/pull/129749 after LLVM brought back the APIs used by rust.
No functional changes intended.
`@rustbot` label: +llvm-main
r? `@nikic`
cc: `@tmandry`