Commit Graph

19780 Commits

Author SHA1 Message Date
León Orell Valerian Liehr
a83f8d02ea Always evaluate free lifetime-generic constants
Co-authored-by: Michael Goulet <michael@errs.io>
2025-05-27 18:58:51 +02:00
Matthew Jasper
f6520673fc Warn on non-crate level text direction lints 2025-05-27 16:16:34 +00:00
Matthew Jasper
65bdb31a97 Report text_direction_codepoint_in_literal when parsing
- The lint is now reported in code that gets removed/modified/duplicated
  by macro expansion.
- Spans are more accurate
- Fixes #140281
2025-05-27 15:57:41 +00:00
Sidney Cammeresi
1ae96fcd79 Update tests with Range parameter to BTreeMap::extract_if etc. 2025-05-27 08:31:56 -07:00
Augie Fackler
a963e6fc38 tests: mark option-niche-eq as fixed on LLVM 21
Some combination of recent Rust changes (between 3d86494a0d and
aa57e46e24 from what I can tell) and changes in LLVM 21 (not recently,
as best I can tell) have caused this test to start showing the behavior
we want, so it's time to move this test to a proper place and mark it as
fixed on LLVM 21.
2025-05-27 11:20:52 -04:00
binarycat
871327e9c7 rustdoc: linking to a local proc macro no longer warns
fixes https://github.com/rust-lang/rust/issues/91274

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-05-27 10:03:05 -05:00
yukang
d5d4cecee9 Suggest mut when possbile for temporary value dropped while borrowed 2025-05-27 22:19:56 +08:00
Mu001999
f83ecd8270 Refactor the two-phase check for impls and impl items 2025-05-27 22:03:21 +08:00
Zalathar
3f526eeec4 coverage: Revert "unused local file IDs" due to empty function names
This reverts commit 3b22c21dd8, reversing
changes made to 5f292eea6d.
2025-05-27 23:33:29 +10:00
Michael Goulet
6344245e4f Rollup merge of #141594 - BoxyUwU:another_gai_test, r=jieyouxu
Add `generic_arg_infer` test

I think most of our existing tests around behaviour of repeat expr inferred counts fail by not having enough inference progress, rather than by having enough inference progress but the element not actually implementing `Copy`.
2025-05-27 13:01:41 +02:00
Michael Goulet
38d18626b1 Rollup merge of #141587 - ferrocene:lw-yurotqzwvwlw, r=jieyouxu
Add missing edition directives for async-await tests

These tests specifically test 2015 edition behavior
2025-05-27 13:01:40 +02:00
Michael Goulet
9d46af12e0 Rollup merge of #141584 - compiler-errors:typing-env-synthetic-body, r=lcnr
Support `opaque_types_defined_by` for `SyntheticCoroutineBody`

We create a synthetic MIR body for the `AsyncFnOnce` impl for async closures. That body goes through all passes that a regular body does, including promotion.

Promotion sometimes requires computing that the type of an rvalue is `Freeze`, which requires computing the typing env of a body. This requires calling `opaque_types_defined_by` on the body's def id, which leads to an ICE today since we don't expect that query to be called for synthetic bodies.

While we could fix this by, for example, computing the typeck root of the body before calling a `TypingEnv` constructor, I think it's appropriate to do a more general fix here since I think it's reasonable that other passes might do analysis too.

Fixes rust-lang/rust#141466

r? ```@lcnr``` or ```@oli-obk```
2025-05-27 13:01:40 +02:00
Michael Goulet
fbac805425 Rollup merge of #141580 - oli-obk:early-dyn-catches-the-incompat, r=compiler-errors
Use more detailed spans in dyn compat errors within bodies

Within bodies we can employ the full dyn compat check query instead of only doing the minimal hir ty lowerer one. This in turn gives us better spans and also silences many follow-up duplicate or bogus errors.

alternative to https://github.com/rust-lang/rust/pull/141439, tho I think I could turn the delayed bug from that one into a bug now instead of having an error code path.

