summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
AgeCommit message (Collapse)AuthorLines
2024-04-11Only inspect user-written predicates for privacy concernsOli Scherer-5/+6
(cherry picked from commit 83bd12c70fd34dece71bcc632ee3df64036ca1d8)
2024-03-15Rollup merge of #122513 - petrochenkov:somehir4, r=fmeaseGuillaume Gomez-5/+1
hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id` Also replace a few `hir_node()` calls with `hir_node_by_def_id()`. Follow up to https://github.com/rust-lang/rust/pull/120943.
2024-03-14Fill in HIR hash for associated opaque typesVadim Petrochenkov-3/+9
2024-03-14hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`Vadim Petrochenkov-5/+1
Also replace a few `hir_node()` calls with `hir_node_by_def_id()`
2024-03-13Create some minimal HIR for associated opaque typesVadim Petrochenkov-8/+21
2024-03-12Rollup merge of #122366 - oli-obk:opaques_defined_by_overflow, r=lcnrJubilee-0/+4
Fix stack overflow with recursive associated types fixes #122364
2024-03-12Fix stack overflow with recursive associated typesOli Scherer-0/+4
2024-03-12Manual rustfmtOli Scherer-2/+2
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-3/+3
2024-03-11update comment for RPITIT projectionslcnr-15/+22
2024-03-11Make `DefiningAnchor::Bind` only store the opaque types that may be ↵Oli Scherer-1/+25
constrained, instead of the current infcx root item. This makes `Bind` almost always be empty, so we can start forwarding it to queries, allowing us to remove `Bubble` entirely
2024-03-09Rollup merge of #122237 - fee1-dead-contrib:rmord, r=compiler-errorsMatthias Krüger-17/+20
Remove `Ord` from `ClosureKind` Using `Ord` to accomplish a meaning of subset relationship can be hard to read. The existing uses for that are easily replaced with a `match`, and in my opinion, more readable without needing to resorting to comments to explain the intention. cc `@compiler-errors`
2024-03-09Remove `Ord` from `ClosureKind`Deadbeef-17/+20
Using `Ord` to accomplish a meaning of subset relationship can be hard to read. The existing uses for that are easily replaced with a `match`, and in my opinion, more readable without needing to resorting to comments to explain the intention.
2024-03-08Rename some functions to represent their generalized behaviorMichael Goulet-1/+1
2024-03-08Make TAITs capture all higher-ranked lifetimes in scopeMichael Goulet-1/+1
2024-03-07Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader`Yoshitomo Nakanishi-3/+2
2024-03-06Rollup merge of #122027 - compiler-errors:rpitit-cycle, r=spastorinoMatthias Krüger-43/+4
Uplift some feeding out of `associated_type_for_impl_trait_in_impl` and into queries This PR moves the `type_of` and `generics_of` query feeding out of `associated_type_for_impl_trait_in_impl`, since eagerly feeding results in query cycles due to a subtle interaction with `resolve_bound_vars`. Fixes #122019 r? spastorino
2024-03-06Auto merge of #121679 - lcnr:opaque-wf-check-2, r=oli-obkbors-12/+1
stricter hidden type wf-check [based on #115008] Original work by `@aliemjay` in #115008. A huge thanks to them for originally figuring out this approach :heart: Fixes https://github.com/rust-lang/rust/issues/114728 Fixes https://github.com/rust-lang/rust/issues/114572 Instead of adding the `WellFormed` obligations when relating opaque types, we now always emit such an obligation when defining the hidden type. This causes nested opaque types which aren't wf to error, see the comment below for the described impact. I believe this change to be desirable as it significantly reduces complexity by removing special-cases. It also caused an issue with RPITIT: in defaulted trait methods, we add a `Projection(synthetic_assoc, rpit_of_trait_method)` clause to the `param_env`. This clause is not added to the `ParamEnv` of the nested coroutines. This caused a normalization failure in `fn check_coroutine_obligations` with the new solver. I fixed that by using the env of the typeck root instead. r? `@oli-obk`
2024-03-06Auto merge of #122045 - matthiaskrgr:rollup-5l3vpn7, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #121065 (Add basic i18n guidance for `Display`) - #121744 (Stop using Bubble in coherence and instead emulate it with an intercrate check) - #121829 (Dummy tweaks (attempt 2)) - #121857 (Implement async closure signature deduction) - #121894 (const_eval_select: make it safe but be careful with what we expose on stable for now) - #122014 (Change some attributes to only_local.) - #122016 (will_wake tests fail on Miri and that is expected) - #122018 (only set noalias on Box with the global allocator) - #122028 (Remove some dead code) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-06Auto merge of #122041 - matthiaskrgr:rollup-imsmdke, r=matthiaskrgrbors-14/+7
Rollup of 8 pull requests Successful merges: - #121202 (Limit the number of names and values in check-cfg diagnostics) - #121301 (errors: share `SilentEmitter` between rustc and rustfmt) - #121658 (Hint user to update nightly on ICEs produced from outdated nightly) - #121846 (only compare ambiguity item that have hard error) - #121961 (add test for #78894 #71450) - #121975 (hir_analysis: enums return `None` in `find_field`) - #121978 (Fix duplicated path in the "not found dylib" error) - #121991 (Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by`) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-05Rollup merge of #122018 - RalfJung:box-custom-alloc, r=oli-obkMatthias Krüger-1/+1
only set noalias on Box with the global allocator As discovered in https://github.com/rust-lang/miri/issues/3341, `noalias` and custom allocators don't go well together. rustc can now check whether a Box uses the global allocator. This replaces the previous ad-hoc and rather unprincipled check for a zero-sized allocator. This is the rustc part of fixing that; Miri will also need a patch.
2024-03-05Convert `SpannedTypeVisitor` to use `VisitorResult`Jason Newcomb-26/+20
2024-03-05Convert `TypeVisitor` and `DefIdVisitor` to use `VisitorResult`Jason Newcomb-15/+10
2024-03-05Merge `impl_trait_in_assoc_types_defined_by` query back into ↵Oli Scherer-14/+7
`opaque_types_defined_by` Instead, when we're collecting opaques for associated items, we choose the right collection mode depending on whether we're collecting for an associated item of a trait impl or not.
2024-03-05Uplift some feeding out of associated_type_for_impl_trait_in_impl and into ↵Michael Goulet-43/+4
queries
2024-03-05only set noalias on Box with the global allocatorRalf Jung-1/+1
2024-03-05Rollup merge of #121838 - oli-obk:impl_trait_in_assoc_tys_fix, r=compiler-errorsMatthias Krüger-81/+18
Use the correct logic for nested impl trait in assoc types Previously we accidentally continued with the TAIT visitor, which allowed more than we wanted to. r? ```@compiler-errors```
2024-03-04make `intrinsic` query legal for any `DefId`Oli Scherer-3/+1
2024-03-04Merge the impl trait in assoc type collector into the opaque type collector ↵Oli Scherer-81/+18
and use a runtime switch instead
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-0/+2
Make changes necessary to support these types in the compiler.
2024-02-27wf-check RPITslcnr-12/+1
2024-02-25remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsicsRalf Jung-10/+5
2024-02-21Rollup merge of #121208 - nnethercote:delayed_bug-to-bug, r=lcnrDylan DPC-3/+2
Convert `delayed_bug`s to `bug`s. I have a suspicion that quite a few delayed bug paths are impossible to reach, so I did an experiment. I converted every `delayed_bug` to a `bug`, ran the full test suite, then converted back every `bug` that was hit. A surprising number were never hit. This is too dangerous to merge. Increased coverage (fuzzing or a crater run) would likely hit more cases. But it might be useful for people to look at and think about which paths are genuinely unreachable. r? `@ghost`
2024-02-21Convert `delayed_bug`s to `bug`s.Nicholas Nethercote-3/+2
I have a suspicion that quite a few delayed bug paths are impossible to reach, so I did an experiment. I converted every `delayed_bug` to a `bug`, ran the full test suite, then converted back every `bug` that was hit. A surprising number were never hit. The next commit will convert some more back, based on human judgment.
2024-02-20Fix stray trait mismatch in resolve_associated_item for AsyncFnMichael Goulet-15/+3
2024-02-16Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkinbors-1/+2
Implement intrinsics with fallback bodies fixes #93145 (though we can port many more intrinsics) cc #63585 The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for * codegen_ssa (so llvm and gcc) * codegen_cranelift other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body). cc `@scottmcm` `@WaffleLapkin` ### todo * [ ] miri support * [x] default intrinsic name to name of function instead of requiring it to be specified in attribute * [x] make sure that the bodies are always available (must be collected for metadata)
2024-02-13Auto merge of #120919 - oli-obk:impl_polarity, r=compiler-errorsbors-3/+4
Merge `impl_polarity` and `impl_trait_ref` queries Hopefully this is perf neutral. I want to finish https://github.com/rust-lang/rust/pull/120835 and stop using the HIR in `coherent_trait`, which should then give us a perf improvement.
2024-02-12Rollup merge of #120958 - ShoyuVanilla:remove-subst, r=oli-obkMatthias Krüger-20/+23
Dejargonize `subst` In favor of #110793, replace almost every occurence of `subst` and `substitution` from rustc codes, but they still remains in subtrees under `src/tools/` like clippy and test codes (I'd like to replace them after this)
2024-02-12Stop calling `impl_polarity` when `impl_trait_ref` was also calledOli Scherer-3/+4
2024-02-12Make `is_intrinsic` query return the intrinsic nameOli Scherer-1/+2
2024-02-12Dejargnonize substShoyu Vanilla-20/+23
2024-02-12Lower anonymous structs or unions to HIRFrank King-2/+1
2024-02-11Auto merge of #120619 - compiler-errors:param, r=lcnrbors-3/+1
Assert that params with the same *index* have the same *name* Found this bug when trying to build libcore with the new solver, since it will canonicalize two params with the same index into *different* placeholders if those params differ by name.
2024-02-10Auto merge of #120712 - compiler-errors:async-closures-harmonize, r=oli-obkbors-0/+31
Harmonize `AsyncFn` implementations, make async closures conditionally impl `Fn*` traits This PR implements several changes to the built-in and libcore-provided implementations of `Fn*` and `AsyncFn*` to address two problems: 1. async closures do not implement the `Fn*` family traits, leading to breakage: https://crater-reports.s3.amazonaws.com/pr-120361/index.html 2. *references* to async closures do not implement `AsyncFn*`, as a consequence of the existing blanket impls of the shape `AsyncFn for F where F: Fn, F::Output: Future`. In order to fix (1.), we implement `Fn` traits appropriately for async closures. It turns out that async closures can: * always implement `FnOnce`, meaning that they're drop-in compatible with `FnOnce`-bound combinators like `Option::map`. * conditionally implement `Fn`/`FnMut` if they have no captures, which means that existing usages of async closures should *probably* work without breakage (crater checking this: https://github.com/rust-lang/rust/pull/120712#issuecomment-1930587805). In order to fix (2.), we make all of the built-in callables implement `AsyncFn*` via built-in impls, and instead adjust the blanket impls for `AsyncFn*` provided by libcore to match the blanket impls for `Fn*`.
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-4/+0
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-07Stop using is_copy_modulo_regions when building clone shimMichael Goulet-3/+1
2024-02-07Stop using `hir_ty_to_ty` in rustc_privacyOli Scherer-3/+3
2024-02-07Actually walk fields of Adt definitionsOli Scherer-2/+11
2024-02-07extern types don't have any types to visitOli Scherer-1/+1
2024-02-07Associated types in traits don't necessarily have a type that we can visitOli Scherer-5/+4
This prevents ICEs from happening in the future when this code path is actually used