3240 Commits

Author SHA1 Message Date
bors
f46ce66fcc Auto merge of #143267 - matthiaskrgr:rollup-suvzar6, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#143125 (Disable f16 on Aarch64 without neon for llvm < 20.1.1)
 - rust-lang/rust#143156 (inherit `#[align]` from trait method prototypes)
 - rust-lang/rust#143178 (rustdoc default faviocon)
 - rust-lang/rust#143234 (Replace `ItemCtxt::report_placeholder_type_error` match with a call to `TyCtxt::def_descr`)
 - rust-lang/rust#143245 (mbe: Add tests and restructure metavariable expressions)
 - rust-lang/rust#143257 (Upgrade dependencies in run-make-support)
 - rust-lang/rust#143263 (linkify CodeSuggestion in doc comments)
 - rust-lang/rust#143264 (fix: Emit suggestion filename if primary diagnostic span is dummy)

Failed merges:

 - rust-lang/rust#143251 (bootstrap: add build.tidy-extra-checks option)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-01 05:31:05 +00:00
Michael Goulet
08278eb1d5 Don't recompute DisambiguatorState for every RPITIT in trait definition 2025-06-30 21:21:35 +00:00
Guillaume Gomez
76df2656df Replace ItemCtxt::report_placeholder_type_error match with a call to TyCtxt::def_descr 2025-06-30 20:36:16 +02:00
Nicholas Nethercote
478f8287c0 Introduce ByteSymbol.
It's like `Symbol` but for byte strings. The interner is now used for
both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"`
you'll get a `Symbol` and a `ByteSymbol` with the same index and the
characters will only be stored once.

The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to
make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate
`ast::LitKind` in HIR. The latter change reduces peak memory by a
non-trivial amount on literal-heavy benchmarks such as `deep-vector` and
`tuple-stress`.

`Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some
changes so that they can handle normal strings and byte strings.

This change does slow down compilation of programs that use
`include_bytes!` on large files, because the contents of those files are
now interned (hashed). This makes `include_bytes!` more similar to
`include_str!`, though `include_bytes!` contents still aren't escaped,
and hashing is still much cheaper than escaping.
2025-06-30 20:42:27 +10:00
Oli Scherer
422eea2863 Don't run hir wfcheck if ty wfcheck handled everything 2025-06-30 08:47:53 +00:00
Oli Scherer
65aac24a08 Avoid some eager uses of HIR spans 2025-06-30 08:45:43 +00:00
Oli Scherer
5ddae353fe Stop requiring HIR for impl item wf checks 2025-06-30 08:45:43 +00:00
Oli Scherer
38ef94aef1 Stop requiring HIR for trait item wf checks 2025-06-30 08:45:43 +00:00
Oli Scherer
6166cd6b50 Avoid looking at HIR for trait and impl items 2025-06-30 08:45:43 +00:00
Oli Scherer
70215dfe61 Avoid eagerly loading the hir fn sig 2025-06-30 08:45:43 +00:00
Oli Scherer
5940109a04 Merge lower_trait_item and lower_impl_item into check_item_type 2025-06-30 08:45:43 +00:00
Oli Scherer
cb158c2119 Merge lower_item into check_item_type 2025-06-30 08:45:43 +00:00
Oli Scherer
632a921479 Move lazy type alias checks to non-hir-wfck 2025-06-30 08:45:43 +00:00
Oli Scherer
28f023c751 Use predicate spans instead of whole item spans 2025-06-30 08:45:43 +00:00
Oli Scherer
ee8fa4eb16 Check variances in the non-hir wfchecker 2025-06-30 08:45:43 +00:00
Oli Scherer
d27c05709c Make variance wfcheck only use the HIR in the error path 2025-06-30 08:45:43 +00:00
Oli Scherer
362d4ddff4 Don't look at static items' HIR for wfcheck 2025-06-30 08:45:43 +00:00
Oli Scherer
9b5d57d0a9 Unconditionally run check_item_type on all items 2025-06-30 08:06:08 +00:00
Oli Scherer
cca072ca15 Make check_param_wf only go through the HIR in the error path 2025-06-30 08:04:11 +00:00
Oli Scherer
215009bd0c Stop storing Span that is only used for checking for global bounds that do not hold 2025-06-30 08:04:11 +00:00
Guillaume Gomez
66ad1f2abf
Rollup merge of #142078 - sayantn:more-intrinsics, r=workingjubilee
Add SIMD funnel shift and round-to-even intrinsics

This PR adds 3 new SIMD intrinsics

 - `simd_funnel_shl` - funnel shift left
 - `simd_funnel_shr` - funnel shift right
 - `simd_round_ties_even` (vector version of `round_ties_even_fN`)

TODO (future PR): implement `simd_fsh{l,r}` in miri, cg_gcc and cg_clif (it is surprisingly hard to implement without branches, the common tricks that rotate uses doesn't work because we have 2 elements now. e.g, the `-n&31` trick used by cg_gcc to implement rotate doesn't work with this because then `fshl(a, b, 0)` will be `a | b`)

[#t-compiler > More SIMD intrinsics](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/More.20SIMD.20intrinsics/with/522130286)

`@rustbot` label T-compiler T-libs A-intrinsics F-core_intrinsics
r? `@workingjubilee`
2025-06-29 12:29:53 +02:00
Yotam Ofek
8429c9911b Remove unused feature gates 2025-06-28 23:36:46 +00:00
Matthias Krüger
0e79b8914d
Rollup merge of #143106 - yotamofek:pr/gce/non-local-ice, r=BoxyUwU
gce: don't ICE on non-local const

Fixes rust-lang/rust#133808

I have absolutely no idea what I'm doing here, but I followed `@BoxyUwU` 's [instructions](https://github.com/rust-lang/rust/issues/133808#issuecomment-3009122957), and turns out this small change fixes rust-lang/rust#133808, and doesn't seem to break anything else.
(This code path is only reachable when the GCE feature gate is enabled, so even if it does break in a way that is not caught by current test coverage, I guess it's not as bad as breaking stable or non-incomplete features?)

Anyways, r? `@BoxyUwU` , if you don't mind.
2025-06-27 22:13:07 +02:00
Matthias Krüger
0f89445e39
Rollup merge of #143104 - davidtwco:issue-142652-dyn-pointeesized-deny, r=compiler-errors
hir_analysis: prohibit `dyn PointeeSized`

Fixes rust-lang/rust#142652
Supersedes rust-lang/rust#142663

`dyn PointeeSized` is nonsensical as a `dyn PointeeSized` needs to be `MetaSized`, so lets reject it to avoid hitting code paths that expect a builtin impl for `PointeeSized`

r? `@compiler-errors`
2025-06-27 22:13:07 +02:00
Matthias Krüger
36c2b011cb
Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-dead
New const traits syntax

This PR only affects the AST and doesn't actually change anything semantically.

All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser

Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error

r? ``@fee1-dead``

cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27 22:13:00 +02:00
Yotam Ofek
0e32036deb gce: don't ICE on non-local const 2025-06-27 18:07:07 +00:00
David Wood
2057423506
hir_analysis: prohibit dyn PointeeSized 2025-06-27 17:01:47 +00:00
Guillaume Gomez
80f20c98f3
Rollup merge of #142671 - davidtwco:no-default-bounds-attr, r=lcnr
add #![rustc_no_implicit_bounds]

Follow-up from rust-lang/rust#137944.

Adds a new `rustc_attrs` attribute that stops rustc from adding any default bounds. Useful for tests where default bounds just add noise and make debugging harder.

After reviewing all tests with `?Sized`, these tests seem like they could probably benefit from `#![rustc_no_implicit_bounds]`.

