Commit graph

22459 commits

Author SHA1 Message Date
Jonathan Brouwer
093d175edd
Rollup merge of #150044 - workingjubilee:avoid-suggesting-irrelevant-rename, r=jieyouxu
Avoid unhelpful suggestion when crate name is invalid

Pointing out they can set the crate's name is non-actionable: their problem is they found out how and set it incorrectly. Remove extraneous information that can only confuse the matter.
2025-12-17 12:49:21 +01:00
Jubilee Young
25cc98f116 Avoid unhelpful suggestion when crate name is invalid
Pointing out they can set the crate's name is non-actionable:
their problem is they found out how and set it incorrectly.
Remove extraneous information that can only confuse the matter.
2025-12-16 20:43:26 -08:00
Jacob Pratt
656d4e8a96
Rollup merge of #150072 - Bryntet:parse_no_link, r=JonathanBrouwer
Port #[no_link] to use attribute parser

Adds `#[no_link]` to the attribute parser, as well as adds tests making sure to FCW warn on `field`, `arm`, and `macrodef `
2025-12-16 23:10:12 -05:00
Jacob Pratt
66155a7df6
Rollup merge of #150000 - Bryntet:brynte/parse_legacy_const_generic_args, r=jonathanbrouwer,jdonszelmann
Port `#[rustc_legacy_const_generics]` to use attribute parser

Small PR that ports the `#[rustc_legacy_const_generics]` to use the new attribute parser!

r? JonathanBrouwer
2025-12-16 23:10:10 -05:00
Edvin Bryntesson
b09a9d0062
add tests making sure to FCW warn on field, arm, and macro def 2025-12-16 22:45:56 +01:00
Edvin Bryntesson
52bcaabdb8
Port #[no_link] to use attribute parser 2025-12-16 22:45:32 +01:00
bors
2dc30247c5 Auto merge of #150068 - JonathanBrouwer:rollup-45j7puz, r=JonathanBrouwer
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#147939 (Make `const BorrowMut` require `const Borrow` and make `const Fn` require `const FnMut`)
 - rust-lang/rust#149734 (Mirror GCC 9.5.0)
 - rust-lang/rust#149767 (Tidying up tests/ui/issues 33 tests [4/N])
 - rust-lang/rust#149804 (chore: fix some minor issues in the comments)
 - rust-lang/rust#149967 (custom `VaList` layout for Hexagon)
 - rust-lang/rust#150025 (dont create unnecessary `DefId`s under mgca)
 - rust-lang/rust#150032 (Use annotate-snippet as default emitter on stable)
 - rust-lang/rust#150033 (Add try_as_dyn and try_as_dyn_mut)
 - rust-lang/rust#150042 (rustc-dev-guide subtree update)
 - rust-lang/rust#150063 (Remove deny of manual-let-else)
 - rust-lang/rust#150064 (std: io: error: Add comment for UEFI unpacked repr use)

Failed merges:

 - rust-lang/rust#150044 (Avoid unhelpful suggestion when crate name is invalid)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-16 19:46:35 +00:00
Edvin Bryntesson
4bd0e65bde
Port #[rustc_legacy_const_generics] to use attribute parser 2025-12-16 20:29:01 +01:00
Jonathan Brouwer
25b73c4943
Rollup merge of #150033 - izagawd:try_as_dyn, r=oli-obk
Add try_as_dyn and try_as_dyn_mut

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

Continuation of: https://github.com/rust-lang/rust/pull/144363
2025-12-16 20:21:10 +01:00
Jonathan Brouwer
f3fa567fdf
Rollup merge of #150032 - Kivooeo:annotate-snippets-stable, r=Muscraft
Use annotate-snippet as default emitter on stable

This is implementation of https://github.com/rust-lang/rust/issues/149932

Now, after MCP was accepted, we can use annotate-snippet as default emitter for errors, that means that we not longer need of previous emitter, so this PR removed previous emitter and makes annotate-snippet new default one both on stable and nightly

