Commit Graph

300570 Commits

Author SHA1 Message Date
Jubilee Young
0a4f87a144 compiler: rename {ast,hir}::BareFn* to FnPtr*
Fix some comments and related types and locals where it is obvious, e.g.
- bare_fn -> fn_ptr
- LifetimeBinderKind::BareFnType -> LifetimeBinderKind::FnPtrType

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-07-06 15:03:08 -07:00
Samuel Tardieu
d8ba94b0ae Fix manual_is_variant_and condition generation
When comparing `x.map(func) == Some(bool_lit)`, the value of `bool_lit` was
ignored, despite the fact that its value should determine the value of
the proposed expression.

`func` can be either a closure or a path. For the latter, η-expansion
will be used if needed to invert the result of the function call.
2025-07-06 23:36:45 +02:00
Jules Bertholet
196e3ed943 Add more tests for invalid alignments 2025-07-06 16:56:42 -04:00
Jules Bertholet
1c93e16c10 Add FIXME for gen et al 2025-07-06 16:56:42 -04:00
Jules Bertholet
a144fd64bb Add test for dyn alignment 2025-07-06 16:56:42 -04:00
Jules Bertholet
ce8ab082cc Test async fn 2025-07-06 16:56:42 -04:00
Jules Bertholet
a1cefee8d5 Support #[align(…)] on fns in extern blocks 2025-07-06 16:56:41 -04:00
Jules Bertholet
97a7b9b1b4 Remove repr(align) code 2025-07-06 16:56:39 -04:00
Yotam Ofek
09cf02c8af Simplify num formatting helpers 2025-07-06 20:26:04 +00:00
Jonathan Brouwer
244d64e60b Port #[path] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06 22:19:16 +02:00
Jonathan Brouwer
ef3d7741e5 Move check for new attribute to check_builtin_meta_item
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06 22:18:58 +02:00
Jonathan Brouwer
f7046bd32a Regression tests for repr ICEs
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06 22:07:09 +02:00
bors
a84ab0ce6c Auto merge of #143509 - cjgillot:copy-prop-noborrow, r=tmiasko
Do not unify borrowed locals in CopyProp.

Instead of trying yet another scheme to unify borrowed locals in CopyProp, let's just stop trying. We had already enough miscompilations because of this.

I'm convinced it's possible to have both unification of some borrowed locals and soundness, but I don't have a simple and convincing formulation yet.

Fixes https://github.com/rust-lang/rust/issues/143491
2025-07-06 19:58:07 +00:00
Josh Triplett
8ee1e9817c mbe: Change unused_macro_rules to a DenseBitSet
Now that it only contains indexes, and no other information, a bitset
provides a more compact and simpler representation.
2025-07-06 12:02:23 -07:00
ia0
4bdd671358 Update run-make test 2025-07-06 20:17:59 +02:00
Micke
8b65c2f85f Remove duplicate word 2025-07-06 20:06:46 +02:00
Michael Goulet
b63f920ccf More carefully consider span context when suggesting remove &mut 2025-07-06 17:36:35 +00:00
bors
de031bbcb1 Auto merge of #143526 - matthiaskrgr:rollup-pm69g5v, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#143252 (Rewrite empty attribute lint for new attribute parser)
 - rust-lang/rust#143492 (Use `object` crate from crates.io to fix windows build error)
 - rust-lang/rust#143514 (Organize macro tests a bit more)
 - rust-lang/rust#143518 (rustc_builtin_macros: Make sure registered attributes stay sorted)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-06 16:56:16 +00:00
Camille GILLOT
b1fdb4bdc8 Do not optimize stable-mir ui tests. 2025-07-06 16:11:43 +00:00
dvdsk
61cf174dce sleep_until: add clock_nanosleep support to Miri
The clock_nanosleep support is there to allow code using `sleep_until`
to run under Miri. Therefore the implementation is minimal.
- Only the clocks REALTIME and MONOTONIC are supported. The first is supported simply
because it was trivial to add not because it was needed for sleep_until.
- The only supported flag combinations are no flags or TIMER_ABSTIME only.
If an unsupported flag combination or clock is passed in this throws
unsupported.
2025-07-06 17:49:35 +02:00
dvdsk
f24ee2c9b1 sleep_until: use clock_nanosleep where possible
Using clock nanosleep leads to more accurate sleep times on platforms
where it is supported.

