about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2025-03-06Revert "rustc_middle: parallel: TyCtxt: remove "unsafe impl DynSend/DynSync""Rémy Rakic-0/+3
This reverts commit 8eba29ac1015e989e6ba96ff17a75d548afde7ff.
2025-03-05Rollup merge of #137633 - ↵许杰友 Jieyou Xu (Joe)-11/+10
compiler-errors:no-implied-bounds-hack-unless-bevy, r=lcnr Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack Consolidates the implied bounds computation mode into a single function, which deeply normalizes, and if it's in **compat** mode (for bevy), it extracts outlives bounds from the infcx. Previously, we were using the implied bounds compat mode in two cases: 1. During WF, if it detects `ParamSet` 2. EVERYWHERE ELSE (lol) -- e.g. borrowck, predicate entailment, etc. While I think this is fine, and the net effect was just that we emitted fewer diagnostics, it makes me uncomfortable that all crates were using the supposed "compat" code. Fixes #137767
2025-03-05Rollup merge of #137298 - compiler-errors:mir-wf, r=lcnr许杰友 Jieyou Xu (Joe)-1/+1
Check signature WF when lowering MIR body Alternative to #137233. https://github.com/rust-lang/rust/pull/137233#issuecomment-2667879143 Fixes https://github.com/rust-lang/rust/issues/137186 We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily. r? lcnr try-job: test-various
2025-03-04Rollup merge of #137923 - scottmcm:fix-postorder-size-hint, r=tmiaskoJubilee-26/+11
Simplify `<Postorder as Iterator>::size_hint` The current version is sometimes malformed (cc #137919); let's see if we can get away with a loose but trivially-correct one.
2025-03-04Auto merge of #135186 - camelid:const-path-multi, r=BoxyUwUbors-1/+19
mgca: Lower all const paths as `ConstArgKind::Path` When `#![feature(min_generic_const_args)]` is enabled, we now lower all const paths in generic arg position to `hir::ConstArgKind::Path`. We then lower assoc const paths to `ty::ConstKind::Unevaluated` since we can no longer use the anon const expression lowering machinery. In the process of implementing this, I factored out `hir_ty_lowering` code that is now shared between lowering assoc types and assoc consts. This PR also introduces a `#[type_const]` attribute for trait assoc consts that are allowed as const args. However, we still need to implement code to check that assoc const definitions satisfy `#[type_const]` if present (basically is it a const path or a monomorphic anon const). r? `@BoxyUwU`
2025-03-04Only use implied bounds hack if bevy, and use deeply normalize in implied ↵Michael Goulet-11/+10
bounds hack
2025-03-04Ensure that negative auto impls are always applicableMichael Goulet-2/+2
2025-03-04mgca: Lower all const paths as `ConstArgKind::Path`Noah Lev-1/+19
When `#![feature(min_generic_const_args)]` is enabled, we now lower all const paths in generic arg position to `hir::ConstArgKind::Path`. We then lower assoc const paths to `ty::ConstKind::Unevaluated` since we can no longer use the anon const expression lowering machinery. In the process of implementing this, I factored out `hir_ty_lowering` code that is now shared between lowering assoc types and assoc consts. This PR also introduces a `#[type_const]` attribute for trait assoc consts that are allowed as const args. However, we still need to implement code to check that assoc const definitions satisfy `#[type_const]` if present (basically is it a const path or a monomorphic anon const).
2025-03-04InhabitedPredicate: avoid using a wildcard branchMaja Kądziołka-1/+4
This is error-prone. Explicitly write down which cases don't need anything substituted. Turn the `OpaqueType` case, which currently seems to be unreachable, into a `bug!`.
2025-03-04Clarify why InhabitedPredicate::instantiate_opt existsMaja Kądziołka-0/+5
At first glance, the extra casework seems pointless and needlessly error-prone. Clarify that there is a reason for it being there.
2025-03-03Also simplify `Preorder`'s `size_hint`Scott McMurray-15/+5
2025-03-03Tweak error code for sized checks of const/staticMichael Goulet-1/+1
2025-03-03Rollup merge of #137922 - Zalathar:sharded, r=SparrowLiiMatthias Krüger-1/+2
A few cleanups after the removal of `cfg(not(parallel))` I noticed a few small things that are no longer needed after the removal of `cfg(not(parallel))` in #132282. One of the later changes adjusts several imports, so viewing the changes individually is recommended. r? SparrowLii (or reroll)
2025-03-03Rollup merge of #137894 - compiler-errors:no-scalar-pair-opt, r=oli-obkMatthias Krüger-1/+1
Revert "store ScalarPair via memset when one side is undef and the other side can be memset" cc #137892 reverts #135335 r? oli-obk
2025-03-03Rollup merge of #137863 - compiler-errors:unsafe-binder-render, r=oli-obkMatthias Krüger-37/+71
Fix pretty printing of unsafe binders We used to render `unsafe<> i32` as `i32`, and `unsafe<'a> &'a i32` as `for<'a> &'a i32`. r? oli-obk Review with whitespace b/c adding a new argument changes some the wrapping of some function calls.
2025-03-03Remove some unnecessary aliases from `rustc_data_structures::sync`Zalathar-1/+2
With the removal of `cfg(parallel_compiler)`, these are always shared references and `std::sync::OnceLock`.
2025-03-02Simplify `<Postorder as Iterator>::size_hint`Scott McMurray-11/+6
The current version is wrong (cc 137919); let's see if we can get away with a loose but trivially-correct one.
2025-03-03interpret/provenance_map: consistently use range_is_emptyRalf Jung-22/+22
2025-03-03Rename a bitMichael Goulet-15/+6
2025-03-03Fix pretty printing of unsafe bindersMichael Goulet-37/+80
2025-03-02Auto merge of #137704 - nnethercote:opt-empty-prov-range-checks, r=oli-obkbors-10/+27
Optimize empty provenance range checks. Currently it gets the pointers in the range and checks if the result is empty, but it can be done faster if you combine those two steps. r? `@oli-obk`
2025-03-02Revert "Auto merge of #135335 - oli-obk:push-zxwssomxxtnq, r=saethlin"Michael Goulet-1/+1
This reverts commit a7a6c64a657f68113301c2ffe0745b49a16442d1, reversing changes made to ebbe63891f1fae21734cb97f2f863b08b1d44bf8.
2025-03-01Rollup merge of #137837 - fee1-dead-contrib:push-pvqvwuvrnwsy, r=compiler-errorsMatthias Krüger-0/+14
Update `const_conditions` and `explicit_implied_const_bounds` docs Move documentation to query definitions, and add docs to `explicit_implied_const_bounds`. r? project-const-traits
2025-03-01Rollup merge of #137800 - BoxyUwU:param_env_docs, r=compiler-errorsMatthias Krüger-6/+0
Remove `ParamEnv::without_caller_bounds` This doesn't really do anything that `ParamEnv::empty` doesn't do nowadays as `ParamEnv` *only* stores caller bounds since other information has been moved out into `TypingMode` r? ```@compiler-errors``` ```@lcnr```
2025-03-01Rollup merge of #137763 - compiler-errors:ty-nits, r=BoxyUwUMatthias Krüger-2/+2
Use `mk_ty_from_kind` a bit less, clean up lifetime handling in borrowck r? ``@BoxyUwU`` Pulled out of my attempt to turn that `*const dyn Tr + '_` casting into a lint (which failed lmao)
2025-03-01Rollup merge of #137617 - BoxyUwU:generic_const_parameter_types, r=lcnrMatthias Krüger-0/+1
Introduce `feature(generic_const_parameter_types)` Allows to define const generic parameters whose type depends on other generic parameters, e.g. `Foo<const N: usize, const ARR: [u8; N]>;` Wasn't going to implement for this for a while until we could implement it with `bad_inference.rs` resolved but apparently the project simd folks would like to be able to use this for some intrinsics and the inference issue isn't really a huge problem there aiui. (cc ``@workingjubilee`` )
2025-03-01Update `const_conditions` and `explicit_implied_const_bounds` docsDeadbeef-0/+14
Move documentation to query definitions, and add docs to `explicit_implied_const_bounds`.
2025-03-01Rollup merge of #137689 - compiler-errors:coroutine, r=lcnrMatthias Krüger-43/+29
Use `Binder<Vec<Ty>>` instead of `Vec<Binder<Ty>>` in both solvers for sized/auto traits/etc. It's more conceptually justified IMO, especially when binders get implications. r? lcnr
2025-02-28Introduce `feature(generic_const_parameter_types)`Boxy-0/+1
2025-02-28Rollup merge of #137780 - samueltardieu:push-kxorztnkqnsz, r=lcnr许杰友 Jieyou Xu (Joe)-1/+1
Fix typo in query expansion documentation
2025-02-28Rollup merge of #137748 - samueltardieu:push-kozpqrxpkxkk, r=lqd许杰友 Jieyou Xu (Joe)-3/+3
Fix method name in `TyCtxt::hir_crate()` documentation Fix #137745
2025-02-28Rollup merge of #137712 - meithecatte:extract-binding-mode, r=oli-obk许杰友 Jieyou Xu (Joe)-2/+4
Clean up TypeckResults::extract_binding_mode - Remove the `Option` from the result type, as `None` is never returned. - Document the difference from the `BindingMode` in `PatKind::Binding`.
2025-02-28reviewlcnr-14/+0
2025-02-28rework cycle handlinglcnr-4/+6
A cycle was previously coinductive if all steps were coinductive. Change this to instead considerm cycles to be coinductive if they step through at least one where-bound of an impl of a coinductive trait goal.
2025-02-28Fix typo in query expansion documentationSamuel Tardieu-1/+1
2025-02-28Auto merge of #137710 - matthiaskrgr:rollup-3vmxxu9, r=matthiaskrgrbors-4/+174
Rollup of 8 pull requests Successful merges: - #136542 ([`compiletest`-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing) - #136579 (Fix UB in ThinVec::flat_map_in_place) - #136688 (require trait impls to have matching const stabilities as the traits) - #136846 (Make `AssocOp` more like `ExprKind`) - #137304 (add `IntoBounds::intersect` and `RangeBounds::is_empty`) - #137455 (Reuse machinery from `tail_expr_drop_order` for `if_let_rescope`) - #137480 (Return unexpected termination error instead of panicing in `Thread::join`) - #137694 (Spruce up `AttributeKind` docs) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-28Use mk_ty_from_kind a bit less, clean up lifetime handling in borrowckMichael Goulet-2/+2
2025-02-28Auto merge of #137669 - DianQK:fn-atts-virtual, r=saethlinbors-2/+3
Don't infer attributes of virtual calls based on the function body Fixes (after backport) #137646. Since we don't know the exact implementation of the virtual call, it might write to parameters, we can't infer the readonly attribute.
2025-02-27Fix method name in `TyCtxt::hir_crate()` documentationSamuel Tardieu-3/+3
2025-02-27Add note to Thir struct about necessity of Clone deriveNiels Saurer-0/+3
2025-02-27Revert "Derive `Clone` on fewer THIR types."Niels Saurer-22/+22
This reverts commit f0b6d660c9c13ab7b19da9e12aeb4dcab45e544b.
2025-02-27Clean up TypeckResults::extract_binding_modeMaja Kądziołka-2/+4
- Remove the `Option` from the result type, as `None` is never returned. - Document the difference from the `BindingMode` in `PatKind::Binding`.
2025-02-27Rollup merge of #137455 - compiler-errors:drop-lint-dtor, r=oli-obkMatthias Krüger-0/+173
Reuse machinery from `tail_expr_drop_order` for `if_let_rescope` Namely, it defines its own `extract_component_with_significant_dtor` which is a bit more accurate than `Ty::has_significant_drop`, since it has a hard-coded list of types from the ecosystem which are opted out of the lint.[^a] Also, since we extract the dtors themselves, adopt the same *label* we use in `tail_expr_drop_order` to point out the destructor impl. This makes it much clear what's actually being dropped, so it should be clearer to know when it's a false positive. This conflicts with #137444, but I will rebase whichever lands first. [^a]: Side-note, it's kinda a shame that now there are two functions that presumably do the same thing. But this isn't my circus, nor are these my monkeys.
2025-02-27Rollup merge of #136846 - nnethercote:make-AssocOp-more-like-ExprKind, ↵Matthias Krüger-4/+1
r=spastorino Make `AssocOp` more like `ExprKind` This is step 1 of [MCP 831](https://github.com/rust-lang/compiler-team/issues/831). r? ``@estebank``
2025-02-27Optimize empty provenance range checks.Nicholas Nethercote-10/+27
Currently it gets the pointers in the range and checks if the result is empty, but it can be done faster if you combine those two steps.
2025-02-27Don't infer attributes of virtual calls based on the function bodyDianQK-2/+3
2025-02-27Always inline `query_get_at`.Nicholas Nethercote-1/+1
2025-02-27Introduce `AssocOp::Binary`.Nicholas Nethercote-4/+1
It mirrors `ExprKind::Binary`, and contains a `BinOpKind`. This makes `AssocOp` more like `ExprKind`. Note that the variants removed from `AssocOp` are all named differently to `BinOpToken`, e.g. `Multiply` instead of `Mul`, so that's an inconsistency removed. The commit adds `precedence` and `fixity` methods to `BinOpKind`, and calls them from the corresponding methods in `AssocOp`. This avoids the need to create an `AssocOp` from a `BinOpKind` in a bunch of places, and `AssocOp::from_ast_binop` is removed. `AssocOp::to_ast_binop` is also no longer needed. Overall things are shorter and nicer.
2025-02-26Remove `ParamEnv::without_caller_bounds`Boxy-6/+0
2025-02-26Print out destructorMichael Goulet-0/+173