summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2024-06-20Only compute specializes query if specialization is enabled in the crate of ↵Michael Goulet-0/+5
the specialized impl (cherry picked from commit 4b188d9d667dfcc7ba4caf95e56cbb3a6697f292)
2024-06-07Auto merge of #125918 - oli-obk:const_block_ice, r=compiler-errorsbors-36/+12
Revert: create const block bodies in typeck via query feeding as per the discussion in https://github.com/rust-lang/rust/pull/125806#discussion_r1622563948 It was a mistake to try to shoehorn const blocks and some specific anon consts into the same box and feed them during typeck. It turned out not simplifying anything (my hope was that we could feed `type_of` to start avoiding the huge HIR matcher, but that didn't work out), but instead making a few things more fragile. reverts the const-block-specific parts of https://github.com/rust-lang/rust/pull/124650 `@bors` rollup=never had a small perf impact previously fixes https://github.com/rust-lang/rust/issues/125846 r? `@compiler-errors`
2024-06-07Revert "Create const block DefIds in typeck instead of ast lowering"Oli Scherer-35/+12
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-06-07Revert "Cache whether a body has inline consts"Oli Scherer-1/+0
This reverts commit eae5031ecbda434e92966099e0dc93917de03eff.
2024-06-07Auto merge of #126108 - workingjubilee:rollup-g7m92b6, r=workingjubileebors-1040/+292
Rollup of 7 pull requests Successful merges: - #125606 (Size optimize int formatting) - #125724 (Uplift `Relate`/`TypeRelation` into `rustc_next_trait_solver`) - #126040 (Don't warn on fields in the `unreachable_pub` lint ) - #126098 (Remove `same-lib-two-locations-no-panic` run-make test) - #126099 (Crate loader cleanups) - #126101 (Revert "Disallow ambiguous attributes on expressions" on nightly) - #126103 (Improve Docs for `hir::Impl` and `hir::ImplItem`) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-06Rollup merge of #125724 - compiler-errors:uplift-relate, r=lcnrJubilee-1040/+292
Uplift `Relate`/`TypeRelation` into `rustc_next_trait_solver` For use in the new solver. This doesn't yet uplift `ObligationEmittingRelation`. r? lcnr
2024-06-07Auto merge of #125928 - michaelwoerister:fix-cgu-hashstable, r=oli-obkbors-30/+21
Stabilize order of MonoItems in CGUs and disallow query_instability lint for rustc_monomorphize The HashStable impl for `CodegenUnit` was incorrect as described in [MCP 533](https://github.com/rust-lang/compiler-team/issues/533). This PR removes any indeterminism from the way codegen units are built. The changes are pretty straightforward. Part of https://github.com/rust-lang/rust/issues/84447 and [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
2024-06-06Auto merge of #126068 - lqd:revert-124976, r=petrochenkovbors-20/+11
Revert "use `tcx.used_crates(())` more" before it reaches beta There are more open issues caused by #124976 than will be fixed by #125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time. fixes https://github.com/rust-lang/rust/issues/125474 fixes https://github.com/rust-lang/rust/issues/125484 fixes https://github.com/rust-lang/rust/issues/125646 fixes https://github.com/rust-lang/rust/issues/125707 fixes #126066 fixes #125934 fixes https://github.com/rust-lang/rust/issues/126021 r? `@petrochenkov` `@bors` p=1
2024-06-06Uplift TypeRelation and RelateMichael Goulet-864/+247
2024-06-06Uplift TypeErrorMichael Goulet-170/+40
2024-06-06Make middle not rely on next_trait_solverMichael Goulet-6/+5
2024-06-06Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"Rémy Rakic-20/+11
This reverts commit eda4a35f365535af72118118a3597edf5a13c12d, reversing changes made to eb6b35b5bcb3c2a594cb29cd478aeb2893f49d30.
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-5/+7
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-06Auto merge of #125958 - BoxyUwU:remove_const_ty, r=lcnrbors-283/+249
Remove the `ty` field from type system `Const`s Fixes #125556 Fixes #122908 Part of the work on `adt_const_params`/`generic_const_param_types`/`min_generic_const_exprs`/generally making the compiler nicer. cc rust-lang/project-const-generics#44 Please review commit-by-commit otherwise I wasted a lot of time not just squashing this into a giant mess (and also it'll be SO much nicer because theres a lot of fluff changes mixed in with other more careful changes if looking via File Changes --- Why do this? - The `ty` field keeps causing ICEs and weird behaviour due to it either being treated as "part of the const" or it being forgotten about leading to ICEs. - As we move forward with `adt_const_params` and a potential `min_generic_const_exprs` it's going to become more complex to actually lower the correct `Ty<'tcx>` - It muddles the idea behind how we check `Const` arguments have the correct type. By having the `ty` field it may seem like we ought to be relating it when we relate two types, or that its generally important information about the `Const`. - Brings the compiler more in line with `a-mir-formality` as that also tracks the type of type system `Const`s via `ConstArgHasType` bounds in the env instead of on the `Const` itself. - A lot of stuff is a lot nicer when you dont have to pass around the type of a const lol. Everywhere we construct `Const` is now significantly nicer :sweat_smile: See #125671's description for some more information about the `ty` field --- General summary of changes in this PR: - Add `Ty` to `ConstKind::Value` as otherwise there is no way to implement `ConstArgHasType` to ensure that const arguments are correctly typed for the parameter when we stop creating anon consts for all const args. It's also just incredibly difficult/annoying to thread the correct `Ty` around to a bunch of ctfe functions otherwise. - Fully implement `ConstArgHasType` in both the old and new solver. Since it now has no reliance on the `ty` field it serves its originally intended purpose of being able to act as a double check that trait vs impls have correctly typed const parameters. It also will now be able to be responsible for checking types of const arguments to parameters under `min_generic_const_exprs`. - Add `Ty` to `mir::Const::Ty`. I dont have a great understanding of why mir constants are setup like this to be honest. Regardless they need to be able to determine the type of the const and the easiest way to make this happen was to simply store the `Ty` along side the `ty::Const`. Maybe we can do better here in the future but I'd have to spend way more time looking at everywhere we use `mir::Const`. - rustdoc has its own `Const` which also has a `ty` field. It was relatively easy to remove this. --- r? `@lcnr` `@compiler-errors`
2024-06-06Auto merge of #122505 - oli-obk:visit_nested_body2, r=tmiaskobors-3/+23
Don't walk the bodies of free constants for reachability. follow-up to #122371 cc #119214 This avoids codegening items (e.g. functions) that are only used during const eval, but do not reach their final constant value (e.g. via function pointers). r? `@tmiasko`
2024-06-05ty::Expr reviewsBoxy-6/+10
2024-06-05Misc fixes (pattern type lowering, cfi, pretty printing)Boxy-18/+1
2024-06-05Add `Ty` to `mir::Const::Ty`Boxy-16/+25
2024-06-05Fully implement `ConstArgHasType`Boxy-0/+48
2024-06-05Add `Ty` to `ConstKind::Value`Boxy-71/+72
2024-06-05Basic removal of `Ty` from places (boring)Boxy-211/+132
2024-06-05Rollup merge of #125505 - aDotInTheVoid:middle-idl, r=pnkfelixMatthias Krüger-5/+6
Add intra-doc-links to rustc_middle crate-level docs. Makes it slightly faster to find these modules, as you don't need to hunt for them in the big list.
2024-06-05Don't walk the bodies of free constants for reachability.Oli Scherer-3/+23
2024-06-05Rollup merge of #123168 - joshtriplett:size-of-prelude, r=AmanieuJubilee-1/+1
Add `size_of` and `size_of_val` and `align_of` and `align_of_val` to the prelude (Note: need to update the PR to add `align_of` and `align_of_val`, and remove the second commit with the myriad changes to appease the lint.) Many, many projects use `size_of` to get the size of a type. However, it's also often equally easy to hardcode a size (e.g. `8` instead of `size_of::<u64>()`). Minimizing friction in the use of `size_of` helps ensure that people use it and make code more self-documenting. The name `size_of` is unambiguous: the name alone, without any prefix or path, is self-explanatory and unmistakeable for any other functionality. Adding it to the prelude cannot produce any name conflicts, as any local definition will silently shadow the one from the prelude. Thus, we don't need to wait for a new edition prelude to add it.
2024-06-04Add safe/unsafe to static inside extern blocksSantiago Pastorino-3/+5
2024-06-04Handle safety keyword for extern block inner itemsSantiago Pastorino-2/+2
2024-06-04Auto merge of #123536 - compiler-errors:simplify-int-float, r=lcnrbors-36/+2
Simplify `IntVarValue`/`FloatVarValue` r? `@ghost`
2024-06-04Rollup merge of #125968 - BoxyUwU:shrink_ty_expr, r=oli-obkMichael Goulet-155/+208
Store the types of `ty::Expr` arguments in the `ty::Expr` Part of #125958 In attempting to remove the `ty` field on `Const` it will become necessary to store the `Ty<'tcx>` inside of `Expr<'tcx>`. In order to do this without blowing up the size of `ConstKind`, we start storing the type/const args as `GenericArgs` r? `@oli-obk`
2024-06-04Downsize `ty::Expr`Boxy-155/+208
2024-06-04Rollup merge of #125750 - compiler-errors:expect, r=lcnr许杰友 Jieyou Xu (Joe)-5/+13
Align `Term` methods with `GenericArg` methods, add `Term::expect_*` * `Term::ty` -> `Term::as_type`. * `Term::ct` -> `Term::as_const`. * Adds `Term::expect_type` and `Term::expect_const`, and uses them in favor of `.ty().unwrap()`, etc. I could also shorten these to `as_ty` and then do `GenericArg::as_ty` as well, but I do think the `as_` is important to signal that this is a conversion method, and not a getter, like `Const::ty` is. r? types
2024-06-03Align Term methods with GenericArg methodsMichael Goulet-5/+13
2024-06-03Stabilize order of MonoItems in CGUs and disallow query_instability lint for ↵Michael Woerister-30/+21
rustc_monomorphize
2024-06-03check_is_object_safe -> is_object_safeMichael Goulet-1/+1
2024-06-03Auto merge of #125778 - estebank:issue-67100, r=compiler-errorsbors-1/+1
Use parenthetical notation for `Fn` traits Always use the `Fn(T) -> R` format when printing closure traits instead of `Fn<(T,), Output = R>`. Address #67100: ``` error[E0277]: expected a `Fn()` closure, found `F` --> file.rs:6:13 | 6 | call_fn(f) | ------- ^ expected an `Fn()` closure, found `F` | | | required by a bound introduced by this call | = note: wrap the `F` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `call_fn` --> file.rs:1:15 | 1 | fn call_fn<F: Fn() -> ()>(f: &F) { | ^^^^^^^^^^ required by this bound in `call_fn` help: consider further restricting this bound | 5 | fn call_any<F: std::any::Any + Fn()>(f: &F) { | ++++++ ```
2024-06-01Auto merge of #125775 - compiler-errors:uplift-closure-args, r=lcnrbors-730/+126
Uplift `{Closure,Coroutine,CoroutineClosure}Args` and friends to `rustc_type_ir` Part of converting the new solver's `structural_traits.rs` to be interner-agnostic. I decided against aliasing `ClosureArgs<TyCtxt<'tcx>>` to `ClosureArgs<'tcx>` because it seemed so rare. I could do so if desired, though. r? lcnr
2024-06-01Uplift TypeRelation and RelateMichael Goulet-717/+126
2024-06-01Yeet PolyFnSig from InternerMichael Goulet-13/+0
2024-06-01Simplify IntVarValue/FloatVarValueMichael Goulet-36/+2
2024-06-01Deduplicate supertrait_def_ids codeMark Rousskov-12/+10
2024-06-01Increase vtable layout sizeMark Rousskov-18/+71
This improves LLVM's codegen by allowing vtable loads to be hoisted out of loops (as just one example).
2024-05-31Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obkbors-132/+245
Implement `needs_async_drop` in rustc and optimize async drop glue This PR expands on #121801 and implements `Ty::needs_async_drop` which works almost exactly the same as `Ty::needs_drop`, which is needed for #123948. Also made compiler's async drop code to look more like compiler's regular drop code, which enabled me to write an optimization where types which do not use `AsyncDrop` can simply forward async drop glue to `drop_in_place`. This made size of the async block from the [async_drop test](https://github.com/zetanumbers/rust/blob/67980dd6fb11917d23d01a19c2cf4cfc3978aac8/tests/ui/async-await/async-drop.rs) to decrease by 12%.
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-2/+2
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-2/+2
2024-05-30Rollup merge of #125754 - Zalathar:conditions-num, r=lqdMatthias Krüger-4/+4
coverage: Rename MC/DC `conditions_num` to `num_conditions` Updated version of #124571, without the other changes that were split out into #125108 and #125700. This value represents a quantity of conditions, not an ID, so the new spelling is more appropriate. Some of the code touched by this PR could perhaps use some other changes, but I would prefer to keep this PR as a simple renaming and avoid scope creep. `@rustbot` label +A-code-coverage
2024-05-30coverage: Rename MC/DC `conditions_num` to `num_conditions`Zalathar-4/+4
This value represents a quantity of conditions, not an ID, so the new spelling is more appropriate.
2024-05-29Use parenthetical notation for `Fn` traitsEsteban Küber-1/+1
Always use the `Fn(T) -> R` format when printing closure traits instead of `Fn<(T,), Output = R>`. Fix #67100: ``` error[E0277]: expected a `Fn()` closure, found `F` --> file.rs:6:13 | 6 | call_fn(f) | ------- ^ expected an `Fn()` closure, found `F` | | | required by a bound introduced by this call | = note: wrap the `F` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `call_fn` --> file.rs:1:15 | 1 | fn call_fn<F: Fn() -> ()>(f: &F) { | ^^^^^^^^^^ required by this bound in `call_fn` help: consider further restricting this bound | 5 | fn call_any<F: std::any::Any + Fn()>(f: &F) { | ++++++ ```
2024-05-29Make `body_owned_by` return the body directly.Oli Scherer-7/+25
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-29fix non-existing ToPredicate trait errorDaria Sukhonina-2/+2
2024-05-29Optimize async drop glue for some old typesDaria Sukhonina-79/+112
2024-05-29Start implementing needs_async_drop and relatedDaria Sukhonina-90/+170