about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
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-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
2024-05-29Rollup merge of #125633 - RalfJung:miri-no-copy, r=saethlin许杰友 Jieyou Xu (Joe)-22/+21
miri: avoid making a full copy of all new allocations Hopefully fixes https://github.com/rust-lang/miri/issues/3637 r? ``@saethlin``
2024-05-29Rollup merge of #124251 - scottmcm:unop-ptr-metadata, r=oli-obk许杰友 Jieyou Xu (Joe)-1/+34
Add an intrinsic for `ptr::metadata` The follow-up to #123840, so we can remove `PtrComponents` and `PtrRepr` from libcore entirely (well, after a bootstrap update). As discussed in <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/.60ptr_metadata.60.20in.20MIR/near/435637808>, this introduces `UnOp::PtrMetadata` taking a raw pointer and returning the associated metadata value. By no longer going through a `union`, this should also help future PRs better optimize pointer operations. r? ``@oli-obk``
2024-05-28Auto merge of #125665 - matthiaskrgr:rollup-srkx0v1, r=matthiaskrgrbors-0/+7
Rollup of 5 pull requests Successful merges: - #117671 (NVPTX: Avoid PassMode::Direct for args in C abi) - #125573 (Migrate `run-make/allow-warnings-cmdline-stability` to `rmake.rs`) - #125590 (Add a "Setup Python" action for github-hosted runners and remove unnecessary `CUSTOM_MINGW` environment variable) - #125598 (Make `ProofTreeBuilder` actually generic over `Interner`) - #125637 (rustfmt fixes) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-28Add an intrinsic for `ptr::metadata`Scott McMurray-1/+34
2024-05-28Rollup merge of #125598 - compiler-errors:proof-tree-builder, r=lcnrMatthias Krüger-0/+7
Make `ProofTreeBuilder` actually generic over `Interner` Self-explanatory. Also renamed `ecx.tcx()` to `ecx.interner()`. r? lcnr
2024-05-28Auto merge of #122662 - Mark-Simulacrum:optional-drop, r=bjorn3bors-4/+8
Omit non-needs_drop drop_in_place in vtables This replaces the drop_in_place reference with null in vtables. On librustc_driver.so, this drops about ~17k (11%) dynamic relocations from the output, since many vtables can now be placed in read-only memory, rather than having a relocated pointer included. This makes a tradeoff by adding a null check at vtable call sites. I'm not sure that's readily avoidable without changing the vtable format (e.g., so that we can use a pc-relative relocation instead of an absolute address, and avoid the dynamic relocation that way). But it seems likely that the check is cheap at runtime. Accepted MCP: https://github.com/rust-lang/compiler-team/issues/730
2024-05-28Make ProofTreeBuilder actually generic over internerMichael Goulet-0/+7
2024-05-28Cache whether a body has inline constsOli Scherer-0/+1
2024-05-28Create const block DefIds in typeck instead of ast loweringOli Scherer-9/+17
2024-05-28eagerly normalize when adding goalslcnr-6/+3
2024-05-27miri: avoid making a full copy of all new allocationsRalf Jung-22/+21
2024-05-27Omit non-needs_drop drop_in_place in vtablesMark Rousskov-4/+8
This replaces the drop_in_place reference with null in vtables. On librustc_driver.so, this drops about ~17k dynamic relocations from the output, since many vtables can now be placed in read-only memory, rather than having a relocated pointer included. This makes a tradeoff by adding a null check at vtable call sites. That's hard to avoid without changing the vtable format (e.g., to use a pc-relative relocation instead of an absolute address, and avoid the dynamic relocation that way). But it seems likely that the check is cheap at runtime.
2024-05-27Rollup merge of #125616 - RalfJung:mir-validate-downcast-projection, ↵Matthias Krüger-2/+2
r=compiler-errors MIR validation: ensure that downcast projection is followed by field projection Cc https://github.com/rust-lang/rust/issues/120369
2024-05-27MIR validation: ensure that downcast projection is followed by field projectionRalf Jung-2/+2
2024-05-27Rollup merge of #125597 - compiler-errors:early-binder, r=jackh726Guillaume Gomez-643/+106
Uplift `EarlyBinder` into `rustc_type_ir` We also need to give `EarlyBinder` a `'tcx` param, so that we can carry the `Interner` in the `EarlyBinder` too. This is necessary because otherwise we have an unconstrained `I: Interner` parameter in many of the `EarlyBinder`'s inherent impls. I also generally think that this is desirable to have, in case we later want to track some state in the `EarlyBinder`. r? lcnr
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-34/+21
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666. See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
2024-05-27Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=compiler-errorsbors-39/+30
Remove `DefId` from `EarlyParamRegion` Currently we represent usages of `Region` parameters via the `ReEarlyParam` or `ReLateParam` variants. The `ReEarlyParam` is effectively equivalent to `TyKind::Param` and `ConstKind::Param` (i.e. it stores a `Symbol` and a `u32` index) however it also stores a `DefId` for the definition of the lifetime parameter. This was used in roughly two places: - Borrowck diagnostics instead of threading the appropriate `body_id` down to relevant locations. Interestingly there were already some places that had to pass down a `DefId` manually. - Some opaque type checking logic was using the `DefId` field to track captured lifetimes I've split this PR up into a commit for generate rote changes to diagnostics code to pass around a `DefId` manually everywhere, and another commit for the opaque type related changes which likely require more careful review as they might change the semantics of lints/errors. Instead of manually passing the `DefId` around everywhere I previously tried to bundle it in with `TypeErrCtxt` but ran into issues with some call sites of `infcx.err_ctxt` being unable to provide a `DefId`, particularly places involved with trait solving and normalization. It might be worth investigating adding some new wrapper type to pass this around everywhere but I think this might be acceptable for now. This pr also has the effect of reducing the size of `EarlyParamRegion` from 16 bytes -> 8 bytes. I wouldn't expect this to have any direct performance improvement however, other variants of `RegionKind` over `8` bytes are all because they contain a `BoundRegionKind` which is, as far as I know, mostly there for diagnostics. If we're ever able to remove this it would shrink the `RegionKind` type from `24` bytes to `12` (and with clever bit packing we might be able to get it to `8` bytes). I am curious what the performance impact would be of removing interning of `Region`'s if we ever manage to shrink `RegionKind` that much. Sidenote: by removing the `DefId` the `Debug` output for `Region` has gotten significantly nicer. As an example see this opaque type debug print before vs after this PR: `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0, T, DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0])` `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), ['a/#0, T, 'a/#0])` r? `@compiler-errors` (I would like someone who understands the opaque type setup to atleast review the type system commit, but the rest is likely reviewable by anyone)
2024-05-26Use EarlyBinder in rustc_type_ir, simplify importsMichael Goulet-2/+2
2024-05-26Uplift EarlyBinderMichael Goulet-606/+50
2024-05-26Give EarlyBinder a tcx parameterMichael Goulet-80/+99
We are gonna need it to uplift EarlyBinder
2024-05-25Rollup merge of #125510 - lcnr:change-proof-trees-to-be-shallow, ↵Matthias Krüger-5/+9
r=compiler-errors remove proof tree formatting, make em shallow Debugging via tracing `RUSTC_LOG=rustc_trait_selection::solve=debug` is now imo slightly more readable then the actual proof tree formatter. Removing everything that's not needed for the `analyse` visitor allows us to remove a bunch of code. I personally believe that we should continue to use tracing over proof trees for debugging: - it eagerly prints, allowing us to debug ICEs - the proof tree builder ends up going out of sync with the actual runtime behavior, which is confusing - using shallow proof trees is a lot more performant as we frequently do not recurse into all nested goals when using an analyse visitor - this allows us to clean up the implementation and remove some code r? ```@compiler-errors```
2024-05-25Rollup merge of #125451 - oli-obk:const_type_mismatch, r=compiler-errorsMatthias Krüger-9/+0
Fail relating constants of different types fixes #121585 fixes #121858 fixes #124151 I gave this several attempts before, but we lost too many important diagnostics until I managed to make compilation never bail out early. We have reached this point, so now we can finally fix all those ICEs by bubbling up an error instead of continueing when we encounter a bug.
2024-05-25Auto merge of #124187 - compiler-errors:self-ctor, r=petrochenkovbors-28/+0
Warn (or error) when `Self` ctor from outer item is referenced in inner nested item This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned https://github.com/rust-lang/rust/pull/117246#discussion_r1374648388. This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do. This also reverts part of https://github.com/rust-lang/rust/pull/117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.
2024-05-24remove proof tree formatter, make em shallowlcnr-5/+9
2024-05-24Remove `DefId` from `EarlyParamRegion` (tedium/diagnostics)Boxy-35/+8
2024-05-24Remove `DefId` from `EarlyParamRegion` (type system)Boxy-4/+16
2024-05-24docsBoxy-0/+6