Implement all mix/max functions in a (hopefully) more optimization amendable way
Previously the graph was like this:
```
min -> Ord::min -> min_by -> match on compare() (in these cases compare = Ord::cmp)
^
|
min_by_key
```
now it looks like this:
```
min -> Ord::min -> `<=` <- min_by_key
min_by -> `Ordering::is_le` of `compare()`
```
(`max*` and `minmax*` are the exact same, i.e. they also use `<=` and `is_le`)
I'm not sure how to test this, but it should probably be easier for the backend to optimize.
r? `@scottmcm`
cc https://github.com/rust-lang/rust/issues/115939#issuecomment-2622161134
docs: Documented Send and Sync requirements for Mutex + MutexGuard
This an attempt to continue where #123225 left off.
I did some light clean up from the work done in that PR.
I also documented the `!Send` + `Sync` implementations for `MutexGuard` to the best of my knowledge.
Let me know if I got anything wrong 😄fixes#122856
cc: ``@IoaNNUwU``
r? ``@joboet``
Implement MIR lowering for unsafe binders
This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are `Copy`. Later on, I'll introduce a new trait that relaxes this requirement to being "is `Copy` or `ManuallyDrop<T>`" which more closely models how we treat union fields.
Namely, wrapping unsafe binders is now `Rvalue::WrapUnsafeBinder`, which acts much like an `Rvalue::Aggregate`. Unwrapping unsafe binders are implemented as a MIR projection `ProjectionElem::UnwrapUnsafeBinder`, which acts much like `ProjectionElem::Field`.
Tracking:
- https://github.com/rust-lang/rust/issues/130516
tests: Port `symbol-mangling-hashed` to rmake.rs
Part of #121876.
This PR supersedes #128567 and is co-authored with `@lolbinarycat.`
### Summary
This PR ports `tests/run-make/symbol-mangling-hashed` to rmake.rs. Notable differences when compared to the Makefile version includes:
- It's no longer limited to linux + x86_64 only. In particular, this now is exercised on darwin and windows (esp. msvc) too.
- The test uses `object` crate to be more precise in the filtering, and avoids relying on parsing the human-readable `nm` output for *some* `nm` in the given environment (which isn't really a thing on msvc anyway, and `llvm-nm` doesn't handle msvc dylibs AFAICT).
- Dump the symbols satisfying various criteria on test failure to make it hopefully less of a pain to debug if it ever fails in CI.
### Review advice
- Best reviewed commit-by-commit.
- I'm not *super* sure about the msvc logic, would benefit from a MSVC (PE/COFF) expert taking a look.
---
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: i686-mingw
try-job: x86_64-mingw-1
try-job: x86_64-apple-1
try-job: aarch64-apple
try-job: test-various
Use proper type when applying deref adjustment in const
When applying a deref adjustment to some type `Wrap<T>` which derefs to `T`, we were checking that `T: ~const Deref`, not `Wrap<T>: ~const Deref` like we should have been.
r? project-const-traits
Fixes#136273Fixes#135210 -- I just deleted the test since the regression test is uninteresting
Manually walk into WF obligations in `BestObligation` proof tree visitor
When we encounter a `WellFormed` obligation in the `BestObligation` proof tree visitor, ignore the proof tree and call `wf::unnormalized_obligations` to derive well-formed obligations with the correct cause codes. This is to avoid having to replicate the somewhat delicate logic that `wf.rs` does to set up its obligation causes... Don't see a better way to do this.
vibes?? r? lcnr
Insert null checks for pointer dereferences when debug assertions are enabled
Similar to how the alignment is already checked, this adds a check
for null pointer dereferences in debug mode. It is implemented similarly
to the alignment check as a `MirPass`.
This inserts checks in the same places as the `CheckAlignment` pass and additionally
also inserts checks for `Borrows`, so code like
```rust
let ptr: *const u32 = std::ptr::null();
let val: &u32 = unsafe { &*ptr };
```
will have a check inserted on dereference. This is done because null references
are UB. The alignment check doesn't cover these places, because in `&(*ptr).field`,
the exact requirement is that the final reference must be aligned. This is something to
consider further enhancements of the alignment check.
For now this is implemented as a separate `MirPass`, to make it easy to disable
this check if necessary.
This is related to a 2025H1 project goal for better UB checks in debug
mode: https://github.com/rust-lang/rust-project-goals/pull/177.
r? `@saethlin`
Replace our `LLVMRustDIBuilderRef` with LLVM-C's `LLVMDIBuilderRef`
Inspired by trying to split #134009 into smaller steps that are easier to review individually.
This makes it possible to start incrementally replacing our debuginfo bindings with the ones in the LLVM-C API, all of which operate on `LLVMDIBuilderRef`.
There should be no change to compiler behaviour.
Improve documentation when adding a new target
https://github.com/rust-lang/rust/pull/133631#issuecomment-2607877936 shows that it can be a bit difficult process-wise to add a new target.
I've added a bit of text to the docs, suggesting that users add the target defintion/spec first, and later work on `std` support.
I also found that we have two places where we document how to add a new target. I've linked these for now, but they should probably be merged somehow in the future.
`@rustbot` label A-docs
r? compiler
CC `@workingjubilee` who's worked a lot on target specs IIRC.
Compiler: Finalize dyn compatibility renaming
Update the Reference link to use the new URL fragment from https://github.com/rust-lang/reference/pull/1666 (this change has finally hit stable). Fixes a FIXME.
Follow-up to #130826.
Part of #130852.
~~Blocking it on #133372.~~ (merged)
r? ghost
[rustdoc] Add `--extract-doctests` command-line flag
Part of https://github.com/rust-lang/rust/issues/134529.
It was discussed with the Rust-for-Linux project recently that they needed a way to extract doctests so they can modify them and then run them more easily (look for "a way to extract doctests" [here](https://github.com/Rust-for-Linux/linux/issues/2)).
For now, I output most of `ScrapedDoctest` fields in JSON format with `serde_json`. So it outputs the following information:
* filename
* line
* langstr
* text
cc `@ojeda`
r? `@notriddle`
Similar to how the alignment is already checked, this adds a check
for null pointer dereferences in debug mode. It is implemented similarly
to the alignment check as a MirPass.
This is related to a 2025H1 project goal for better UB checks in debug
mode: https://github.com/rust-lang/rust-project-goals/pull/177.
Rollup of 8 pull requests
Successful merges:
- #135414 (Stabilize `const_black_box`)
- #136150 (ci: use windows 2025 for i686-mingw)
- #136258 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 11))
- #136270 (Remove `NamedVarMap`.)
- #136278 (add constraint graph to polonius MIR dump)
- #136287 (LLVM changed the nocapture attribute to captures(none))
- #136291 (some test suite cleanups)
- #136296 (float::min/max: mention the non-determinism around signed 0)
r? `@ghost`
`@rustbot` modify labels: rollup
Disable `overflow_delimited_expr` in edition 2024
This reverts the style guide changes and sets the default to "false" in rustfmt for style edition 2024.
r? `@ytmimi`
cc `@rust-lang/style` `@rust-lang/rustfmt`
normalize `*.long-type.txt` paths for compare-mode tests
When using a compare mode, the name of the test + compare-mode is embedded in some of rustc's output, like the location where a long type `bla.long-type(-some-hash)?.txt` is written to. That generally makes these tests fail under all compare-modes.
This PR fixes this by normalizing the compare-mode suffix away in the stderr output. We can also see some remnants of the long-removed `nll` compare mode being normalized away ^^.
I did this to fix some failures with `--compare-mode next-solver` (but it also fixes them with e.g. `--compare-mode polonius` of course):
- it makes 9 new tests pass with the new solver
- however, 3 tests I changed here still don't pass with the new solver (IIRC there were 2 ICEs, and some duplicate errors for the 3rd one)
(There was also one that triggered slowness in the new solver while triggering the long type failure, I'll mention this on zulip. )