3252 Commits

Author SHA1 Message Date
Jubilee Young
3b7f9f9d1b compiler: document all provide fn in hir_analysis and hir_typeck 2025-07-03 13:49:34 -07:00
Jubilee Young
f5fbb2c0a5 compiler: inline 1-2 query provide fn in hir_analysis and hir_typeck
Many small indirections with 1-2 items actively hinders understanding.
Inlines various tiny submodule provides into
- hir_analysis::provide
- hir_analysis::check::provide
- hir_typeck::provide
2025-07-03 13:48:32 -07:00
Michael Goulet
e2e3f5809b Remove PointerLike trait 2025-07-03 20:03:49 +00:00
Jana Dönszelmann
0aaac883de
Rollup merge of #143038 - Qelxiros:142676-private-dependency-traits, r=tgross35
avoid suggesting traits from private dependencies

fixes rust-lang/rust#142676
fixes rust-lang/rust#138191

r? ``@tgross35``
2025-07-03 13:29:36 +02:00
Jana Dönszelmann
f6d37a25a9
Rollup merge of #134006 - klensy:typos, r=nnethercote
setup typos check in CI

This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying?

Also includes commits with actual typo fixes.

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

typos check currently turned for:
* ./compiler
* ./library
* ./src/bootstrap
* ./src/librustdoc

After merging, PRs which enables checks for other crates (tools) can be implemented too.

Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr.

Check typos: `python x.py test tidy --extra-checks=spellcheck`
Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo)

Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03 13:29:35 +02:00
klensy
c76d032f01 setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
Matthias Krüger
547dc74fcd
Rollup merge of #143292 - compiler-errors:explicit-generic, r=oli-obk
Explicitly handle all nodes in `generics_of` when computing parent

If we, for example, forget to feed `generics_of` then it'll silently fall back to empty generics. Make this a bit more explicit.
2025-07-03 05:21:33 +02:00
Jeremy Smart
6b824e8143
avoid suggesting traits from private dependencies 2025-07-02 22:04:51 -04:00
Matthias Krüger
7fa00aa75f
Rollup merge of #143258 - compiler-errors:disambiguator-state, r=oli-obk
Don't recompute `DisambiguatorState` for every RPITIT in trait definition

The `associated_type_for_impl_trait_in_trait` currently needs to rerun the `RPITVisitor` for every RPITIT to compute its disambiguator.

Instead of synthesizing all of the RPITITs def ids one at a time in different queries, just synthesize them inside of the `associated_types_for_impl_traits_in_associated_fn` query. There we can just share the same `DisambiguatorState` for all the RPITITs in one function signature.

r? ``````@Zoxc`````` or ``````@oli-obk`````` cc rust-lang/rust#140453
2025-07-02 19:28:08 +02:00
Michael Goulet
0330525b1c Explicitly handle all nodes in generics_of when computing parent 2025-07-02 16:55:18 +00:00
Michael Goulet
2516c33982 Remove support for dyn* 2025-07-01 19:00:21 +00:00
bors
4e97337005 Auto merge of #142030 - oli-obk:wfck-less-hir, r=compiler-errors
Start moving wf checking away from HIR

I'm trying to only access the HIR in the error path. My hope is that once we move significant portions of wfcheck off HIR that incremental will be able to cache wfcheck queries significantly better.

I think I am reaching a blocker because we normally need to provide good spans to `ObligationCause`, so that the trait solver can report good errors. In some cases I have been able to use bad spans and improve them depending on the `ObligationCauseCode` (by loading HIR in the case where we actually want to error). To scale that further we'll likely need to remove spans from the `ObligationCause` entirely (leaving it to some variants of `ObligationCauseCode` to have a span when they can't recompute the information later). Unsure this is the right approach, but we've already been using it. I will create an MCP about it, but that should not affect this PR, which is fairly limited in where it does those kind of tricks.

Especially b862d8828e is interesting here, because I think it improves spans in all cases
2025-07-01 14:59:58 +00:00
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