Commit graph

20804 commits

Author SHA1 Message Date
Josh Stone
faf3e0b589 Further revert Deref for Cow to its 1.90.0 state
ref: https://github.com/rust-lang/rust/issues/147964#issuecomment-3446420995
2025-10-28 08:41:14 -07:00
Theemathas Chirananthavat
6ab240d329 [beta-1.91] Add more context to the temporary lifetime extension FCW
Mention in the FCW that the lifetime extension behavior was wrong since 1.88/1.89.
2025-10-27 21:49:39 +07:00
Pierre Tardy
1e668e089d fix panic when rustc tries to reduce intermediate filenames length with multi byte chars
The issue cannot be reproduced with the former testcase of creating external crates because
rust refuses to use "external crate 28_找出字符串中第一个匹配项的下标"
because it is not a valid indentifier (starts with number, and contain non ascii chars)

But still using 28_找出字符串中第一个匹配项的下标.rs as a filename is accepted by previous rustc releases
So we consider it valid, and add an integration test for it to catch any regression on other code related to non ascii filenames.

(cherry picked from commit c6acffeb78)
2025-10-24 14:58:36 -07:00
Rémy Rakic
1dda76181e add crashes tests for overlapping spans
(cherry picked from commit dd83c57674)
2025-10-24 10:12:51 -07:00
ltdk
21ffe30cd5 Add regression test for inference failures
(cherry picked from commit 4a4f3b0e8e)
2025-10-24 10:12:43 -07:00
dianqk
408e09e77c GVN: Invalidate derefs at loop headers
(cherry picked from commit 2048b9c027)
2025-10-16 14:17:45 -07:00
dianqk
5b36a0a7b2 Add miscompiled test cases
(cherry picked from commit 64c023bad8)
2025-10-16 14:16:46 -07:00
Boxy Uwu
00c06488ad in opaque type handling lift region vars to static if they outlive placeholders
(cherry picked from commit 30bedc74d4)
2025-10-16 14:16:24 -07:00
Ben Kimock
6b4f96d492 Change int-to-ptr transmute lowering back to inttoptr
(cherry picked from commit 029579d177)
2025-10-16 14:12:06 -07:00
bors
df8b2e497d Auto merge of #147056 - dianne:fcw-super-let-init-borrow-shortening, r=jackh726
[beta-1.91] Warn on future errors from temporary lifetimes shortening in Rust 1.92

Pursuant to [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/474880-t-compiler.2Fbackports/topic/.23145838.3A.20beta-nominated/near/540530631), this implements a future-compatibility warning lint `macro_extended_temporary_scopes` for errors in Rust 1.92 caused by rust-lang/rust#145838:

```
warning: temporary lifetime shortening in Rust 1.92
  --> $DIR/macro-extended-temporary-scopes.rs:54:14
   |
LL |             &struct_temp().field
   |              ^^^^^^^^^^^^^ this expression creates a temporary value...
...
LL |         } else {
   |         - ...which will be dropped at the end of this block in Rust 1.92
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
   = note: consider using a `let` binding to create a longer lived value
```

Implementation-wise, this reuses the existing temporary scoping FCW machinery introduced for the `tail_expr_drop_order` edition lint: this adds `BackwardIncompatibleDropHint` statements to the MIR at the end of the shortened scopes for affected temporaries; these are then checked in borrowck to warn if the temporary is used after the future drop hint. There are trade-offs here: on one hand, I believe this gives some assurance over ad-hoc pattern-recognition that there are no false positives[^1]. On the other hand, this fails to lint on future dangling raw pointers and it complicates the potential addition of explanatory diagnostics or suggestions[^2]. I'm hopeful that the limitation around dangling pointers won't be relevant in real code, though; the only real instance we've seen of breakage so far is future errors in formatting macro invocations, which this should be able to catch.

