about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2021-09-09as casts and block exprsEllen-2/+2
2021-09-09WIP stateEllen-0/+1
2021-09-08Auto merge of #80522 - cjgillot:borrowcrate, r=oli-obkbors-6/+2327
Split rustc_mir The `rustc_mir` crate is the second largest in the compiler. This PR splits it up into 5 crates: - rustc_borrowck; - rustc_const_eval; - rustc_mir_dataflow; - rustc_mir_transform; - rustc_monomorphize.
2021-09-07Don't move ?Trait bounds to param bounds if they're in where clausesjackh726-9/+3
2021-09-07Rename rustc_mir to rustc_const_eval.Camille GILLOT-6/+6
2021-09-07Move the dataflow framework to its own crate.Camille GILLOT-0/+2321
2021-09-07Auto merge of #88689 - Aaron1011:confused-std-resolver, r=cjgillotbors-0/+3
Move `confused_type_with_std_module` to `ResolverOutputs` This eliminates untracked global state from `Session`.
2021-09-06Auto merge of #83214 - cjgillot:dep-map, r=michaelwoeristerbors-1/+4
Mmap the incremental data instead of reading it. Instead of reading the full incremental state using `fs::read_file`, we memmap it using a private read-only file-backed map. This allows the system to reclaim any memory we are not using, while ensuring we are not polluted by outside modifications to the file. Suggested in https://github.com/rust-lang/rust/pull/83036#issuecomment-800458082 by `@bjorn3`
2021-09-06Move `confused_type_with_std_module` to `ResolverOutputs`Aaron Hill-0/+3
This eliminates untracked global state from `Session`.
2021-09-06Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebankbors-0/+1
Fix #88256 remove duplicated diagnostics Fix #88256
2021-09-05Auto merge of #88435 - cjgillot:no-walk-crate, r=Aaron1011bors-3/+20
Avoid invoking the hir_crate query to traverse the HIR Walking the HIR tree is done using the `hir_crate` query. However, this is unnecessary, since `hir_owner(CRATE_DEF_ID)` provides the same information. Since depending on `hir_crate` forces dependents to always be executed, this leads to unnecessary work. By splitting HIR and attributes visits, we can avoid an edge to `hir_crate` when trying to visit the HIR tree.
2021-09-05Auto merge of #88552 - nbdd0121:vtable, r=nagisabors-0/+6
Stop allocating vtable entries for non-object-safe methods Current a vtable entry is allocated for all associated fns, even if the method is not object-safe: https://godbolt.org/z/h7vx6f35T As a result, each vtable for `Iterator`' currently consumes 74 `usize`s. This PR stops allocating vtable entries for those methods, reducing vtable size of each `Iterator` vtable to 7 `usize`s. Note that this PR introduces will cause more invocations of `is_vtable_safe_method`. So a perf run might be needed. If result isn't favorable then we might need to query-ify `is_vtable_safe_method`.
2021-09-05Add query `own_existential_vtable_entries`Gary Guo-0/+6
2021-09-05Auto merge of #88499 - eddyb:layout-off, r=nagisabors-23/+100
Provide `layout_of` automatically (given tcx + param_env + error handling). After #88337, there's no longer any uses of `LayoutOf` within `rustc_target` itself, so I realized I could move the trait to `rustc_middle::ty::layout` and redesign it a bit. This is similar to #88338 (and supersedes it), but at no ergonomic loss, since there's no funky `C: LayoutOf<Ty = Ty>` -> `Ty: TyAbiInterface<C>` generic `impl` chain, and each `LayoutOf` still corresponds to one `impl` (of `LayoutOfHelpers`) for the specific context. After this PR, this is what's needed to get `trait LayoutOf` (with the `layout_of` method) implemented on some context type: * `TyCtxt`, via `HasTyCtxt` * `ParamEnv`, via `HasParamEnv` * a way to transform `LayoutError`s into the desired error type * an error type of `!` can be paired with having `cx.layout_of(...)` return `TyAndLayout` *without* `Result<...>` around it, such as used by codegen * this is done through a new `LayoutOfHelpers` trait (and so is specifying the type of `cx.layout_of(...)`) When going through this path (and not bypassing it with a manual `impl` of `LayoutOf`), the end result is that only the error case can be customized, the query itself and the success paths are guaranteed to be uniform. (**EDIT**: just noticed that because of the supertrait relationship, you cannot actually implement `LayoutOf` yourself, the blanket `impl` fully covers all possible context types that could ever implement it) Part of the motivation for this shape of API is that I've been working on querifying `FnAbi::of_*`, and what I want/need to introduce for that looks a lot like the setup in this PR - in particular, it's harder to express the `FnAbi` methods in `rustc_target`, since they're much more tied to `rustc` concepts. r? `@nagisa` cc `@oli-obk` `@bjorn3`
2021-09-05Change more x64 size checks to not apply to x32.Harald van Dijk-4/+4
Commit 95e096d6 changed a bunch of size checks already, but more have been added, so this fixes the new ones the same way: the various size checks that are conditional on target_arch = "x86_64" were not intended to apply to x86_64-unknown-linux-gnux32, so add target_pointer_width = "64" to the conditions.
2021-09-04Fix #88256, remove duplicated diagnosticyukang-0/+1
2021-09-03Auto merge of #88572 - matthewjasper:if-let-scoping-fix, r=oli-obkbors-0/+6
Fix drop handling for `if let` expressions MIR lowering for `if let` expressions is now more complicated now that `if let` exists in HIR. This PR adds a scope for the variables bound in an `if let` expression and then uses an approach similar to how we handle loops to ensure that we reliably drop the correct variables. Closes #88307 cc `@flip1995` `@richkadel` `@c410-f3r`
2021-09-03Auto merge of #88597 - cjgillot:lower-global, r=petrochenkovbors-8/+9
Move global analyses from lowering to resolution Split off https://github.com/rust-lang/rust/pull/87234 r? `@petrochenkov`
2021-09-02Rename walk_crate.Camille GILLOT-1/+1
2021-09-02Rollup merge of #88532 - ptrojahn:single_use, r=davidtwcoMara Bos-5/+2
Remove single use variables
2021-09-02Stop using walk_crate.Camille GILLOT-3/+20
2021-09-01Fix drop handling for `if let` expressionsMatthew Jasper-0/+6
MIR lowering for `if let` expressions is now more complicated now that `if let` exists in HIR. This PR adds a scope for the variables bound in an `if let` expression and then uses an approach similar to how we handle loops to ensure that we reliably drop the correct variables.
2021-09-02ty::layout: split `LayoutOf` into required and (blanket) provided halves.Eduard-Mihai Burtescu-4/+10
2021-09-02ty::layout: implement `layout_of` automatically as a default method.Eduard-Mihai Burtescu-11/+50
2021-09-02rustc_target: move `LayoutOf` to `ty::layout`.Eduard-Mihai Burtescu-17/+49
2021-09-01Compute proc_macros in resolutions.Camille GILLOT-0/+3
2021-09-01Compute all_traits_impls during resolution.Camille GILLOT-1/+3
2021-09-01Stop sorting bodies by span.Camille GILLOT-7/+3
The definition order is already close to the span order, and only differs in corner cases.
2021-09-01Auto merge of #88121 - camelid:better-recursive-alias-error, r=estebankbors-1/+12
Improve errors for recursive type aliases Fixes #17539.
2021-09-01Auto merge of #87688 - camsteffen:let-else, r=cjgillotbors-0/+3
Introduce `let...else` Tracking issue: #87335 The trickiest part for me was enforcing the diverging else block with clear diagnostics. Perhaps the obvious solution is to expand to `let _: ! = ..`, but I decided against this because, when a "mismatched type" error is found in typeck, there is no way to trace where in the HIR the expected type originated, AFAICT. In order to pass down this information, I believe we should introduce `Expectation::LetElseNever(HirId)` or maybe add `HirId` to `Expectation::HasType`, but I left that as a future enhancement. For now, I simply assert that the block is `!` with a custom `ObligationCauseCode`, and I think this is clear enough, at least to start. The downside here is that the error points at the entire block rather than the specific expression with the wrong type. I left a todo to this effect. Overall, I believe this PR is feature-complete with regard to the RFC.
2021-08-31Rollup merge of #86362 - ptrojahn:insert_vars_and_temps, r=jackh726Mara Bos-0/+5
Avoid cloning LocalDecls
2021-08-31Remove single use variablesPaul Trojahn-5/+2
2021-08-31Avoid cloning LocalDeclsPaul Trojahn-0/+5
2021-08-31Rollup merge of #88486 - bjorn3:better_arena_macro, r=jackh726Mara Bos-6/+6
Remove unused arena macro args
2021-08-30Enforce diverging let...elseCameron Steffen-0/+3
2021-08-30Remove unused arena macro argsbjorn3-6/+6
2021-08-30`feature(const_generics)` -> `feature(const_param_types)`lcnr-2/+2
2021-08-30remove lazy_normalization_constsEllen-1/+1
2021-08-30rename const_evaluatable_checked to generic_const_exprsEllen-2/+2
:sparkles:
2021-08-29Auto merge of #88337 - eddyb:field-failure-is-not-an-option, r=nagisabors-83/+108
rustc_target: `TyAndLayout::field` should never error. This refactor (making `TyAndLayout::field` return `TyAndLayout` without any `Result` around it) is based on a simple observation, regarding `TyAndLayout::field`: If `cx.layout_of(ty)` succeeds (for some `cx` and `ty`), then `.field(cx, i)` on the resulting `TyAndLayout` should *always* succeed in computing `cx.layout_of(field_ty)` (where `field_ty` is the type of the `i`th field of `ty`). The reason for this is that no matter which field is chosen, `cx.layout_of(field_ty)` *will have already been computed*, as part of computing `cx.layout_of(ty)`, as we cannot determine the layout of *any* type without considering the layouts of *all* of its fields. And so it should be fine to turn any errors into ICEs, since they likely indicate a `cx` mismatch, or some other edge case that is due to a compiler bug (as opposed to ever being an user-facing error). <hr/> Each commit should probably be reviewed separately, though note that there's some `where` clauses (in `rustc_target::abi::call::*`) that change in most commits. cc `@nagisa` `@oli-obk`
2021-08-30rustc_target: remove `LayoutOf` bound from `TyAbiInterface`.Eduard-Mihai Burtescu-24/+30
2021-08-30rustc_target: `TyAndLayout::field` should never error.Eduard-Mihai Burtescu-48/+53
2021-08-28Drop the query result memmap before serializing it back.Camille GILLOT-0/+2
2021-08-28Mmap the incremental data instead of reading it.Camille GILLOT-1/+2
2021-08-28Remove obsolete `MacroDef` variant of `OwnerNode`inquisitivecrystal-13/+0
2021-08-28Treat macros as HIR itemsinquisitivecrystal-25/+2
2021-08-27Auto merge of #88328 - fee1-dead:not-quite-const, r=oli-obkbors-26/+37
Introduce `~const` - [x] Removed `?const` and change uses of `?const` - [x] Added `~const` to the AST. It is gated behind const_trait_impl. - [x] Validate `~const` in ast_validation. - [x] Update UI Tests - [x] Add enum `BoundConstness` (With variants `NotConst` and `ConstIfConst` allowing future extensions) - [x] Adjust trait selection and pre-existing code to use `BoundConstness`. - [ ] Optional steps for this PR - [x] Fix #88155 - [x] ~~Do something with constness bounds in chalk~~ Must be done to rust-lang/chalk (just tried to refactor, there are a lot of errors to resolve :( ) - [ ] Adjust Error messages for `~const` bounds that can't be satisfied. r? `@oli-obk`
2021-08-27rustc_target: require `TyAbiInterface` in `LayoutOf`.Eduard-Mihai Burtescu-0/+14
2021-08-27rustc_target: rename `TyAndLayoutMethods` to `TyAbiInterface`.Eduard-Mihai Burtescu-4/+8
2021-08-27rustc_target: add lifetime parameter to `LayoutOf`.Eduard-Mihai Burtescu-13/+9