summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/context.rs
AgeCommit message (Collapse)AuthorLines
2023-04-12resolve: Pre-compute non-reexport module childrenVadim Petrochenkov-2/+23
Instead of repeating the same logic by walking HIR during metadata encoding. The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list. They can be encoded separately if this need ever arises. `module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead.
2023-04-09Fix some clippy::complexityNilstrieb-2/+2
2023-04-08rustc_middle: Remove `Option` from `module_reexports` queryVadim Petrochenkov-1/+1
2023-04-06Remove index from BrAnonJack Huey-8/+4
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-5/+3
The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-3/+3
2023-03-21LocalCrate keyMichael Goulet-3/+4
2023-03-21Use local key in providersMichael Goulet-10/+5
2023-03-16Rollup merge of #109151 - compiler-errors:debug-assert-alias, r=WaffleLapkinMatthias Krüger-0/+7
Assert def-kind is correct for alias types Make sure we're not constructing alias types for the wrong def-kind, at least for debug cases :sweat_smile:
2023-03-14Don't make projection tys out of anon constsMichael Goulet-1/+1
2023-03-14Assert def-kind is correct for alias typesMichael Goulet-0/+7
2023-03-13Don't opt_rpitit_info as a separate queryMichael Goulet-1/+1
2023-03-12Auto merge of #108700 - spastorino:new-rpitit-impl-side-2, r=compiler-errorsbors-0/+12
Make RPITITs simple cases work when using lower_impl_trait_in_trait_to_assoc_ty r? `@compiler-errors` It's probably best reviewed commit by commit.
2023-03-10Actually cache goalsMichael Goulet-0/+5
2023-03-08Auto merge of #108312 - michaelwoerister:hash-set-not-hash-stable, r=eholkbors-1/+4
Do not implement HashStable for HashSet (MCP 533) This PR removes all occurrences of `HashSet` in query results, replacing it either with `FxIndexSet` or with `UnordSet`, and then removes the `HashStable` implementation of `HashSet`. This is part of implementing [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), that is, removing the `HashStable` implementations of all collection types with unstable iteration order. The changes are mostly mechanical. The only place where additional sorting is happening is in Miri's override implementation of the `exported_symbols` query.
2023-03-06Add is_impl_trait_in_traitSantiago Pastorino-0/+8
2023-03-06Add tcx::lower_impl_trait_in_trait_to_assoc_ty to avoid accessing through ↵Santiago Pastorino-0/+4
sess.opts.unstable_opts
2023-03-05Auto merge of #108351 - petrochenkov:rmdit, r=cjgillotbors-5/+4
rustc_middle: Remove trait `DefIdTree` This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-04Rollup merge of #108405 - Nilstrieb:lazy-crate-name-optimization-fuel, ↵Dylan DPC-2/+1
r=WaffleLapkin Lazily compute crate name for consider_optimizing The extra query is unnecessary in the common case of not having fuel.
2023-03-03Match unmatched backticks in comments in compiler/est31-1/+1
2023-03-03Match unmatched backticks in compiler/ that are part of rustdocest31-2/+2
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-5/+4
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-01Use UnordSet instead of FxHashSet for names_imported_by_glob_use query.Michael Woerister-1/+4
2023-02-27Rollup merge of #108363 - cjgillot:unused-crate, r=WaffleLapkinMatthias Krüger-2/+0
Move the unused extern crate check back to the resolver. It doesn't have anything to do in `rustc_hir_typeck`.
2023-02-26Auto merge of #108375 - Zoxc:query-inline, r=cjgillotbors-0/+1
Add inlining attributes for query system functions These only have a single caller, but don't always get inlined.
2023-02-25Add inlining attributes for query system functionsJohn Kåre Alsaker-0/+1
2023-02-24Add `mk_canonical_var_infos_from_iter`.Nicholas Nethercote-0/+8
It's missing, and is useful in two places.
2023-02-24Rename `mk_{ty,region}` as `mk_{ty,region}_from_kind`.Nicholas Nethercote-30/+38
To discourage accidental use -- there are more specific `mk_*` functions for all `Ty` and `Region` kinds.
2023-02-24Rename many interner functions.Nicholas Nethercote-64/+70
(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-24Tweak the slice interners.Nicholas Nethercote-59/+24
All the slice interners have a wrapper that handles the empty slice case. We can instead handle this in the `slice_interners!` macro, avoiding the need for most of the wrappers, and allowing the interner functions to be renamed from `_intern_foos` to `intern_foos`. The two exceptions: - intern_predicates: I kept this wrapper because there's a FIXME comment about a possible future change. - intern_poly_existential_predicates: I kept this wrapper because it asserts that the slice is empty and sorted.
2023-02-23Lazily compute crate name for consider_optimizingNilstrieb-2/+1
The extra query is unnecessary in the common case of not having fuel.
2023-02-23Auto merge of #108369 - compiler-errors:ty-error-more, r=BoxyUwUbors-3/+3
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-6/+6
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-3/+3
2023-02-22Remove some resolver outputs.Camille GILLOT-2/+0
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-7/+2
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
2023-02-22Auto merge of #108300 - oli-obk:elsa, r=eholkbors-3/+2
Use a lock-free datastructure for source_span follow up to the perf regression in https://github.com/rust-lang/rust/pull/105462 The main regression is likely the CStore, but let's evaluate the perf impact of this on its own
2023-02-21Rollup merge of #108141 - spastorino:add_rpitit_queries, r=compiler-errorsDylan DPC-0/+4
Add rpitit queries This is part of the changes we are making to lower RPITITs as an associated type. The rest of the stuff will follow under a `-Z` flag. I still need to add comments to the code, explain stuff and also I'd need to avoid encoding in metadata when rpitit queries return `&[]` r? `@compiler-errors`
2023-02-21Use a lock-free datastructure for `source_span`Oli Scherer-3/+2
2023-02-21Associated type bounds in some places in the compilerMichael Goulet-6/+6
2023-02-20Run the resolver after TyCtxt constructionOli Scherer-0/+4
2023-02-20Make untracked.source_span lockable so that resolution can still write to it ↵Oli Scherer-2/+2
when using TyCtxt
2023-02-20Make untracked.cstore lockable so that resolution can still write to it when ↵Oli Scherer-10/+10
using TyCtxt
2023-02-17Make encode_attrs use opt_local_def_id_to_hir_id so we can feed it with None ↵Santiago Pastorino-0/+4
for definitions that have no HIR
2023-02-17Replace more `mk_foo` calls with `infer_foo`.Nicholas Nethercote-4/+4
2023-02-17Use `IntoIterator` for `mk_fn_sig`.Nicholas Nethercote-5/+10
This makes a lot of call sites nicer.
2023-02-17Clarify iterator interners.Nicholas Nethercote-41/+54
There are two traits, `InternAs` and `InternIteratorElement`. I found them confusing to use, particularly this: ``` pub fn mk_tup<I: InternAs<Ty<'tcx>, Ty<'tcx>>>(self, iter: I) -> I::Output { iter.intern_with(|ts| self.intern_tup(ts)) } ``` where I thought there might have been two levels of interning going on (there isn't) due to the `intern_with`/`InternAs` + `intern_tup` naming. And then I found the actual traits and impls themselves *very* confusing. - `InternAs` has a single impl, for iterators, with four type variables. - `InternAs` is only implemented for iterators because it wouldn't really make sense to implement for any other type. And you can't really understand the trait without seeing that single impl, which is suspicious. - `InternAs` is basically just a wrapper for `InternIteratorElement` which does all the actual work. - Neither trait actually does any interning. They just have `Intern` in their name because they are used *by* interning code. - There are no comments. So this commit improves things. - It removes `InternAs` completely. This makes the `mk_*` function signatures slightly more verbose -- two trait bounds instead of one -- but much easier to read, because you only need to understand one trait instead of two. - It renames `InternIteratorElement` as `CollectAndApply`. Likewise, it renames its method `intern_with` as `collect_and_apply`. These names describe better what's going on: we collect the iterator elements into a slice and then apply a function to the slice. - It adds comments, making clear that all this is all there just to provide an optimized version of `f(&iter.collect::<Vec<_>>())`. It took me a couple of attempts to come up with this commit. My initial attempt kept `InternAs` around, but renamed things and added comments, and I wasn't happy with it. I think this version is much better. The resulting code is shorter, despite the addition of the comments.
2023-02-17Remove the `InternIteratorElement` impl for `&'a T`.Nicholas Nethercote-1/+1
`InternIteratorElement` is a trait used to intern values produces by iterators. There are three impls, corresponding to iterators that produce different types: - One for `T`, which operates straightforwardly. - One for `Result<T, E>`, which is fallible, and will fail early with an error result if any of the iterator elements are errors. - One for `&'a T`, which clones the items as it iterates. That last one is bad: it's extremely easy to use it without realizing that it clones, which goes against Rust's normal "explicit is better" approach to cloning. So this commit just removes it. In practice, there weren't many use sites. For all but one of them `into_iter()` could be used, which avoids the need for cloning. And for the one remaining case `copied()` is used.
2023-02-17Clarify `mk_fn_sig` signature.Nicholas Nethercote-3/+4
Giving the item type a name `T` avoids duplication.
2023-02-17Replace `mk_foo` calls with `infer_foo` where possible.Nicholas Nethercote-1/+1
There are several `mk_foo`/`intern_foo` pairs, where the former takes an iterator and the latter takes a slice. (This naming convention is bad, but that's a fix for another PR.) This commit changes several `mk_foo` occurrences into `intern_foo`, avoiding the need for some `.iter()`/`.into_iter()` calls. Affected cases: - mk_type_list - mk_tup - mk_substs - mk_const_list