Release logistics notes:
- This PR targets the beta branch directly, since the breakage it's a FCW for is landing in the next Rust version.
- rust-lang/rust#146098 undoes the breakage this is a FCW for. If that behavior is merged and stabilizes in Rust 1.92, this PR should be reverted (or shouldn't be merged) in order to avoid spurious warnings.

cc `@traviscross`

`@rustbot` label +T-lang

[^1]: In particular, more syntactic approaches are complicated by having to avoid warning on promoted constants; they'd either be full of holes, they'd need a lot of extra logic, or they'd need to hack more MIR-to-HIR mapping into `PromoteTemps`.
[^2]: It's definitely possible to add more context and a suggestion, but the ways I've thought of to do so are either too hacky or too complex to feel appropriate for a last-minute direct-to-beta lint.
2025-10-15 01:35:47 +00:00
dianne
164620feda warn on shortening super let binding lifetimes 2025-10-13 22:45:25 -07:00
dianne
9f7ad5ee77 add a test for shortening super let binding lifetimes 2025-10-13 22:45:09 -07:00
dianne
6c2246d9b3 warn on future errors from temporary lifetimes shortening in Rust 1.92 2025-10-13 22:45:09 -07:00
Jonathan Brouwer
555abc18d7 Add regression test for link_section targets
(cherry picked from commit 1589c6c12d)
2025-10-10 09:30:05 -07:00
Jonathan Brouwer
15843ffde1 Fix target list of link_section
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
(cherry picked from commit 4787834eda)
2025-10-10 09:23:48 -07:00
Michael Goulet
91163a9e1e Don't normalize higher-ranked assumptions if they're not used
(cherry picked from commit e3f104608c)
2025-10-10 09:20:53 -07:00
Jonathan Brouwer
0d2b92cd1e Make #[link="dl"] a warning rather than an error
(cherry picked from commit 1c85a1dc2e)
2025-10-07 15:41:15 -07:00
Jonathan Brouwer
d4278373a9 Add failing regression test for #[link="dl"]
(cherry picked from commit 5c95f8bea6)
2025-10-07 15:41:15 -07:00
lcnr
34182f6e7d add test
(cherry picked from commit 7a0adc0878)
2025-10-02 16:20:09 -07:00
lcnr
dad01bc9a8 remove test for no_core
(cherry picked from commit 83532f8544)
2025-10-02 16:20:09 -07:00
dianne
f1fbf1f6ae add positive and negative tests for temporary scope shortening FCW 2025-09-26 01:39:40 -07:00
Nikita Popov
186d91daf7 Revert "Auto merge of #144086 - clubby789:alloc-zeroed, r=nikic"
This reverts commit 040a98af70, reversing
changes made to e8a792daf5.
2025-09-25 16:36:51 +02:00
Jakub Beránek
8499d50da0 Only run Cranelift dist test on nightly 2025-09-15 08:36:53 -04:00
Mark Rousskov
03265b459f Update CURRENT_RUSTC_VERSION post-bump 2025-09-14 14:43:32 -04:00
Jacob Pratt
da1c27df16
Rollup merge of #146521 - folkertdev:document-va-arg-safe, r=workingjubilee
document `core::ffi::VaArgSafe`

tracking issue: https://github.com/rust-lang/rust/issues/44930

A modification of https://github.com/rust-lang/rust/pull/146454, keeping just the documentation changes, but not unsealing the trait.

Although conceptually we'd want to unseal the trait, there are many edge cases to supporting arbitrary types. We'd need to exhaustively test that all targets/calling conventions support all types that rust might generate (or generate proper error messages for unsupported cases). At present, many of the `va_arg` implementations assume that the argument is a scalar, and has an alignment of at most 8. That is totally  sufficient for an MVP (accepting all of the "standard" C types), but clearly does not cover all rust types.

This PR also adds some various other tests for edge cases of c-variadic:

- the `#[inline]` attribute in its various forms. At present, LLVM is unable to inline c-variadic functions, but the attribute should still be accepted. `#[rustc_force_inline]` already rejects c-variadic functions.
- naked functions should accept and work with a C variable argument list. In the future we'd like to allow more ABIs with naked functions (basically, any ABI for which we accept defining foreign c-variadic functions), but for now only  `"C"` and `"C-unwind` are supported
- guaranteed tail calls: c-variadic functions cannot be tail-called. That was already rejected, but there was not test for it.

r? `@workingjubilee`
2025-09-13 18:55:20 -04:00
Jacob Pratt
141cb38f15
Rollup merge of #146171 - scrabsha:push-wovnxxwltsun, r=WaffleLapkin
tidy: check that error messages don't start with a capitalized letter
2025-09-13 18:55:17 -04:00
Folkert de Vries
a107ea18af
c-variadic: check that inline attributes are accepted on c-variadic functions
they don't do anything, because LLVM is unable to inline c-variadic functions (on most targets, anyway)
2025-09-13 21:05:12 +02:00
Folkert de Vries
d28c31a600
c-variadic: check that c-variadic functions cannot be tail-called
as far as I can see this was not tested, though the error message was already implemented
2025-09-13 21:05:12 +02:00
Folkert de Vries
a84bb32e05
c-variadic: test ... with naked functions 2025-09-13 21:05:12 +02:00
bors
637b50be01 Auto merge of #145186 - camsteffen:assoc-impl-kind, r=petrochenkov
Make `AssocItem` aware of its impl kind

The general goal is to have fewer query dependencies by making `AssocItem` aware of its parent impl kind (inherent vs. trait) without having to query the parent def_kind.

See individual commits.
2025-09-13 13:59:48 +00:00
bors
b50f345a2f Auto merge of #146499 - jhpratt:rollup-ufflehe, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#144498 (Add --print target-spec-json-schema)
 - rust-lang/rust#145471 (Stabilize BTree{Map,Set}::extract_if)
 - rust-lang/rust#145896 (Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [rust-lang/rust#3 of Batch rust-lang/rust#2])
 - rust-lang/rust#146450 (bootstrap: rustdoc-js tests can now be filtered by js files)
 - rust-lang/rust#146456 (Fix panic and incorrectly suggested examples in `format_args` macro.)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-13 10:43:09 +00:00
Jacob Pratt
c4539b2d58
Rollup merge of #146456 - IoaNNUwU:issue-146446, r=estebank
Fix panic and incorrectly suggested examples in `format_args` macro.

Follow up on rust-lang/rust#146123
Fixes: rust-lang/rust#146446
r? `@estebank`
2025-09-13 03:26:03 -04:00
Jacob Pratt
82bb6d523b
Rollup merge of #145896 - Oneirical:uncountable-integer-10, r=jieyouxu
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#3 of Batch #2]

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

Inspired by the methodology that `@Kivooeo` was using.

r? `@jieyouxu`
2025-09-13 03:26:02 -04:00
Jacob Pratt
5b37a1e4ae
Rollup merge of #145471 - rs-sac:extr, r=the8472
Stabilize BTree{Map,Set}::extract_if

Tracking issue: rust-lang/rust#70530
FCP completed: https://github.com/rust-lang/rust/issues/70530#issuecomment-3191454465
Closes: rust-lang/rust#70530
2025-09-13 03:26:02 -04:00
Jacob Pratt
544644476d
Rollup merge of #144498 - Noratrieb:rustc-json-schema, r=jieyouxu,davidtwco
Add --print target-spec-json-schema

This schema is helpful for people writing custom target spec JSON. It can provide autocomplete in the editor, and also serves as documentation when there are documentation comments on the structs, as `schemars` will put them in the schema.

I was motivated to do this because I saw someone write their own version of this schema by hand, so demand for this clearly exists. It's not a lot of effort to implement, so I thought it would make sense.

MCP: https://github.com/rust-lang/compiler-team/issues/905

I think it would also be useful to put this in the sysroot in `etc` so people can link it directly in their editors.