(this PR does not remove a code of previous emitter it just removes a `Default` option of `HumanReadableErrorType` enum, and keeping only `HumanReadableErrorType::AnnotateSnippet` as it now uses by default)
2025-12-16 20:21:10 +01:00
Jonathan Brouwer
9308518af9
Rollup merge of #150025 - BoxyUwU:mgca_no_unused_defids, r=oli-obk
dont create unnecessary `DefId`s under mgca

Fixes rust-lang/rust#149977
Fixes rust-lang/rust#148838

Accidentally left this out of rust-lang/rust#149136 even though being able to do this was a large part of the point of the PR :3

First ICE was caused by the fact that we create a defid but never lower the nodeid associated with it to a hirid which later parts of the compiler can't handle.

See test for second ICE

r? oli-obk
2025-12-16 20:21:09 +01:00
Jonathan Brouwer
297cdc8137
Rollup merge of #149804 - xiaolinny:main, r=lcnr
chore: fix some minor issues in the comments

fix some minor issues in the comments
2025-12-16 20:21:08 +01:00
Jonathan Brouwer
f108cd7232
Rollup merge of #149767 - reddevilmidzy:t11, r=Kivooeo
Tidying up tests/ui/issues 33 tests [4/N]

> [!NOTE]
> Intermediate commits are intended to help review, but will be squashed add comment commit prior to merge.

part of rust-lang/rust#133895

`tests/ui/compile-flags` split it into `tests/ui/compile-flags/invalid/` and `tests/ui/compile-flags/run-pass/`

r? Kivooeo
2025-12-16 20:21:07 +01:00
Jonathan Brouwer
d93b93bcb0
Rollup merge of #147939 - theemathas:add-const-supertrait, r=oli-obk
Make `const BorrowMut` require `const Borrow` and make `const Fn` require `const FnMut`

This makes it consistent with other const traits in the standard library with supertraits.

I am currently unsure if `const FnMut` should require `const FnOnce` or not. See [zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/.5Bconst.5D.20implied.20bounds.20for.20implicit.20trait.20bounds/near/546152748).
2025-12-16 20:21:05 +01:00
bors
31010ca61c Auto merge of #149442 - chenyukang:yukang-fix-mark-span-note-144304, r=estebank
Fix span note for question mark expression

Fixes rust-lang/rust#144304

Seems it's better to fix the note instead of modifying the span to cover the whole expression.

r? `@estebank`
2025-12-16 16:06:43 +00:00
Kivooeo
84f2854bc3 remove fixme & update stderr files 2025-12-16 13:23:48 +00:00
Kivooeo
a47c8b292e remove human-annotate-rs 2025-12-16 13:23:45 +00:00
bors
95a27adcf9 Auto merge of #143924 - davidtwco:sve-infrastructure, r=workingjubilee
`rustc_scalable_vector(N)`

Supercedes rust-lang/rust#118917.

Initial experimental implementation of rust-lang/rfcs#3838. Introduces a `rustc_scalable_vector(N)` attribute that can be applied to types with a single `[$ty]` field (for `u{16,32,64}`, `i{16,32,64}`, `f{32,64}`, `bool`). `rustc_scalable_vector` types are lowered to scalable vectors in the codegen backend.

As with any unstable feature, there will necessarily be follow-ups as we experiment and find cases that we've not considered or still need some logic to handle, but this aims to be a decent baseline to start from.

