Commit graph

308340 commits

Author SHA1 Message Date
Samuel Tardieu
5ab16d118a
fix(let_unit_value): create the suggestion "differentially" (#15788)
I.e, instead of constructing a whole new `LetStmt` to replace the old
one, suggest to only change the part of the `LetStmt` that we don't
like. This makes the suggestion less likely to introduce spurious
changes, but also makes the diagnostic much nicer imo.

Fixes rust-lang/rust-clippy#15771 by not adding a semicolon that the
initial `LetStmt` didn't have
Fixes rust-lang/rust-clippy#15784 by using the `init.span` with the
correct `SyntaxContext`

changelog: [`let_unit_value`]: don't add spurious semicolon
changelog: [`let_unit_value`]: don't mangle macro calls
2025-09-29 22:08:35 +00:00
cyrgani
23f3400613 remove unused #![feature(stmt_expr_attributes)] 2025-09-30 00:01:17 +02:00
cyrgani
9bb4081fb0 remove reverse_{encode, decode}! 2025-09-29 23:42:01 +02:00
Alejandra González
98a92bf093
overhaul mut_mut (#15417)
This PR:
- adds structured suggestions to all 3 lint scenarios
- adds more examples of linted patterns, and recommended fixes
- moves some test cases to `_unfixable.rs`, to allow running rustfix on
the main file
- stops the lint from firing multiple times on types like `&mut &mut
&mut T`

Open questions:
- I'd like to add a note explaining why chained `&mut` are useless.. but
can't really come up with something consice. I very much don't like the
one in the docs -- it's a bit too condescending imo.
- see comments in the diff for more

I do realize that the PR ended up being quite wide-scoped, but that's
primarily because once I added structured suggestions to one of the lint
cases, `ui_test` started complaining about warnings remaining after the
rustfix run, which of course had to with the fact that the other two
lint cases didn't actually fix the code they linted, only warned. I
_guess_ `ui_test` could be smarter about this, by understanding that if
a warning was created without a suggestion, then that warning will still
remain in the fixed file. But oh well.

changelog: [`mut_mut`]: add structured suggestions, improve docs

fixes rust-lang/rust-clippy#13021
2025-09-29 21:21:56 +00:00
Ralf Jung
bbe778ec02
Merge pull request #4609 from RalfJung/genmc-targets
genmc: bail out for non-64bit-little-endian targets
2025-09-29 21:20:52 +00:00
Ralf Jung
cfefa9bc88 genmc: bail out for non-64bit-little-endian targets 2025-09-29 22:52:06 +02:00
Ralf Jung
739d858804
Merge pull request #4603 from Patrick-6/miri-genmc-provenance
Implement Pointer conversions to and from GenMC.
2025-09-29 20:45:02 +00:00
Ada Alakbarova
f6dd112a0a
fix: create the suggestion "differentially" 2025-09-29 22:05:24 +02:00
Ada Alakbarova
48ee4705dd
fix: actually use the Applicability 2025-09-29 22:05:24 +02:00
Ada Alakbarova
c3e4d2bb90
clean-up 2025-09-29 22:05:23 +02:00
Matthias Krüger
379979951e
Rollup merge of #147150 - nikic:alloc-shim-attributes, r=bjorn3
Emit allocator attributes for allocator shim

This emits the same attributes we place on allocator declarations on the definitions in the allocator shim as well. This complements https://github.com/rust-lang/rust/pull/146766, which added the attribute for `#[global_allocator]` definitions. Emitting the attributes on the definitions ensures that they cannot be lost of the allocator shim participates in LTO.

See https://github.com/rust-lang/rust/issues/145995 for context, though that one was about `#[global_allocator]`. I'm not sure whether this can occur with the allocator shim as well or not, but better safe than sorry.

I'm not sure whether there is any good way to test this, as the allocator shim is not part of `--emit=llvm-ir`. I've verified this locally by inspecting the bitcode produced by `-C save-temps`.

r? ``@bjorn3``
2025-09-29 21:42:44 +02:00
Matthias Krüger
967e64279a
Rollup merge of #147133 - GuillaumeGomez:rm-loop-extract_cfg_from_attrs, r=lolbinarycat
Remove one loop in `extract_cfg_from_attrs`

Follow-up of https://github.com/rust-lang/rust/pull/138907.

r? lolbinarycat
2025-09-29 21:42:43 +02:00
Matthias Krüger
fdb965f3f7
Rollup merge of #147131 - cjgillot:patch-branches, r=davidtwco
Use MirPatch in simplify_branches.

This allows to avoid clearing the CFG cache if we don't perform any change.

r? ``@ghost`` for perf
2025-09-29 21:42:43 +02:00
Matthias Krüger
618942b86f
Rollup merge of #147040 - joshtriplett:mbe-fix-comments, r=petrochenkov
mbe: macro_check: Fix function comments referencing non-existent parameters

Several functions had comments referencing a non-existent `valid`
parameter. Remove those. The `guar` parameter that handles errors is
already documented.

In the process, remove another duplicate reference to an
already-documented parameter (`binders`).
2025-09-29 21:42:42 +02:00
Matthias Krüger
8223831942
Rollup merge of #146937 - joboet:gethostname, r=Mark-Simulacrum
std: implement `hostname`

Resolves https://github.com/rust-lang/libs-team/issues/330
Tracking issue: https://github.com/rust-lang/rust/issues/135142

This is based on rust-lang/rust#135141, but I've reimplemented the UNIX version, which now:
* uses `sysconf(_SC_HOST_NAME_MAX)` as an initial buffer length
* returns `OutOfMemory` if the `Vec` allocation fails
* retries the operation if it detects that the name returned by `gethostname` was truncated

Additionally, as part of the rebase, I had to move some WinSock abstractions (initialisation and error access) to `sys::pal` so that they can be accessed from `sys::net::hostname`.

CC ``@orowith2os`` (and thank you for your work!)
2025-09-29 21:42:41 +02:00
nora
7e65b095c4
Merge pull request #2598 from rust-lang/tshepang-patch-2
how-to-build-and-run.md: replace "rm build" with "x clean --all"
2025-09-29 21:29:53 +02:00
Jason Newcomb
dfd8b2d3ee
Fix new_without_default FP on private type with trait impl (#15782)
Closes rust-lang/rust-clippy#15778

changelog: [`new_without_default`] fix FP on private type with trait
impl
2025-09-29 18:43:30 +00:00
yanglsh
642feb7e56 fix: if_then_some_else_none FP when return exists in block expr 2025-09-30 02:28:54 +08:00
yanglsh
17cecfd311 fix: new_without_default FP on private type with trait impl 2025-09-30 02:00:06 +08:00
Patrick-6
8b38760176 Implement Pointer conversions to and from GenMC. Limitation: Borrow tracking must be disabled. Remove hacks for keeping all memory allocations in GenMC mode. 2025-09-29 19:12:54 +02:00
Tshepang Mbambo
eaeca96778 how-to-build-and-run.md: update "building compiler" section 2025-09-29 18:58:03 +02:00
Tshepang Mbambo
92e65dc4d4
how-to-build-and-run.md: replace "rm build" with "x clean --all" 2025-09-29 18:39:39 +02:00
Guillaume Gomez
9119eba24d Add regression test for doc cfg applied on public items inside private items 2025-09-29 18:08:51 +02:00
Guillaume Gomez
06a6dcd4d2 Move doc cfg propagation pass before items stripping passes 2025-09-29 18:08:51 +02:00
Marijn Schouten
1a16755ea0 flatten conditional block 2025-09-29 15:55:38 +00:00
Oblarg
f4a865fea7 move test per review feedback 2025-09-29 11:18:49 -04:00
bors
dc2c3564d2 Auto merge of #146376 - durin42:dwo-specify-path, r=davidtwco
debuginfo: add an unstable flag to write split DWARF to an explicit directory

Bazel requires knowledge of outputs from actions at analysis time, including file or directory name. In order to work around the lack of predictable output name for dwo files, we group the dwo files in a subdirectory of --out-dir as a post-processing step before returning control to bazel. Unfortunately some debugging workflows rely on directly opening the dwo file rather than loading the merged dwp file, and our trick of moving the files breaks those users. We can't just hardlink the file or copy it, because with remote build execution we wouldn't end up with the un-moved file copied back to the developer's workstation. As a fix, we add this unstable flag that causes dwo files to be written to a build-system-controllable location, which then lets bazel hoover up the dwo files, but the objects also have the correct path for the dwo files.

r? `@davidtwco`
2025-09-29 15:06:55 +00:00
Boxy Uwu
66b664c996 more rename 2025-09-29 16:06:25 +01:00
bjorn3
adf9cbd69c Add a dummy codegen backend
This allows building a rustc capable of running the frontend without any
backend present. While this may not seem all that useful, it allows
running the frontend of rustc to report errors or running miri to
interpret a program without any backend present. This is useful when you
are trying to say run miri in the browser as upstream LLVM can't be
compiled for wasm yet. Or to run rustc itself in miri like I did a while
ago and caught some UB.
2025-09-29 14:34:58 +00:00
Jules Bertholet
9f667cdd24
Add overlapping_assoc_constraints param to lower_bounds 2025-09-29 10:34:19 -04:00
lcnr
07806a1132 cleanup try_evaluate_added_goals 2025-09-29 15:28:33 +02:00
lcnr
0f2b79c36d add tests 2025-09-29 15:28:33 +02:00
lcnr
098a56890f Fn-trait goals, eagerly instantiate binder
to avoid overflow from proving `for<'a> opaque<'a>: Sized`
2025-09-29 15:28:33 +02:00
Jake Goulding
5df0be3988 Make macOS dist build configuration match where reasonable 2025-09-29 08:52:09 -04:00
Ada Alakbarova
2d2d143a18
fix: respect crate's edition 2025-09-29 14:18:20 +02:00
Ada Alakbarova
26a9a371ee
clean-up: extract should_implement_trait
Also put `SelfKind` into `lib.rs`, since it's shared with
`wrong_self_convention` -- not `utils.rs`, because it's not really a
utility function
2025-09-29 14:18:20 +02:00
Ada Alakbarova
f6e223cdb5
clean-up 2025-09-29 14:17:56 +02:00
bors
21a13b8864 Auto merge of #147151 - Zalathar:rollup-w81rn0j, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#146653 (improve diagnostics for empty attributes)
 - rust-lang/rust#146987 (impl Ord for params and use unstable sort)
 - rust-lang/rust#147101 (Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library )
 - rust-lang/rust#147123 (Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`)
 - rust-lang/rust#147149 (add joboet to library review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-29 11:52:07 +00:00
Guillaume Gomez
2e63708d39 Improve code comments 2025-09-29 13:43:25 +02:00
Stuart Cook
82db672ed5
Rollup merge of #147149 - joboet:rerotating-joboet, r=joboet
add joboet to library review rotation

Reviewing feels like fun again...
2025-09-29 21:06:46 +10:00
Stuart Cook
f2306f3729
Rollup merge of #147123 - DJMcNab:doc_cfg_merge_version, r=fmease
Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`

Tracking issue: https://github.com/rust-lang/rust/issues/43781

The `doc_auto_cfg` and `doc_cfg_hide` features were removed in a recent nightly (by https://github.com/rust-lang/rust/pull/138907).
I believe that the rustc version numbers at which the features were declared to be removed were incorrect, however, and should both be "1.92" (±1). As evidence in favour of this, the error we get from using this was:

```text
error[E0557]: feature has been removed
  --> src/lib.rs:22:29
   |
22 | #![cfg_attr(docsrs, feature(doc_auto_cfg))]
   |                             ^^^^^^^^^^^^ feature has been removed
   |
   = note: removed in 1.58.0; see <https://github.com/rust-lang/rust/pull/138907> for more information
   = note: merged into `doc_cfg`
```

Note especially the "removed in 1.58" claim. Further evidence is found in the comment further up this file: 4ffeda10e1/compiler/rustc_feature/src/removed.rs (L49-L53)

I've chosen 1.92 as that was the milestone which https://github.com/rust-lang/rust/pull/138907 was added to.

cc `@GuillaumeGomez`
2025-09-29 21:06:46 +10:00
Stuart Cook
08616a1745
Rollup merge of #147101 - yotamofek:pr/iter-eq-and-eq-by, r=jdonszelmann
Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library

Now that rust-lang/rust#137122 has landed, we can replace stuff that looks like:
```rust
let a: &[T];
let b: &[T];
let eq = a.len() == b.len() && a.iter().zip(b).all(|(a,b)| a == b)
```
with the much simpler `a.iter().eq(b)`, without losing the perf benefit of the different-length-fast-path.
Also dogfooded `Iterator::eq_by` (cc rust-lang/rust#64295 ) while I'm at it.

First commit (4d1b6fad230f8a5ccceccc7562eadc4ea50059da) should be very straightforward to review, second one (049a4606cb3906787aedf508ee8eea09c2bb3b9a) is slightly more creative, but IMHO a nice cleanup.
2025-09-29 21:06:45 +10:00
Stuart Cook
acd91e2fe1
Rollup merge of #146987 - hkBst:sort-params-1, r=nnethercote
impl Ord for params and use unstable sort

AFAICT we are only sorting to find duplicates, so unstable sort should work fine, and maybe is a tiny bit faster?
2025-09-29 21:06:45 +10:00
Stuart Cook
cf07cce1fb
Rollup merge of #146653 - jdonszelmann:empty-attr-diags, r=nnethercote
improve diagnostics for empty attributes

Adds a note about them not having any effect. This was previously done for `feature` attributes but no other attributes. In [converting the `feature` parser](https://github.com/rust-lang/rust/pull/146652) I removed that note. This PR adds it back in and makes it so all attributes benefit from it.

Not blocked on rust-lang/rust#146652, either can merge first
2025-09-29 21:06:44 +10:00
Nikita Popov
af8fd78142 Emit allocator attributes for allocator shim
This emits the same attributes we place on allocator declarations
(and allocator definitions using `#[global_allocator]`) on the
definitions in the allocator shim as well, making sure that the
attributes are not lost if the allocator shim participates in LTO.
2025-09-29 11:29:59 +02:00
joboet
9c97ba700e
add joboet to library review rotation 2025-09-29 11:20:40 +02:00
Daniel McNab
04ee991589 Fix removed version of doc_auto_cfg, doc_cfg_hide 2025-09-29 09:45:27 +01:00
bors
128b36a4a4 Auto merge of #147145 - Zalathar:rollup-s7kcs3w, r=Zalathar
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#147100 (tests: Remove ignore-android directive for fixed issue)
 - rust-lang/rust#147116 (compiler: remove AbiAlign inside TargetDataLayout)
 - rust-lang/rust#147134 (remove explicit deref of AbiAlign for most methods)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-29 08:43:49 +00:00
Shoyu Vanilla (Flint)
cd26daab4f
Merge pull request #20760 from A4-Tacks/all-any-not-attr-comp
Add `all` `any` and `not` attribute completions
2025-09-29 08:33:17 +00:00
joboet
97333f8c9a
std: implement hostname 2025-09-29 10:24:54 +02:00