I would have loved to add a test that validates the JSON schema against the spec JSON of every builtin target, but I don't want to do it as the JSON schema validation crates have incredible amounts of dependencies because JSON schema supports a ton of random features. I don't want to add that, even as a dev dependency.
2025-09-13 03:26:01 -04:00
bors
064cc81354 Auto merge of #146394 - Enselic:debuginfo-level-tests-2, r=jieyouxu
ci: Increase `rust.debuginfo-level-tests` to `2` in `x86_64-gnu-debug` job

Simply to increase the scope of the testing.

Part of https://github.com/rust-lang/rust/issues/61117.

cc rust-lang/rust#145967 and rust-lang/rust#146025 which prepared for this. And rust-lang/rust#144499 that set to level to `1`

try-job: x86_64-gnu-debug
2025-09-13 07:24:30 +00:00
Jana Dönszelmann
5dd5264d14
Rollup merge of #146403 - cyrgani:array-sugg-sorting, r=fee1-dead
sort array trait implementation suggestions correctly

Fixes rust-lang/rust#135098.
Previously tried in rust-lang/rust#137428.
2025-09-13 02:40:44 +02:00
Jana Dönszelmann
147e97ae68
Rollup merge of #146389 - jdonszelmann:no-std, r=oli-obk
Convert `no_std` and `no_core` to the new attribute infrastructure

r? ```@oli-obk```

Also added a test for these, since we didn't have any and I was kind of surprised new diagnostics didn't break anything hehe
2025-09-13 02:40:44 +02:00
Cameron Steffen
9615ec7d10 Split AssocContainer::{InherentImpl,TraitImpl} 2025-09-12 15:14:15 -05:00
Noratrieb
f157ce994e Add --print target-spec-json-schema
This schema is helpful for people writing custom target spec JSON. It
can provide autocomplete in the editor, and also serves as documentation
when there are documentation comments on the structs, as `schemars` will
put them in the schema.
2025-09-12 20:53:28 +02:00
Oneirical
957fa10d50 Add test batch 3 2025-09-12 14:45:12 -04:00
bors
5c11fb842a Auto merge of #144847 - Randl:const-ord, r=oli-obk
Constify Eq, Ord, PartialOrd