To enable using clock_nanosleep this makes `sleep_until` platform
specific. That unfortunatly requires identical placeholder
implementations for the other platforms (windows/mac/wasm etc).

we will land platform specific implementations for those later. See the
`sleep_until` tracking issue.

This requires an accessors for the Instant type. As that accessor is only
used on the platforms that have clock_nanosleep it is marked as allow_unused.

32bit time_t targets do not use clock_nanosleep atm, they instead rely
on the same placeholder as the other platforms. We could make them
use clock_nanosleep too in the future using `__clock_nanosleep_time64`.

__clock_nanosleep_time64 is documented at:
https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html
2025-07-06 17:36:49 +02:00
llogiq
c943f4c0e9 or_fun_call: also lint and method for Option/Result (#15073)
<strike>build on top of rust-lang/rust-clippy#15071</strike>

This also adds ability to lint Option/Result::and method. Yes, this is
not `or` method, but uses the same eager/lazy linting logic. Should i
update lint description to list all checked structs/methods?

changelog: [`or_fun_call`]: lint Option/Result::and
2025-07-06 15:31:13 +00:00
Jakub Beránek
5dc77ba658 Do not ever cross-check bootstrap tools 2025-07-06 17:25:19 +02:00
Jakub Beránek
baa55aef3a Fix CI 2025-07-06 17:25:19 +02:00
Jakub Beránek
18768f0888 Horrible hack to make codegen backends "work" during check 2025-07-06 17:25:19 +02:00
Jakub Beránek
775c970aae Add support for allowing features when checking tools 2025-07-06 17:25:19 +02:00
Jakub Beránek
20719767bc Use stage auto-bump when cross-checking on stage 1 2025-07-06 17:25:19 +02:00
Jakub Beránek
97da04c922 Add #[tracing::instrument] to the LLVM build step 2025-07-06 17:25:19 +02:00
Jakub Beránek
33e6b7aa09 Update library cross-compilation test 2025-07-06 17:25:19 +02:00
Jakub Beránek
8d4d0502bd Update Mode::ToolStd comment 2025-07-06 17:25:19 +02:00
Jakub Beránek
40176388d2 Add staging comment to check::Rustc 2025-07-06 17:25:19 +02:00
Jakub Beránek
38b09dd838 Add change tracker entry 2025-07-06 17:25:18 +02:00
Jakub Beránek
c054c115a5 Unify selection of build compiler for checking in a single function 2025-07-06 17:25:18 +02:00
Jakub Beránek
4a3cfaa745 Implement CoverageDump checking through the tool_check_step macro 2025-07-06 17:25:18 +02:00
Zalathar
b4da3bd872 Fixup check of rust-analyzer, codegen backends, compiletest and other tools 2025-07-06 17:25:12 +02:00
llogiq
cc7b2f57e0 Properly check that an expression might be the one returned (#15115)
The `TyCtxt::hir_get_fn_id_for_return_block()` function was too broad,
as it will return positively even when given part of an expression that
can be used as a return value. A new
`potential_return_of_enclosing_body()` utility function has been made to
represent the fact that an expression might be directly returned from
its enclosing body.

changelog: [`return_and_then`]: prevent false positives in case of a
partially used expression

Fixes rust-lang/rust-clippy#15111
Fixes rust-lang/rust-clippy#14927

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

-
[Beta-nomination](https://github.com/rust-lang/rust-clippy/pull/15115#issuecomment-2996222332)
by [samueltardieu](https://github.com/samueltardieu)

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2025-07-06 15:24:46 +00:00
llogiq
5c51a1d9d3 Handle potentially-shadowing bindings in manual_let_else (#15118)
This commit also adds more test cases, which already worked but were
mentioned in the issue.

Fixes rust-lang/rust-clippy#9939

changelog: [`manual_let_else`]: correctly handle binding subpattern with
unused name
2025-07-06 15:22:46 +00:00
llogiq
412def25d5 fix: Improve floating point lint to handle ambiguous type (#15133)
Fixes: rust-lang/rust-clippy#14897, rust-lang/rust-clippy#10015

This is not a perfect solution, but it fixes the issue. Happy to discuss
further with the clippy team.

This PR refines check_mul_add to avoid false positives on ambiguous
float types (e.g., f32 vs f64). It improves type detection and ensures
mul_add is only suggested when the type is clear.

Changes:
- Improved detection of ambiguous float types
- Refined mul_add suggestion logic
- Added tests for ambiguous cases
## Example

Before this change, expressions like:
```rust
let x = 1.0; // ambiguous type
let _ = x * 2.0 + 0.5; // could incorrectly suggest mul_add
```

----

changelog: [`suboptimal_flops`]: improve handling of ambiguous float
types in mul_add suggestions
2025-07-06 15:18:52 +00:00
llogiq
60d57851ad Don't remove explicit cast to trait object pointer (#15145)
Fixes rust-lang/rust-clippy#15141

----

changelog: [`borrow_as_ptr`]: do not remove cast to trait object pointer
2025-07-06 15:15:35 +00:00
llogiq
cd679d6b84 FIX: NegMultiply should preserve parenthesis when method is called (#15179)
Hi,

I noticed that the lint
[neg_multiply](https://rust-lang.github.io/rust-clippy/master/index.html#neg_multiply)
generates bad code when we call a method on the expression.
Consider `((a.delta - 0.5).abs() * -1.0).total_cmp(&1.0)`. Currently
this would be changed by clippy to `-(a.delta - 0.5).abs()
.total_cmp(&1.0)` - which does not compile because we are trying to
negate an ordering enum - but what we really want is `(-(a.delta -
0.5).abs()).total_cmp(&1.0)`.

This PR fixes this.

changelog: [`neg_multiply`] does not remove parenthesis anymore if a
method is being called on the affected expression

NOTE: This is the first time I am contributing to clippy or the rust
repo in general. So I am not sure whether my approach to fixing this
issue is goo, if there are better solutions or if I missed something.

Thanks & hope you have a good day,
Dario
2025-07-06 15:14:39 +00:00
Jakub Beránek
9906de2510 Make build compiler explicit in check::Rustc and check::Std 2025-07-06 17:12:44 +02:00
Jakub Beránek
50e5599d1d Remove custom_stage override from check::Std and make 1 be the default check stage for it 2025-07-06 17:12:43 +02:00
Jakub Beránek
0aa4ef964d Make default check stage be 1, and error out on checking with stage 0 2025-07-06 17:12:43 +02:00
llogiq
2713c509de fix: redundant_closure_call lint for closures with block (#15144)
Fixes rust-lang/rust-clippy#9583

When a closure with no parameters is called immediately after being
defined, clippy can now suggest replacing the entire expression with
just the closure's body.

----

changelog: [`redundant_closure_call`]: add fixes for closures with block
2025-07-06 15:10:25 +00:00
Ralf Jung
e40f8b26ad rename panic_paylods → unwind_payloads 2025-07-06 16:51:14 +02:00
Joshua Gentry
39575d39c5 Renamed retain_mut to retain on LinkedList as mentioned in the ACP 2025-07-06 10:40:55 -04:00
Ralf Jung
7775166528 interpret: rename StackPopCleanup 2025-07-06 16:07:35 +02:00
Matthias Krüger
bff79a7517 Rollup merge of #143518 - joshtriplett:sort-attrs, r=Kobzol
rustc_builtin_macros: Make sure registered attributes stay sorted

As with the list of builtin macros, use tidy to make sure the list of
builtin attributes stays sorted.
2025-07-06 15:56:14 +02:00
Matthias Krüger
05146ab802 Rollup merge of #143514 - joshtriplett:macro-test-organization, r=jieyouxu
Organize macro tests a bit more

- Move some macro parsing tests from `tests/ui/parser` to `tests/ui/parser/macro`.

- Most macro tests use `macro` in the name, making it easy to find and run tests relevant to macros. However, a few use `mbe` instead. Rename those to say `macro`.
2025-07-06 15:56:13 +02:00
Matthias Krüger
bae6714fe2 Rollup merge of #143492 - Diggsey:db-fix-object-ambiguity, r=RalfJung
Use `object` crate from crates.io to fix windows build error

See https://rust-lang.zulipchat.com/#narrow/channel/386786-rustc-codegen-gcc/topic/Cannot.20compile.20rustc.20on.20Windows.2010/with/527240094
2025-07-06 15:56:13 +02:00