See rust-lang/rust#145052 for request for a lang experiment.
2025-12-16 12:53:53 +00:00
David Wood
5f27abdbc8
mono: require target feature for scalable vectors
Scalable vector types only work with the relevant target features
enabled, so require this for any function with the types in its
signature.
2025-12-16 11:01:26 +00:00
David Wood
4185e9f2ec
mir_transform: prohibit scalable vectors in async
Scalable vectors cannot be members of ADTs and thus cannot be kept over
await points in async functions.
2025-12-16 11:00:12 +00:00
David Wood
a56b1b9283
codegen: implement repr(scalable)
Introduces `BackendRepr::ScalableVector` corresponding to scalable
vector types annotated with `repr(scalable)` which lowers to a scalable
vector type in LLVM.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
2025-12-16 11:00:12 +00:00
David Wood
ba9262936e
hir/trait_sel: prohibit scalable vectors in types
Extend well-formedness checking and HIR analysis to prohibit the use of
scalable vectors in structs, enums, unions, tuples and arrays. LLVM does
not support scalable vectors being members of other types, so these
restrictions are necessary.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
2025-12-16 11:00:12 +00:00
David Wood
78b06057ef
attr: parse rustc_scalable_vector(N)
Extend parsing of `ReprOptions` with `rustc_scalable_vector(N)` which
optionally accepts a single literal integral value - the base multiple of
lanes that are in a scalable vector. Can only be applied to structs.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
2025-12-16 11:00:11 +00:00
Ivar Flakstad
d5bf1a4c9a Introduce vtable_for intrinsic and use it to implement try_as_dyn and try_as_dyn_mut for fallible coercion from &T / &mut T to &dyn Trait. 2025-12-16 06:39:58 -04:00
bors
61cc47e367 Auto merge of #149948 - WaffleLapkin:dereferenceablen't, r=RalfJung
Stop applying `dereferenceable(n)` to return types

It looks like the semantics of `dereferenceable(n)` on return types is "dereferenceable until the end of the program", which is not sound for how we were using it. See [dereferenceable on return type](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/LLVM.20dereferenceable.20on.20return.20type/with/563001493) zulip thread.

cc `@rust-lang/opsem` `@nikic`
2025-12-16 09:38:19 +00:00
Stuart Cook
0ea7d0b956
Rollup merge of #148790 - kevaundray:kw/rv64im-unknown-elf, r=davidtwco,JonathanBrouwer
Add new Tier-3 target: riscv64im-unknown-none-elf

This PR proposes to add riscv64im-unknown-none-elf, a subset of the already supported riscv64imac-unknown-none-elf.

The motivation behind this PR is that we want to standardize (most) zkVMs on riscv64im-none and riscv64ima-none. Having different variants of riscv extensions, also seems to be within expectation, atleast with respects to riscv32.

Note: This does not mean that we will be able to remove [riscv32im-risc0-zkvm-elf](https://doc.rust-lang.org/rustc/platform-support/riscv32im-risc0-zkvm-elf.html) -- I am not aware of all of the dependents for this

**Tier-3 Policy**

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I assigned  Rust Embedded Working Group, since they are already maintaining riscv64IMAC, though I am happy to assign myself.

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

It follows the naming convention of the other bare metal riscv targets

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

This has the same requirements as riscv{32, 64}imac

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via ````@)```` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

> Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. (Having support in a fork of the backend is not sufficient, it must be upstream.)

Acknowledging the above.
2025-12-16 14:40:41 +11:00
Stuart Cook
bd1e142ac0
Rollup merge of #148756 - JonathanBrouwer:link_section_targets2, r=jdonszelmann
Warn on codegen attributes on required trait methods

This PR turns applying the following attributes on required trait methods (that is, trait methods **without** a default implementation) into a FCW:
- `#[cold]`
- `#[link_section]`
- `#[linkage]` (unstable)
- `#[rustc_allow_const_fn_unstable]` (internal attribute)

These attributes already had no effect when applied to a required trait method, this PR only adds a warning.

Furthermore, it adds a comment in the code that the following codegen attributes are *inherited* when applied to a required trait method:
- `#[track_caller]`
- `#[align]` (unstable)

````@rustbot```` labels +I-lang-nominated
````@rust-lang/lang````

Two questions for the lang team:
- Is adding this warning ok?
- Does the current behaviour of these attributes align with that you would expect them to be?

Fixes https://github.com/rust-lang/rust/issues/147432
2025-12-16 14:40:40 +11:00
Boxy Uwu
dbfc8c218e dont create unnecessary DefIds under mgca 2025-12-15 22:59:15 +00:00
reddevilmidzy
1bd997a452 Cleaned up some tests
Split invalid-compile-flags into run-pass & invalid