r? `@compiler-errors`
cc `@fmease`
2025-05-27 13:01:38 +02:00
Michael Goulet
b7854c65a9 Rollup merge of #141552 - jieyouxu:cfg-version-tests, r=est31
Pull out dedicated `cfg_version` syntax test from feature gate test

Tracking issue: rust-lang/rust#64796.
Closes rust-lang/rust#141452, as a follow-up to https://github.com/rust-lang/rust/pull/141413#discussion_r2104490809 (point 3 of that is probably too pedantic).

The feature gate test was dual-purposing causing feature gate errors to distract from syntax exercises.

``@rustbot`` label +F-cfg_version
r? ``@est31``
2025-05-27 13:01:36 +02:00
Michael Goulet
a0d77f37f3 Rollup merge of #141536 - Urgau:ambi_wide_ptr-cmp-diag, r=fee1-dead
Improve `ambiguous_wide_pointer_comparisons` lint compare diagnostics

This PR improves the `ambiguous_wide_pointer_comparisons` lint compare diagnostics: `cmp`/`partial_cmp`, but also the operators `<`/`>`/`>=`/`<=`, by:
1. removing the reference to `std::ptr::addr_eq` which only works for equality
2. and adding an `#[expect]` suggestion for keeping the current behavior

Fixes rust-lang/rust#141510
2025-05-27 13:01:36 +02:00
Michael Goulet
77e35944af Rollup merge of #140591 - Kivooeo:new-fix-five, r=davidtwco
Fix malformed suggestion for E0061 when method is a macro token in macro context

fixes #140512

before
```rust
3  -         <Self>::$method(8)
3  +         <Self>::<Self>::$method(8, /* u8 */)
```
now
```rust
3  |         <Self>::$method(8, /* u8 */)
   |                          ++++++++++
```
2025-05-27 13:01:35 +02:00
Fabian Grünbichler
dd148a0696 test: convert version_check ui test to run-make
else it breaks with `rpath=false`.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-05-27 11:12:15 +02:00
Oli Scherer
3fff727e87 Use more detailed spans in dyn compat errors within bodies 2025-05-27 08:18:11 +00:00
Folkert de Vries
c7c0194d98 move asm parsing code into rustc_parse 2025-05-27 09:44:10 +02:00
Folkert de Vries
e3bbbeeafd support #[cfg(...)] on arguments to the asm! macros 2025-05-27 09:44:04 +02:00
Ben Kimock
6d0e04d6f3 Wrap NonZero::new_unchecked call in the print_type_sizes test in a const 2025-05-27 00:35:25 -04:00
bors
d76fe15402 Auto merge of #140790 - quininer:mac-xray, r=wesleywiser,jieyouxu
Enable xray support for Mac

https://github.com/rust-lang/rust/issues/102921

Upstream has supported Mac for a while, let's enable it.

I've tested it on M4 and it generates nop sled correctly.

* https://maskray.me/blog/2023-06-18-port-llvm-xray-to-apple-systems
* https://github.com/llvm/llvm-project/blob/llvmorg-20.1.4/clang/lib/Driver/XRayArgs.cpp#L31

try-job: x86_64-apple-1
try-job: aarch64-apple
2025-05-26 23:44:21 +00:00
MarcoIeni
1b7a927d84 ci: move tests from x86_64-gnu-llvm-19 job to aarch64 2025-05-26 22:27:20 +02:00
Urgau
3fd0265fbb rustdoc: use custom CfgMatchesLintEmitter to make check-cfg work 2025-05-26 21:52:21 +02:00
许杰友 Jieyou Xu (Joe)
bca4279457 Rollup merge of #141550 - Urgau:unused_braces-attrs, r=chenyukang
Fix `unused_braces` lint suggestion when encountering attributes

This PR fixes the `unused_braces` lint suggestion when encountering attributes by not removing them in the suggestion.

Fixes rust-lang/rust#141549
2025-05-27 01:29:22 +08:00
许杰友 Jieyou Xu (Joe)
92b07de1ca Rollup merge of #141439 - compiler-errors:dyn-compatible-coerce, r=oli-obk
Deduplicate dyn compatibility violations due to coercion

