about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/collect.rs
AgeCommit message (Collapse)AuthorLines
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-8/+9
2023-07-04Replace `const_error` methods with `Const::new_error`Boxy-1/+1
2023-07-01Auto merge of #113154 - lcnr:better-probe-check, r=compiler-errorsbors-1/+1
change snapshot tracking in fulfillment contexts use the exact snapshot number to prevent misuse even when created inside of a snapshot
2023-06-29change snapshot tracking in fulfillment contextslcnr-1/+1
2023-06-20Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnrbors-0/+46
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code. Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above. The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits: https://github.com/rust-lang/rust/blob/2f896da247e0ee8f0bef7cd7c54cfbea255b9f68/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L61-L132 However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well. r? `@lcnr`
2023-06-20Merge attrs, better validationMichael Goulet-2/+44
2023-06-20Make rustc_deny_explicit_impl only local as wellMichael Goulet-1/+3
2023-06-20Add rustc_do_not_implement_via_objectMichael Goulet-0/+2
2023-06-11properly check associated consts for infer placeholdersMichael Goulet-11/+16
2023-06-01Rename `impl_defaultness` to `defaultness`Deadbeef-1/+1
2023-05-30Rollup merge of #112060 - lcnr:early-binder, r=jackh726Nilstrieb-2/+2
`EarlyBinder::new` -> `EarlyBinder::bind` for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR. r? `@jackh726` `@kylematsuda`
2023-05-29Rename `tcx.mk_re_*` => `Region::new_*`Maybe Waffle-1/+1
2023-05-29EarlyBinder::new -> EarlyBinder::bindlcnr-2/+2
2023-05-28Replace EarlyBinder(x) with EarlyBinder::new(x)Kyle Matsuda-2/+2
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-2/+2
2023-05-17Retire is_foreign_item query.Camille GILLOT-5/+0
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-1/+1
2023-05-12Require `impl Trait` in associated types to appear in method signaturesOli Scherer-1/+1
2023-05-03Rename things to reflect that they're not item specificMichael Goulet-2/+2
2023-04-26Make some region folders a little stricter.Nicholas Nethercote-2/+4
Because certain regions cannot occur in them.
2023-04-22Don't infer fn return type to return itselfMichael Goulet-11/+20
2023-04-20Remove opt_const_param_of.Camille GILLOT-1/+0
2023-04-16use matches! macro in more placesMatthias Krüger-4/+1
2023-04-11Split implied and super predicate queriesMichael Goulet-3/+4
2023-04-11Split super_predicates_that_define_assoc_type query from super_predicates_ofMichael Goulet-2/+3
2023-04-08Migrate `rustc_hir_analysis` to session diagnosticObei Sideg-110/+55
Part 3: Finishing `collect.rs` file
2023-03-22`HirId` to `LocalDefId` cleanuplcnr-3/+1
2023-03-21Use LocalDefId in ItemCtxtMichael Goulet-16/+12
2023-03-21Use local key in providersMichael Goulet-32/+29
2023-02-24Rename many interner functions.Nicholas Nethercote-1/+1
(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-22Rename ty_error_with_guaranteed to ty_error, ty_error to ty_error_miscMichael Goulet-1/+1
2023-02-17Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwUbors-3/+3
Switch to `EarlyBinder` for `type_of` query Part of the work to finish #105779 and implement https://github.com/rust-lang/types-team/issues/78. Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `type_of` query and removes `bound_type_of`. r? `@lcnr`
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-3/+3
in metadata
2023-02-16change usages of type_of to bound_type_ofKyle Matsuda-3/+3
2023-02-17Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillotMatthias Krüger-2/+2
Implement partial support for non-lifetime binders This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed. Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged. Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`) cc rust-lang/types-team#81 r? `@ghost`
2023-02-16Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errorsbors-7/+5
Optimize `mk_region` PR #107869 avoiding some interning under `mk_ty` by special-casing `Ty` variants with simple (integer) bodies. This PR does something similar for regions. r? `@compiler-errors`
2023-02-16Rename some region-specific stuffMichael Goulet-2/+2
2023-02-15Add specialized variants of `mk_region`.Nicholas Nethercote-7/+5
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-14add a `#[rustc_coinductive]` attributelcnr-5/+7
2023-02-03Make const/fn return params more suggestableMichael Goulet-20/+12
2023-01-30Rollup merge of #107125 - ↵Matthias Krüger-2/+1
WaffleLapkin:expect_an_item_in_your_hir_by_the_next_morning, r=Nilstrieb Add and use expect methods to hir. [The future has come](https://github.com/rust-lang/rust/pull/106090/files#r1070062462). r? `@Nilstrieb` tbh I'm not even sure if it's worth it
2023-01-28Rollup merge of #107100 - compiler-errors:issue-107087, r=lcnrMatthias Krüger-1/+5
Use proper `InferCtxt` when probing for associated types in astconv Fixes #107087
2023-01-26change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add ↵Kyle Matsuda-3/+4
EarlyBinder to fn_sig in metadata
2023-01-23Use proper InferCtxt when probing for associated types in astconvMichael Goulet-1/+5
2023-01-23fix: use LocalDefId instead of HirId in trait resVincenzo Palazzo-2/+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-20Add and use expect methods to hir.Maybe Waffle-2/+1
2023-01-20Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstriebbors-23/+21
Remove some `ref` patterns from the compiler Previous PR: https://github.com/rust-lang/rust/pull/105368 r? `@Nilstrieb`
2023-01-19Encode whether foreign opaques are TAITs or notMichael Goulet-0/+11
2023-01-17`rustc_hir_analysis`: remove `ref` patternsMaybe Waffle-8/+8
2023-01-17`rustc_hir_analysis`: some general code improvementsMaybe Waffle-15/+13