Update tests/ui/README.md
2025-12-16 02:10:08 +09:00
Kevaundray Wedderburn
1fe0a85df7 Add rv64IM 2025-12-15 12:17:55 +00:00
Matthias Krüger
3e412faa66
Rollup merge of #149994 - Flakebi:amdgpu-vectors, r=jieyouxu
Allow vector types for amdgpu

The amdgpu target uses vector types in various places. The vector types can be used on all architectures, there is no associated target feature that needs to be enabled.

The largest vector type found in LLVM intrinsics is `v32i32` (`[32 x i32]`) for mfma intrinsics. Note that while this intrinsic is only supported on some architectures, the vector type itself is supported on all architectures.

Tracking issue: rust-lang/rust#135024

(I used an empty string to say “does not need a target feature”. If you prefer an `Option` or something like that, I’ll change it.)
2025-12-15 08:08:04 +01:00
Matthias Krüger
98f87362d9
Rollup merge of #149969 - jyn514:ibt, r=jieyouxu
don't use no_main and no_core to test IBT

The previous test was quite fragile and depended on a bunch of internal features. Simplify it.

Split out of https://github.com/rust-lang/rust/pull/149937.

cc ```@jieyouxu``` ```@Oneirical```
2025-12-14 20:04:57 +01:00
Matthias Krüger
185f7dc044
Rollup merge of #149949 - JonathanBrouwer:error_cleanup, r=jdonszelmann
Cleanup of attribute parsing errors

Removes the specific `UnknownMetaItem` and `IllFormedAttributeInputLint` errors.
Note that `IllFormedAttributeInputLint` is not a lint, contrary to its name

r? ``````@jdonszelmann``````
2025-12-14 20:04:56 +01:00
Matthias Krüger
d7a18fc052
Rollup merge of #148490 - hkBst:dangling-ptr-lint-2, r=Urgau
dangling pointer from temp cleanup

Continuation of https://github.com/rust-lang/rust/pull/148348
r? `@Urgau`
2025-12-14 20:04:54 +01:00
Flakebi
a9b147259b
Allow vector types for amdgpu
The amdgpu target uses vector types in various places. The vector types
can be used on all architectures, there is no associated target feature
that needs to be enabled.

The largest vector type found in LLVM intrinsics is `v32i32`
(`[32 x i32]`) for mfma intrinsics. Note that while this intrinsic is
only supported on some architectures, the vector type itself is
supported on all architectures.
2025-12-14 17:03:51 +01:00
jyn
309e9ec576 don't use no_main and no_core to test IBT
also assert that the property is IBT and not some random other property.
2025-12-14 09:18:31 -05:00
bors
0208ee09be Auto merge of #149979 - ChrisDenton:rollup-9rvyn3h, r=ChrisDenton
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#148755 (Constify `DropGuard::dismiss` and trait impls)
 - rust-lang/rust#148825 (Add SystemTime::{MIN, MAX})
 - rust-lang/rust#149272 (Fix vec iter zst alignment)
 - rust-lang/rust#149417 (tidy: Detect outdated workspaces in workspace list)
 - rust-lang/rust#149773 (fix va_list test by adding a llvmir signext check)
 - rust-lang/rust#149894 (Update to mdbook 0.5)
 - rust-lang/rust#149955 (Fix typo in armv7a-vex-v5 documentation)
 - rust-lang/rust#149972 (Enable to ping LoongArch group via triagebot)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-14 12:32:36 +00:00
Marijn Schouten
cab911449a dangling pointer from temp cleanup 2025-12-14 11:39:43 +00:00
Chris Denton
2f06db1cbe
Rollup merge of #149773 - fneddy:fix_test_va_list_signext, r=Mark-Simulacrum
fix va_list test by adding a llvmir signext check

s390x has no option to directly pass 32bit values therefor i32 parameters need an optional llvmir signext attribute.
2025-12-14 09:18:29 +00:00
bors
08de25c4ea Auto merge of #149273 - bjorn3:crate_locator_improvements, r=petrochenkov
Don't leak sysroot crates through dependencies

