about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2023-02-28Remove the `capture_disjoint_fields` featureclubby789-6/+5
2023-02-27Auto merge of #108487 - cjgillot:no-typeck-mir, r=oli-obkbors-111/+105
Avoid invoking typeck from borrowck This PR attempts to reduce direct dependencies between typeck and MIR-related queries. The goal is to have all the information transit either through THIR or through dedicated queries that avoid depending on the whole `TypeckResults`. In a first commit, we store the type information that MIR building requires into THIR. This avoids edges between mir_built and typeck. In the second and third commit, we wrap informations around closures (upvars, kind origin and user-provided signature) to avoid borrowck depending on typeck information. There should be a single remaining borrowck -> typeck edge in the good path, due to inline consts.
2023-02-27Implement checked Shl/Shr at MIR building.Camille GILLOT-22/+63
2023-02-27Auto merge of #108493 - cjgillot:thir-print, r=compiler-errorsbors-22/+895
Move THIR printing to rustc_mir_build. https://github.com/rust-lang/rust/pull/107451 increased the compilation time of `rustc_middle` by 10% = 3s. As https://github.com/rust-lang/rust/pull/107006 adds quite a lot of code to rustc_middle, I suspect it to be the cause. This PR moves the THIR printing code to `rustc_mir_build`, where the query provider lives, in order to benefit from higher parallelism when compiling rustc.
2023-02-26Move THIR printing to rustc_mir_build.Camille GILLOT-22/+895
2023-02-26Access upvars through a query.Camille GILLOT-77/+74
2023-02-26Store the body type in THIR.Camille GILLOT-34/+31
2023-02-25Add ErrorGuaranteed to HIR ExprKind::ErrMichael Goulet-1/+1
2023-02-24Rename many interner functions.Nicholas Nethercote-13/+12
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-23Auto merge of #108369 - compiler-errors:ty-error-more, r=BoxyUwUbors-1/+1
Use `tcx.ty_error_with_guaranteed` in more places, rename variants 1. Use `ty_error_with_guaranteed` more so we don't delay so many span bugs 2. Rename `ty_error_with_guaranteed` to `ty_error`, `ty_error` to `ty_error_misc`. This is to incentivize using the former over the latter in cases where we already are witness to a `ErrorGuaranteed` token. Second commit is just name replacement, so the first commit can be reviewed on its own with more scrutiny.
2023-02-23Rollup merge of #108350 - compiler-errors:assoc-type-bound-dogfooding, r=oli-obkMatthias Krüger-1/+1
Use associated type bounds in some places in the compiler Use associated type bounds for some nested `impl Trait<Assoc = impl Trait2>` cases. I'm generally keen to introduce new lang features that are more mature into the compiler, but maybe let's see what others think? Side-note: I was surprised that the only use-cases of nested impl trait in the compiler are just iterator related?!
2023-02-22Rename ty_error_with_guaranteed to ty_error, ty_error to ty_error_miscMichael Goulet-1/+1
2023-02-22Use ty_error_with_guaranteed in many more placesMichael Goulet-1/+1
2023-02-22Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obkbors-2/+2
Remove type-traversal trait aliases #107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate. As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value. Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream). This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope. These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c624b9e3bbd7d8e07697e2e9f861a45b6. Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit. Let me know if you'd like it broken up. r? `@oli-obk`
2023-02-22Remove type-traversal trait aliasesAlan Egerton-2/+2
2023-02-22errors: generate typed identifiers in each crateDavid Wood-19/+25
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-21Associated type bounds in some places in the compilerMichael Goulet-1/+1
2023-02-17Replace more `mk_foo` calls with `infer_foo`.Nicholas Nethercote-3/+3
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-2/+2
in metadata
2023-02-16change usages of type_of to bound_type_ofKyle Matsuda-1/+1
2023-02-16Auto merge of #108127 - matthiaskrgr:rollup-kpzfc6j, r=matthiaskrgrbors-17/+8
Rollup of 7 pull requests Successful merges: - #106347 (More accurate spans for arg removal suggestion) - #108057 (Prevent some attributes from being merged with others on reexports) - #108090 (`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`) - #108092 (note issue for feature(packed_bundled_libs)) - #108099 (use chars instead of strings where applicable) - #108115 (Do not ICE on unmet trait alias bounds) - #108125 (Add new people to the compiletest review rotation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-16Replace some `then`s with some `then_some`sMaybe Waffle-1/+1
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-17/+8
2023-02-15Add specialized variants of `mk_region`.Nicholas Nethercote-1/+1
Much like there are specialized variants of `mk_ty`. This will enable some optimization in the next commit. Also rename the existing `re_error*` functions as `mk_re_error*`, for consistency.
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-6/+8
2023-02-02Put a DefId in AggregateKind.Camille GILLOT-2/+6
2023-01-30Use `Mutability::{is_mut, is_not}`Maybe Waffle-1/+1
2023-01-29Rollup merge of #107006 - b-naber:thir-tree, r=jackh726Matthias Krüger-0/+15
Output tree representation on thir-tree The current output of `-Zunpretty=thir-tree` is really cumbersome to work with, using an actual tree representation should make it easier to see what the thir looks like.
2023-01-28Remove `HirId -> LocalDefId` map from HIR.Camille GILLOT-3/+1
2023-01-27Restrict amount of ignored locals.Camille GILLOT-0/+1
2023-01-27Separate witness type computation from the generator transform.Camille GILLOT-2/+3
2023-01-26change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add ↵Kyle Matsuda-3/+1
EarlyBinder to fn_sig in metadata
2023-01-26replace usages of fn_sig query with bound_fn_sigKyle Matsuda-1/+3
2023-01-26previous thir unpretty output through thir-flatb-naber-0/+8
2023-01-26Auto merge of #107328 - matthiaskrgr:rollup-lfqwo0o, r=matthiaskrgrbors-53/+88
Rollup of 8 pull requests Successful merges: - #106904 (Preserve split DWARF files when building archives.) - #106971 (Handle diagnostics customization on the fluent side (for one specific diagnostic)) - #106978 (Migrate mir_build's borrow conflicts) - #107150 (`ty::tls` cleanups) - #107168 (Use a type-alias-impl-trait in `ObligationForest`) - #107189 (Encode info for Adt in a single place.) - #107322 (Custom mir: Add support for some remaining, easy to support constructs) - #107323 (Disable ConstGoto opt in cleanup blocks) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-26Rollup merge of #107322 - JakobDegen:custom-mir, r=tmiaskoMatthias Krüger-0/+14
Custom mir: Add support for some remaining, easy to support constructs Some documentation for previous changes and support for `Deinit`, checked binops, len, and array repetition r? ```@oli-obk``` or ```@tmiasko```
2023-01-26Rollup merge of #106978 - mejrs:mir_build3, r=davidtwcoMatthias Krüger-53/+74
Migrate mir_build's borrow conflicts This also changes the error message slightly, for two reasons: - I'm not a fan of saying "value borrowed, by `x`, here" - it simplifies the error implementation significantly.
2023-01-26Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obkbors-3/+3
Move format_args!() into AST (and expand it during AST lowering) Implements https://github.com/rust-lang/compiler-team/issues/541 This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier. This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`. This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-26Custom mir: Add support for some remaining, easy to support constructsJakob Degen-0/+14
2023-01-26output tree representation for thir-treeb-naber-1/+8
2023-01-26Rollup merge of #107085 - tmiasko:custom-mir-operators, r=oli-obkMatthias Krüger-0/+6
Custom MIR: Support binary and unary operations Lower binary and unary operations directly to corresponding unchecked MIR operations. Ultimately this might not be syntax we want, but it allows for experimentation in the meantime. r? ````@oli-obk```` ````@JakobDegen````
2023-01-23fix: use LocalDefId instead of HirId in trait resVincenzo Palazzo-1/+3
use LocalDefId instead of HirId in trait resolution to simplify the obligation clause resolution Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-01-20Auto merge of #107105 - matthiaskrgr:rollup-rkz9t7r, r=matthiaskrgrbors-0/+6
Rollup of 8 pull requests Successful merges: - #106783 (Recover labels written as identifiers) - #106973 (Don't treat closures from other crates as local) - #106979 (Document how to get the type of a default associated type) - #107053 (signal update string representation for haiku.) - #107058 (Recognise double-equals homoglyph) - #107067 (Custom MIR: Support storage statements) - #107076 (Added const-generic ui test case for issue #106419) - #107091 (Fix broken format strings in `infer.ftl`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-20Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstriebbors-26/+21
Remove some `ref` patterns from the compiler Previous PR: https://github.com/rust-lang/rust/pull/105368 r? `@Nilstrieb`
2023-01-19Custom MIR: Support binary and unary operationsTomasz Miąsko-0/+6
2023-01-19Custom MIR: Support storage statementsTomasz Miąsko-0/+6
2023-01-18Also remove `#![feature(control_flow_enum)]` where possibleScott McMurray-1/+0
2023-01-17Stop using `BREAK` & `CONTINUE` in compilerScott McMurray-3/+3
Switching them to `Break(())` and `Continue(())` instead. libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.
2023-01-17Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726Matthias Krüger-9/+9
Remove double spaces after dots in comments Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17Migrate mir_build's borrow conflictsmejrs-53/+74