Adds `#[const_trait]` and impls for `Eq`, `Ord`, `PartialOrd`. Impl for some other traits (e.g., slices and arrays) are blocked mainly on const closures (https://github.com/rust-lang/rust/issues/106003).
For TypeId Ord we need const pointer comparison (https://github.com/rust-lang/rust/issues/53020)
Tracking issue https://github.com/rust-lang/rust/issues/143800
2025-09-12 17:34:52 +00:00
bors
a171994070 Auto merge of #146329 - lcnr:opaque-type-infer-alias-candidates, r=BoxyUwU
consider item bounds for non-yet-defined opaque types

Based on rust-lang/rust#140405.

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/182
fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/196
fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/205

there's some jank here, see https://github.com/rust-lang/trait-system-refactor-initiative/issues/229

## Design

If the self type is an inference variable which has been sub-unified with am opaque type, we need to incompletely guide inference to avoid breakage.

In this case, we
- look at the item bounds of all sub-unified opaque types, and
- blanket impls which do not constrain the self type

Even if there are applicable candidates, we always force their certainty to be `Maybe`, so they will always have to be reproven once we've constrained the inference variable.

This is a bit iffy, see the added tests.

r? `@BoxyUwU`
2025-09-12 14:28:42 +00:00
cyrgani
889be7860b sort array trait implementation suggestions correctly 2025-09-12 12:12:06 +02:00
Stuart Cook
be33ef20b1
Rollup merge of #146455 - cuviper:no-rustc-version, r=jieyouxu
test: remove an outdated normalization for rustc versions

These "you are using $RUSTC_VERSION" help messages were removed in
rust-lang/rust#142943, but rust-lang/rust#142681 started before that and
merged later, so its normalization is vestigial.
2025-09-12 20:02:19 +10:00
Stuart Cook
249730f521
Rollup merge of #146448 - GuillaumeGomez:fix-literal-search-paths, r=lolbinarycat
[rustdoc] Correctly handle literal search on paths

Fixes https://github.com/rust-lang/rust/issues/146129.

cc ```@notriddle```
r? ```@lolbinarycat```
2025-09-12 20:02:17 +10:00
Stuart Cook
322f5dc4f4
Rollup merge of #146413 - GuillaumeGomez:rustdoc-bare-urls, r=lolbinarycat
Improve suggestion in case a bare URL is surrounded by brackets

Fixes https://github.com/rust-lang/rust/issues/146162.

With this change, output looks like this:

```
  |
1 | //! [https://github.com]
  |     ^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://github.com>`
  |
  = note: bare URLs are not automatically turned into clickable links
  = note: `#[warn(rustdoc::bare_urls)]` on by default
```

cc ```@fmease```
r? ```@lolbinarycat```
2025-09-12 20:02:14 +10:00
Stuart Cook
40520c6357
Rollup merge of #146308 - cyrgani:concat-integer-literals, r=jackh726
support integer literals in `${concat()}`

Tracking issue: rust-lang/rust#124225

Adds support for using integer literals as arguments to `${concat()}` macro expressions.
Integer formatting such as `1_000` is preserved by this.
2025-09-12 20:02:11 +10:00
Stuart Cook
48d684111e
Rollup merge of #144549 - folkertdev:va-arg-arm, r=saethlin
match clang's `va_arg` assembly on arm targets

tracking issue: https://github.com/rust-lang/rust/issues/44930

For this example

```rust
#![feature(c_variadic)]

#[unsafe(no_mangle)]
unsafe extern "C" fn variadic(a: f64, mut args: ...) -> f64 {
    let b = args.arg::<f64>();
    let c = args.arg::<f64>();

    a + b + c
}
```

We currently generate (via llvm):

```asm
variadic:
    sub     sp, sp, #12
    stmib   sp, {r2, r3}
    vmov    d0, r0, r1
    add     r0, sp, #4
    vldr    d1, [sp, #4]
    add     r0, r0, #15
    bic     r0, r0, #7
    vadd.f64        d0, d0, d1
    add     r1, r0, #8
    str     r1, [sp]
    vldr    d1, [r0]
    vadd.f64        d0, d0, d1
    vmov    r0, r1, d0
    add     sp, sp, #12
    bx      lr
```

LLVM is not doing a good job. In fact, it's well-known that LLVM's implementation of `va_arg` is kind of bad, and we implement it ourselves (based on clang) for many targets already. For arm,  our own `emit_ptr_va_arg` saves 3 instructions.

Next, it turns out it's important for LLVM to explicitly start and end the lifetime of the `va_list`. In https://github.com/rust-lang/rust/pull/146059 I already end the lifetime, but when looking at this again, I noticed that it is important to also start it, see https://godbolt.org/z/EGqvKTTsK: failing to explicitly start the lifetime uses an extra register.

So, the combination of `emit_ptr_va_arg` with starting/ending the lifetime makes rustc emit exactly the instructions that clang generates::

```asm
variadic:
    sub     sp, sp, #12
    stmib   sp, {r2, r3}
    vmov    d16, r0, r1
    vldr    d17, [sp, #4]
    vadd.f64        d16, d16, d17
    vldr    d17, [sp, #12]
    vadd.f64        d16, d16, d17
    vmov    r0, r1, d16
    add     sp, sp, #12
    bx      lr
```

The arguments to `emit_ptr_va_arg` are based on [the clang implementation](03dc2a41f3/clang/lib/CodeGen/Targets/ARM.cpp (L798-L844)).

r? ``@workingjubilee`` (I can re-roll if your queue is too full, but you do seem like the right person here)

try-job: armhf-gnu
2025-09-12 20:02:10 +10:00
Evgenii Zheltonozhskii
ff9b1c1d28 Constify Eq, Ord, PartialOrd 2025-09-12 12:39:31 +03:00