Previously if a dependency of the current crate depended on a sysroot crate, then `extern crate` would in the current crate would pick the first loaded version of said sysroot crate even in case of an ambiguity. This is surprising and brittle. For `-Ldependency=` we already blocked this since rust-lang/rust#110229, but the fix didn't account for sysroot crates.

Should fix https://github.com/rust-lang/rust/issues/147966
2025-12-14 09:16:11 +00:00
bors
3f4dc1e02d Auto merge of #146348 - jdonszelmann:eiiv3, r=lcnr,oli-obk
Externally implementable items

Supersedes https://github.com/rust-lang/rust/pull/140010
Tracking issue: https://github.com/rust-lang/rust/issues/125418

Getting started:

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

#[eii(eii1)]
pub fn decl1(x: u64)
// body optional (it's the default)
{
    println!("default {x}");
}

// in another crate, maybe
#[eii1]
pub fn decl2(x: u64) {
    println!("explicit {x}");
}

fn main() {
    decl1(4);
}
```

- tiny perf regression, underlying issue makes multiple things in the compiler slow, not just EII, planning to solve those separately.
- No codegen_gcc support, they don't have bindings for weak symbols yet but could
- No windows support yet for weak definitions

This PR merges the implementation of EII for just llvm + not windows, doesn't yet contain like a new panic handler implementation or alloc handler. With this implementation, it would support implementing the panic handler in terms of EII already since it requires no default implementation so no weak symbols

The PR has been open in various forms for about a year now, but I feel that having some implementation merged to build upon
2025-12-14 04:20:26 +00:00
Jana Dönszelmann
065e4c1c8a
ignore windows 2025-12-13 22:49:45 +01:00
bors
2cd4ee6bcf Auto merge of #149192 - gmorenz:normalize_lifetimes, r=madsmtm
NFC normalize lifetime identifiers

Fixes rust-lang/rust#126759
2025-12-13 21:47:35 +00:00
Jonathan Brouwer
8fa10c0ed7
Add regression test for codegen attributes on required trait methods
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-12-13 20:19:20 +01:00
Jonathan Brouwer
ddcd55fa66
Don't allow codegen attributes on trait methods
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-12-13 20:14:14 +01:00
Jonathan Brouwer
ae39d3d9ab
Improve spans of malformed attribute errors 2025-12-13 17:13:36 +01:00
bors
8188f6c808 Auto merge of #149709 - Urgau:overhaul-filenames, r=davidtwco
Overhaul filename handling for cross-compiler consistency

This PR overhauls the way we handle filenames in the compiler and `rmeta` in order to achieve achieve cross-compiler consistency (ie. having the same path no matter if the filename was created in the current compiler session or is coming from `rmeta`).

This is required as some parts of the compiler rely on consistent paths for the soundness of generated code (see rust-lang/rust#148328).

In order to achieved consistency multiple steps are being taken by this PR:
 - by making `RealFileName` immutable
 - by only having `SourceMap::to_real_filename` create `RealFileName`
   - currently `RealFileName` can be created from any `Path` and are remapped afterwards, which creates consistency issue
 - by also making `RealFileName` holds it's working directory, embeddable name and the remapped scopes
   - this removes the need for a `Session`, to know the current(!) scopes and cwd, which is invalid as they may not be equal to the scopes used when creating the filename

In order for `SourceMap::to_real_filename` to know which scopes to apply `FilePathMapping` now takes the current remapping scopes to apply, which makes `FileNameDisplayPreference` and company useless and are removed.

This PR is split-up in multiple commits (unfortunately not atomic), but should help review the changes.

Unblocks https://github.com/rust-lang/rust/pull/147611
Fixes https://github.com/rust-lang/rust/issues/148328
2025-12-13 14:32:09 +00:00
Jonathan Brouwer
69a59e8e87
Stop using IllFormedAttributeInputLint for must_use 2025-12-13 15:14:01 +01:00
Jonathan Brouwer
6a7ed1353d
Stop using IllFormedAttributeInputLint for macro_use 2025-12-13 15:14:01 +01:00
Jonathan Brouwer
f357e51e89
Stop using IllFormedAttributeInputLint for macro_use 2025-12-13 15:13:04 +01:00