- Skipping most of `tests/ui/unsized` as these seem to want to test `?Sized`
- Skipping tests that used `Box<T>` because it's still bound by `T: MetaSized`
- Skipping parsing or other tests that cared about `?Sized` syntactically
- Skipping tests for `derive(CoercePointee)` because this appears to check that the pointee type is relaxed with `?Sized` explicitly

r? `@lcnr`
2025-06-27 15:04:52 +02:00
Oli Scherer
c51f05be30 Report infer ty errors during hir ty lowering
This centralizes the placeholder type error reporting in one location, but it also exposes the granularity at which we convert things from hir to ty more. E.g. previously infer types in where bounds were errored together with the function signature, but now they are independent.
2025-06-27 07:51:38 +00:00
Michael Goulet
d712024aee
Rollup merge of #142927 - compiler-errors:note-find-const, r=BoxyUwU
Add note to `find_const_ty_from_env`

Add a note to `find_const_ty_from_env` to explain why it has an `unwrap` which "often" causes ICEs.

Also, uplift it into the new trait solver. This avoids needing to go through the interner to call this method which is otherwise an inherent method in the compiler. I can remove this part if desired.

r? `@boxyuwu`
2025-06-26 20:15:22 -04:00
Michael Goulet
48d311898b
Rollup merge of #142637 - compiler-errors:less-globs, r=lcnr
Remove some glob imports from the type system

