about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2025-05-29Rollup merge of #141638 - oli-obk:builtin-index, r=lcnrJacob Pratt-2/+1
Use `builtin_index` instead of hand-rolling it Just using the dedicated method more
2025-05-29Rollup merge of #136429 - fmease:gci-fix-def-site-checks, r=BoxyUwUJacob Pratt-9/+36
GCI: At their def site, actually wfcheck the where-clause & always eval free lifetime-generic constants * 1st commit: Partially addresses [#136204](https://github.com/rust-lang/rust/issues/136204) by turning const eval errors from post to pre-mono for free lifetime-generic constants. * As the linked issue/comment states, on master there's a difference between `const _: () = panic!();` (pre-mono error) and `const _<'a>: () = panic!();` (post-mono error) which feels wrong. * With this PR, both become pre-mono ones! * 2nd commit: Oof, yeah, I missed that in the initial impl! This doesn't fully address #136204 because I still haven't figured out how & where to properly & best suppress const eval of free constants whose predicates don't hold at the def site. The motivating example is `const _UNUSED: () = () where for<'_delay> String: Copy;` which can also be found over at the tracking issue #113521. r? compiler-errors or reassign
2025-05-28atomic_load intrinsic: use const generic parameter for orderingRalf Jung-6/+7
2025-05-28Stabilise `repr128`beetrees-14/+1
2025-05-28GCI: Check where-clauses for well-formedness at the def siteLeón Orell Valerian Liehr-8/+33
2025-05-28Use `builin_index` instead of hand-rolling itOli Scherer-2/+1
2025-05-27Rollup merge of #141495 - compiler-errors:rename-unpack, r=fmeaseMatthias Krüger-22/+22
Rename `{GenericArg,Term}::unpack()` to `kind()` A well-deserved rename IMO. r? `@oli-obk` or `@lcnr` (or anyone) cc `@rust-lang/types,` but I'd be surprised if this is controversial.
2025-05-27Always evaluate free lifetime-generic constantsLeón Orell Valerian Liehr-1/+3
Co-authored-by: Michael Goulet <michael@errs.io>
2025-05-27Fix some var namesMichael Goulet-9/+9
2025-05-27Rename unpack to kindMichael Goulet-17/+17
2025-05-27Use more detailed spans in dyn compat errors within bodiesOli Scherer-6/+13
2025-05-26RenameMichael Goulet-1/+1
2025-05-26Avoid obligation construction dance with query region constraintsMichael Goulet-1/+1
2025-05-23Auto merge of #140553 - BoxyUwU:defer_type_system_ctfe, r=compiler-errorsbors-41/+55
Defer evaluating type system constants when they use infers or params Split out of #137972, the parts necessary for associated const equality and min generic const args to make progress and have correct semantics around when CTFE is invoked. According to a [previous perf run](https://perf.rust-lang.org/compare.html?start=93257e2d20809d82d1bc0fcc1942480d1a66d7cd&end=01b4cbf0f47c3f782330db88fa5ba199bba1f8a2&stat=instructions:u) of adding the new `const_arg_kind` query we should expect minor regressions here. I think this is acceptable as we should be able to remove this query relatively soon once mgca is more complete as we'll then be able to implement GCE in terms of mgca and rip out `GCEConst` at which point it's trivial to determine what kind of anon const we're dealing with (either it has generics and is a repeat expr hack, or it doesnt and is a normal anon const). This should only affect unstable code as we handle repeat exprs specially and those are the only kinds of type system consts that are allowed to make use of generic parameters. Fixes #133066 Fixes #133199 Fixes #136894 Fixes #137813 r? compiler-errors
2025-05-22Rollup merge of #140218 - fmease:hirtylo-clean-up-path-low, r=compiler-errorsMatthias Krüger-489/+482
HIR ty lowering: Clean up & refactor the lowering of type-relative paths While rebasing #126651 I realized that HIR ty lowering could benefit from some *spring cleaning* now that it's been extended to handle RTN and mGCA paths. More seriously, similar to my merged PR #118668 which unified the handling of all *associated item constraints* (assoc ty, const (ACE) & fn (RTN)), this PR (commit https://github.com/rust-lang/rust/pull/140218/commits/695fcf517d8864b4812225643ef8cfc036ba9f61) partially[^1] deduplicates the resolution code for all *type-relative paths* (assoc ty, const (mGCA) & fn (RTN)). **Why**? DRY'ing that part of the code means PR #126651 will automatically support RTN paths like `Ty::AssocTy::assoc_fn(..)` and it also implies shared diagnostic code and thus better diagnostics for RTN. --- The other commits represent cleanups, renamings, moves. More notably, I've renamed path lowering methods to be a lot more descriptive, so ones lowering `QPath(Resolved)` paths now have `_resolved_` in their name and ones lowering `QPath(TypeRelative)` paths now have `_type_relative_` in their name. This should make it stupidly obvious what their purpose is. --- Best reviewed commit by commit. The changes are close to trivial but the diff might make it look hairier. r? compiler-errors [^1]: Sadly, I couldn't unify as much compared to the other PR without introducing unnecessary `unreachable!()`s or rendering the code otherwise illegible with flags and micro helper traits.
2025-05-22Review CommentsBoxy-7/+7
2025-05-21Introduce `tcx.anon_const_kind` queryBoxy-41/+55
2025-05-19Rollup merge of #140874 - mejrs:rads, r=WaffleLapkinStuart Cook-6/+5
make `rustc_attr_parsing` less dominant in the rustc crate graph It has/had a glob re-export of `rustc_attr_data_structures`, which is a crate much lower in the graph, and a lot of crates were using it *just* (or *mostly*) for that re-export, while they can rely on `rustc_attr_data_structures` directly. Previous graph: ![graph_1](https://github.com/user-attachments/assets/f4a5f13c-4222-4903-b56d-28c83511fcbd) Graph with this PR: ![graph_2](https://github.com/user-attachments/assets/1e053d9c-75cc-402b-84df-86229c98277a) The first commit keeps the re-export, and just changes the dependency if possible. The second commit is the "breaking change" which removes the re-export, and "explicitly" adds the `rustc_attr_data_structures` dependency where needed. It also switches over some src/tools/*. The second commit is actually a lot more involved than I expected. Please let me know if it's a better idea to back it out and just keep the first commit.
2025-05-17Auto merge of #140856 - oli-obk:merge-queries2, r=nnethercotebors-15/+13
Merge mir query analysis invocations r? `@ghost` same thing as https://github.com/rust-lang/rust/pull/140854 just a different set of queries Doing this in general has some bad cache coherence issues because the query caches are laid out in Vec<QueryResult> lists per query where each index refers to a DefId in the same order as we're iterating. Iterating two or more lists at the same time does have cache issues, so I want to poke a bit at it to see if we can't merge just a few of them at a time.
2025-05-17check coroutines with TypingMode::Borrowck to avoid cyclic reasoninglcnr-7/+13
MIR borrowck taints its output if an obligation fails. This could then cause `check_coroutine_obligations` to silence its error, causing us to not emit and actual error and ICE.
2025-05-16Auto merge of #140557 - compiler-errors:remove-wf-hack, r=lcnrbors-56/+9
Remove manual WF hack We do not need this hack anymore since we fixed the candidate selection problems with `Sized` bounds. We prefer built-in sized bounds now since #138176, which fixes the only regression this hack was intended to fix. While this theoretically is broken for some code, for example, when there a param-env bound that shadows an impl or built-in trait, we don't see it in practice and IMO it's not worth the burden of having to maintain this wart in `compare_method_predicate_entailment`. The code that regresses is, for example: ```rust trait Bar<'a> {} trait Foo<'a, T> { fn method(&self) where Self: Bar<'a>; } struct W<'a, T>(&'a T) where Self: Bar<'a>; impl<'a, 'b, T> Bar<'a> for W<'b, T> {} impl<'a, 'b, T> Foo<'a, T> for W<'b, T> { fn method(&self) {} } ``` Specifically, I don't believe this is really going to be encountered in practice. For this to fail, there must be a where clause in the *trait method* that would shadow an impl or built-in (non-`Sized`) candidate in the trait, and this shadowing would need to be encountered when solving a nested WF goal from the impl self type. See #108544 for the original regression. Crater run is clean! r? lcnr
2025-05-13Auto merge of #140887 - pietroalbini:pa-bootstrap-update, r=compiler-errorsbors-1/+0
Stage0 bootstrap update This PR [follows the release process](https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday) to update the stage0 compiler. The only thing of note is https://github.com/rust-lang/rust/commit/58651d1b316e268fac2100c3ae37bb502a36b8ba, which was flagged by clippy as a correctness fix. I think allowing that lint in our case makes sense, but it's worth to have a second pair of eyes on it. r? `@Mark-Simulacrum`
2025-05-13Run rustc_attrs dumps after typeckOli Scherer-11/+11
2025-05-13Some require_lang_item -> is_lang_item replacementsOli Scherer-4/+2
2025-05-12Fix typosomahs-1/+1
2025-05-12update cfg(bootstrap)Pietro Albini-1/+0
2025-05-11Rollup merge of #140792 - Urgau:minimum-maximum-intrinsics, ↵León Orell Valerian Liehr-0/+18
r=scottmcm,traviscross,tgross35 Use intrinsics for `{f16,f32,f64,f128}::{minimum,maximum}` operations This PR creates intrinsics for `{f16,f32,f64,f64}::{minimum,maximum}` operations. This wasn't done when those operations were added as the LLVM support was too weak but now that LLVM has libcalls for unsupported platforms we can finally use them. Cranelift and GCC[^1] support are partial, Cranelift doesn't support `f16` and `f128`, while GCC doesn't support `f16`. r? `@tgross35` try-job: aarch64-gnu try-job: dist-various-1 try-job: dist-various-2 [^1]: https://www.gnu.org/software///gnulib/manual/html_node/Functions-in-_003cmath_002eh_003e.html
2025-05-10Auto merge of #140854 - oli-obk:merge-queries, r=nnethercotebors-4/+0
Merge typeck loop with static/const item eval loop r? `@ghost` Let's try a small one first. Doing this in general has some bad cache coherence issues because the query caches are laid out in `Vec<QueryResult>` lists per query where each index refers to a `DefId` in the same order as we're iterating. Iterating two or more lists at the same time does have cache issues, so I want to poke a bit at it to see if we can't merge just a few of them at a time.
2025-05-09don't depend on rustc_attr_parsing if rustc_data_structures will domejrs-6/+5
2025-05-09Merge typeck loop with static/const item eval loopOli Scherer-4/+0
2025-05-09Use intrinsics for `{f16,f32,f64,f128}::{minimum,maximum}` operationsUrgau-0/+18
2025-05-08Rollup merge of #140684 - compiler-errors:unnecessary-assoc, r=lcnrMatthias Krüger-7/+23
Only include `dyn Trait<Assoc = ...>` associated type bounds for `Self: Sized` associated types if they are provided Since #136458, we began filtering out associated types with `Self: Sized` bounds when constructing the list of associated type bounds to put into our `dyn Trait` types. For example, given: ```rust trait Trait { type Assoc where Self: Sized; } ``` After #136458, even if a user writes `dyn Trait<Assoc = ()>`, the lowered ty would have an empty projection list, and thus be equivalent to `dyn Trait`. However, this has the side effect of no longer constraining any types in the RHS of `Assoc = ...`, not implying any WF implied bounds, and not requiring that they hold when unsizing. After this PR, we include these bounds, but (still) do not require that they are provided. If the are not provided, they are skipped from the projections list. This results in `dyn Trait` types that have differing numbers of projection bounds. This will lead to re-introducing type mismatches e.g. between `dyn Trait` and `dyn Trait<Assoc = ()>`. However, this is expected and doesn't suffer from any of the deduplication unsoundness from before #136458. We may want to begin to ignore thse bounds in the future by bumping `unused_associated_type_bounds` to an FCW. I don't want to tangle that up into the fix that was originally intended in #136458, so I'm doing a "fix-forward" in this PR and deferring thinking about this for the future. Fixes #140645 r? lcnr
2025-05-08Rollup merge of #140769 - Zoxc:fix-140731, r=oli-obkMatthias Krüger-5/+5
Add `DefPathData::OpaqueLifetime` to avoid conflicts for remapped opaque lifetimes This adds `DefPathData::OpaqueLifetime` to ensure the def paths for remapped opaque lifetimes remain unique. Fixes https://github.com/rust-lang/rust/issues/140731. r? ``@oli-obk``
2025-05-08Rollup merge of #140523 - compiler-errors:late-early-mismatch, r=jackh726Matthias Krüger-45/+299
Better error message for late/early lifetime param mismatch Rework the way we report early-/late-bound lifetime param mismatches to equate the trait and impl signatures using region variables, so that we can detect when a late-bound param is present in the signature in place of an early-bound param, or vice versa. The diagnostic is a bit more technical, but it's more obviously clear to see what the problem is, even if it's not great at explaining how to fix it. I think this could be improved further, but I still think it's much better than what exists today. Note to reviewer(s): I'd appreciate if we didn't bikeshed *too* much about this verbiage, b/c I hope it's clear that the old message sucked a lot. I'm happy to file bugs for interested new contributors to improve the messaging further. Edit(fmease): Fixes https://github.com/rust-lang/rust/issues/33624.
2025-05-07Add `DefPathData::OpaqueLifetime` to avoid conflicts for remapped opaque ↵John Kåre Alsaker-5/+5
lifetimes
2025-05-07Better error message for late/early lifetime param mismatchMichael Goulet-3/+234
2025-05-07ReviewMichael Goulet-5/+20
2025-05-07Point out region bound mismatches in check_region_bounds_on_impl_itemMichael Goulet-43/+66
2025-05-07Only include associated type bounds for Self:Sized associated types if they ↵Michael Goulet-4/+5
are provided
2025-05-07Remove manual WF hackMichael Goulet-56/+9
2025-05-07Require T: TypeFoldable in Binder<T> visitMichael Goulet-3/+3
2025-05-06Preserve generic args in suggestions for ambiguous associated itemsLeón Orell Valerian Liehr-24/+29
Most notably, this preserves the `(..)` of ambiguous RTN paths.
2025-05-06Factor out `resolve_type_relative_path`León Orell Valerian Liehr-152/+112
IMPORTANT: This leads to a tiny diagnostic regression that will be fixed in the next commit!
2025-05-06Rename and move several error reporting methodsLeón Orell Valerian Liehr-192/+205
Name them more consistently, descriptively and appropriately. Move large error reporting methods into the dedicated error module to make the happy paths in HIR ty lowering more legible.
2025-05-06Introduce Boolean type `PermitVariants` for legibilityLeón Orell Valerian Liehr-13/+22
2025-05-06Name methods pertaining to HIR ty lowering of paths more appropriatelyLeón Orell Valerian Liehr-134/+150
2025-05-06Eliminate unnecessary parameterLeón Orell Valerian Liehr-18/+10
2025-05-06Consistently use the DiagCtxtHandle of HirTyLowerer instead of the one of TyCtxtLeón Orell Valerian Liehr-17/+15
They are not the same.
2025-05-05Rollup merge of #140672 - compiler-errors:deeply-normalize, r=lcnrGuillaume Gomez-8/+39
Deeply normalize in the new solver in WF We need to deeply normalize types we check for well-formedness, since we only collect implied bounds from normalized signature types. Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/194 r? lcnr
2025-05-05Rollup merge of #140374 - compiler-errors:global_asm-bug, r=lcnrGuillaume Gomez-1/+1
Resolve instance for SymFn in global/naked asm `Instance::expect_resolve` ensures that we're actually going from trait item -> impl item. Fixes #140373