Don't unnecessarily emit dyn compatibility violations due to coercion to a non-dyn-compatible target type.

For us to even have that target type, we would have had to write `dyn Trait` somewhere in source, and that would have led to us *already* emitting a dyn compatibility violation when checking that user written type is WF.

r? oli-obk
2025-05-27 01:29:19 +08:00
许杰友 Jieyou Xu (Joe)
9f93c48ddc Rollup merge of #141433 - compiler-errors:unsafe-binder-captures, r=oli-obk
Properly analyze captures from unsafe binders

We need to represent the unsafe binder unwrap as an adjustment in HIR. Pretty straightforward b/c we already represent it as a projection elem in MIR.

Fixes #141418
Fixes #141417

r? oli-obk
2025-05-27 01:29:18 +08:00
许杰友 Jieyou Xu (Joe)
0e710d0883 Rollup merge of #141431 - compiler-errors:open-drop, r=oli-obk
Emit dummy open drop for unsafe binder

Fixes rust-lang/rust#141394

We can't taint the body in wfcheck when we have a `T: Copy` bound failure, so we end up binding MIR here. Emit a dummy open drop so that drop elaboration doesn't fail.

r? oli-obk
2025-05-27 01:29:18 +08:00
Boxy
c27aff35ca Add test 2025-05-26 16:35:36 +01:00
Lukas Wirth
1d35ac9ce0 Add missing edition directives for async-await tests 2025-05-26 14:59:48 +02:00
Michael Goulet
5e31cd30aa Support opaque_types_defined_by for SyntheticCoroutineBody 2025-05-26 12:19:34 +00:00
Jieyou Xu
0ea12c3c5f cfg_version: pull out dedicated syntax test from feature gate test
The feature gate test was dual-purposing causing feature gate errors to
distract from syntax exercises.
2025-05-26 19:58:33 +08:00
Michael Goulet
a59c86ab44 Deduplicate dyn compatibility violations due to coercion 2025-05-26 10:57:54 +00:00
dianqk
457f8ba447 mir-opt: Do not transform non-int type in match_branches 2025-05-26 18:15:54 +08:00
bors
95a2212587 Auto merge of #141567 - jhpratt:rollup-uuhcmci, r=jhpratt
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#134696 (Implement `normalize_lexically`)
 - rust-lang/rust#140539 (Simplify `attribute_groups`)
 - rust-lang/rust#140863 ([rustdoc] Unify type aliases rendering with other ADT)
 - rust-lang/rust#140936 (Clarify WTF-8 safety docs)
 - rust-lang/rust#140952 (Specify that split_ascii_whitespace uses the same definition as is_ascii_whitespace)
 - rust-lang/rust#141472 (Attempt to improve the `std::fs::create_dir_all` docs related to atomicity)
 - rust-lang/rust#141502 (ci: move PR job x86_64-gnu-tools to codebuild)
 - rust-lang/rust#141559 (const-check: stop recommending the use of rustc_allow_const_fn_unstable)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-26 04:30:06 +00:00
Jacob Pratt
5a8cb6f892 Rollup merge of #141559 - RalfJung:less-rustc_allow_const_fn_unstable, r=compiler-errors
const-check: stop recommending the use of rustc_allow_const_fn_unstable

I have seen way too many people see the compiler suggest this attribute and then just apply it without a second thought. This is bad. So let's just stop recommending it; for the rare case where someone needs it, they'll eventually ask us and that way we can be sure that it is truly needed. The dev-guide still also explains `rustc_allow_const_fn_unstable`.

Cc ``@rust-lang/wg-const-eval``
2025-05-26 03:38:19 +02:00
Jacob Pratt
6257d2fb1c Rollup merge of #140863 - GuillaumeGomez:cleanup-tyalias-render, r=lolbinarycat
[rustdoc] Unify type aliases rendering with other ADT

Fixes #140739.

Better reviewed one commit at a time.

Just one thing I'm wondering: should we also render non-`repr` attributes? If so, I wonder if we shouldn't simply change `clean::TypeAlias` to contain the other ADT directly (`Struct`, `Enum` and `Union`) and remove the `TypeAlias::generics` field.