Namely, remove the glob imports for `BoundRegionConversionTime`, `RegionVariableOrigin`, `SubregionOrigin`, `TyOrConstInferVar`, `RegionResolutionError`, `SelectionError`, `ProjectionCandidate`, `ProjectionCandidateSet`, and some more specific scoped globs (like `Inserted` in the impl overlap graph construction.

These glob imports are IMO very low value, since they're not used nearly as often as other globs (like `TyKind`).
2025-06-26 20:15:19 -04:00
Oli Scherer
eb7245a864 Change const trait bound syntax from ~const to [const] 2025-06-26 13:46:45 +00:00
Jana Dönszelmann
63c5a84b74
Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk
Add runtime check to avoid overwrite arg in `Diag`

## Origin PR description
At first, I set up a `debug_assert` check for the arg method to make sure that `args` in `Diag` aren't easily overwritten, and I added the `remove_arg()` method, so that if you do need to overwrite an arg, then you can explicitly call `remove_arg()` to remove it first, then call `arg()` to overwrite it.

For the code before the rust-lang/rust#142015 change, it won't compile because it will report an error
```
arg `instance`already exists.
```

This PR also modifies all diagnostics that fail the check to pass the check. There are two cases of check failure:

1. ~~Between *the parent diagnostic and the subdiagnostic*, or *between the subdiagnostics* have the same field between them. In this case, I renamed the conflicting fields.~~
2. ~~For subdiagnostics stored in `Vec`, the rendering may iteratively write the same arg over and over again. In this case, I changed the auto-generation with `derive(SubDiagnostic)` to manually implementing `SubDiagnostic` and manually rendered it with `eagerly_translate()`, similar to https://github.com/rust-lang/rust/issues/142031#issuecomment-2984812090, and after rendering it I manually deleted useless arg with the newly added `remove_arg` method.~~

## Final Decision

After trying and discussing, we made a final decision.

For `#[derive(Subdiagnostic)]`, This PR made two changes:

1. After the subdiagnostic is rendered, remove all args of this subdiagnostic, which allows for usage like `Vec<Subdiag>`.
2. Store `diag.args` before setting arguments, so that you can restore the contents of the main diagnostic after deleting the arguments after subdiagnostic is rendered, to avoid deleting the main diagnostic's arg when they have the same name args.
2025-06-25 22:14:55 +02:00
Michael Goulet
c995070b6a rename RegionVariableOrigin::MiscVariable to RegionVariableOrigin::Misc 2025-06-25 15:35:18 +00:00
Michael Goulet
44254c8cd7 Remove some glob imports from the type system 2025-06-25 15:35:16 +00:00
xizheyin
d2d17c60bd
Add runtime check to avoid overwrite arg easily in diag and store and restore snapshot when set subdiag arg
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-25 21:07:16 +08:00
Jubilee Young
383d76106b compiler: Trim the misleading C of C-cmse from errors 2025-06-25 00:52:10 -07:00
Jubilee Young
35deb5bce4 compiler: Trim the misleading C from ExternAbi::CCmse* 2025-06-25 00:52:09 -07:00
Jubilee
2ad6272649
Rollup merge of #142825 - jdonszelmann:track-caller, r=oli-obk
Port `#[track_caller]` to the new attribute system

r? ``@oli-obk``

depends on https://github.com/rust-lang/rust/pull/142493

Closes rust-lang/rust#142783

(didn't add a test for this, this situation should simply never come up again, the code was simply wrong. lmk if I should add it, but it won't test something very useful)
2025-06-24 19:45:32 -07:00
Jubilee
891dc0fb09
Rollup merge of #142633 - folkertdev:interrupt-abi-restrict-signature, r=workingjubilee
Error on invalid signatures for interrupt ABIs

We recently added `extern "custom"`, which must have type `fn()`. The various `extern "interrupt"` ABIs impose similar constraints on the signature of functions with that ABI: `x86-interrupt` should not have a return type (linting on the exact argument types is left as future work), and the other interrupt ABIs cannot have any parameters or a return type.

r? ```@workingjubilee```
2025-06-24 19:45:31 -07:00
Jana Dönszelmann
5d44fdd972
Rewrite #[track_caller] 2025-06-24 23:00:31 +02:00
Folkert de Vries
943d37958b
Error on invalid signatures for interrupt ABIs 2025-06-24 14:40:11 +02:00
Guillaume Gomez
69cc875438
Rollup merge of #142695 - GrigorenkoPV:attributes/rustc_skip_during_method_dispatch, r=jdonszelmann
Port `#[rustc_skip_during_method_dispatch]` to the new attribute system

Part of rust-lang/rust#131229

r? ``@jdonszelmann``
2025-06-24 11:20:07 +02:00
Michael Goulet
00f369abc2 Add note to find_const_ty_from_env 2025-06-23 21:00:09 +00:00
Pavel Grigorenko
aa80a2b62c Port #[rustc_skip_during_method_dispatch] to the new attribute system 2025-06-23 22:48:20 +03:00
Ralf Jung
7c6b50cd5b unsupported_calling_conventions: print which ABI this is about 2025-06-23 09:40:00 -07:00
Jubilee Young
267ecd132b Clarify note in rustc_ast_lowering still applies
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-06-23 09:40:00 -07:00
Jubilee Young
b34c52043f compiler: Remove unsupported_fn_ptr_calling_conventions lint 2025-06-23 09:39:59 -07:00
Jubilee Young
e93a99b324 hir_analysis: Avoid repeating unsupported ABI errors 2025-06-23 09:39:23 -07:00
Jana Dönszelmann
5c0a625205
move naked checks out of check_attr.rs 2025-06-23 12:22:57 +02:00