Can be done in a follow-up too.

cc ``@camelid``
r? ``@notriddle``
2025-05-26 03:38:16 +02:00
bors
46264e6dfd Auto merge of #138489 - tmiasko:call-tmps-lifetime, r=workingjubilee
Describe lifetime of call argument temporaries passed indirectly

Fixes #132014.
2025-05-26 01:16:52 +00:00
Ralf Jung
cf9ac0eec1 const-check: stop recommending the use of rustc_allow_const_fn_unstable 2025-05-25 22:47:21 +02:00
quininer
45ed022d63 Add compiler tests for xray 2025-05-26 00:39:23 +08:00
Urgau
4765fd6b76 Fix unused_braces lint suggestion when encountering attributes 2025-05-25 18:17:43 +02:00
Michael Goulet
295a8d56f5 Make UNNECESSARY_TRANSMUTES into a HIR lint 2025-05-25 15:57:48 +00:00
Michael Goulet
5370c5753f Make PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS into a HIR lint 2025-05-25 15:57:48 +00:00
Urgau
77e295c39c Improve ambiguous_wide_pointer_comparisons lint compare diagnostics 2025-05-25 17:08:58 +02:00
Guillaume Gomez
9460f64362 Rollup merge of #141512 - Noratrieb:stop-trimming-this-much, r=compiler-errors
Avoid extra path trimming in method not found error

Method errors have an extra check that force trim paths whenever the normal string is longer than 10 characters, which can be quite unhelpful when multiple items have the same name (for example an `Error`).

A user reported this force trimming as being quite unhelpful when they had a method error where the precise path of the `Error` mattered.

The code uses `tcx.short_string` already to get the normal path, which tries to be clever around trimming paths if necessary, so there is no reason for this extra force trimming.
2025-05-25 15:11:48 +02:00
Guillaume Gomez
b0ae228007 Rollup merge of #141413 - est31:cfg_version_env_var, r=jieyouxu
Make #[cfg(version)] respect RUSTC_OVERRIDE_VERSION_STRING

The `#[cfg(version(...))]` feature is currently under-tested. Part of it is the difficulty that it is hard to write a test that never changes, while the version of the Rust compiler indeed *does* change.

PR #81468 added the first and so far only test of `#[cfg(version(...))]`'s functionality (there is one other test for the *syntax*, that also acts as feature gate). But that test uses a proc macro that parses the version: the text of the test doesn't contain the actual `#[cfg(version(...))]`.

This PR makes `#[cfg(version(...))]` respect `RUSTC_OVERRIDE_VERSION_STRING`, added by PR #124339, allowing us to virtually pin the rustc version and write tests from all directions against some specific version.

The PR also adds a functional test of `#[cfg(version(...))]` that leverages `RUSTC_OVERRIDE_VERSION_STRING`.

Pulled out of #141137.

Tracking issue: #64796
2025-05-25 15:11:47 +02:00
Guillaume Gomez
2b292d1b78 Add regression test for #140739 2025-05-25 15:10:24 +02:00
Guillaume Gomez
4f3dd7b018 Tweak attribute rendering depending on wether or not it is a type alias 2025-05-25 15:10:23 +02:00
Jacob Pratt
3f91bbcd5f Rollup merge of #140950 - clubby789:nonzero-ord-test, r=Mark-Simulacrum
More option optimization tests

I noticed that although adding a manual implementation for PartialOrd on Option in #122024, I didn't add a test so that we can easily check if this behavior has improved.

This also adds a couple of `should-fail` tests - this will allow us to remove these hacky implementations if upstream LLVM improves.
2025-05-25 04:00:55 +02:00
Jacob Pratt
045ac21c6f Rollup merge of #139831 - lolbinarycat:rustdoc-mobile-sidebar, r=GuillaumeGomez
rustdoc: on mobile, make the sidebar full width and linewrap

this is because the mobile sidebar cannot be resized, unlike on desktop.
2025-05-25 04:00:55 +02:00