summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query/mod.rs
AgeCommit message (Collapse)AuthorLines
2023-03-03Match unmatched backticks in compiler/ that are part of rustdocest31-1/+1
2023-03-01Make associated_item_def_ids for traits use an unstable option to also ↵Santiago Pastorino-0/+11
return associated types for RPITITs
2023-03-01Add opt_rpitit_info querySantiago Pastorino-0/+8
2023-03-01Rollup merge of #108505 - Nilstrieb:further-unify-validity-intrinsics, ↵Matthias Krüger-2/+2
r=michaelwoerister Further unify validity intrinsics Also merges the inhabitedness check into the query to further unify the code paths. Depends on #108364
2023-02-27Auto merge of #108487 - cjgillot:no-typeck-mir, r=oli-obkbors-7/+3
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-27Rollup merge of #108363 - cjgillot:unused-crate, r=WaffleLapkinMatthias Krüger-3/+0
Move the unused extern crate check back to the resolver. It doesn't have anything to do in `rustc_hir_typeck`.
2023-02-27Unify all validity check intrinsicsNilstrieb-2/+2
Also merges the inhabitedness check into the query to further unify the code paths.
2023-02-26Wrap more into into closure_typeinfo query.Camille GILLOT-1/+1
2023-02-26Access upvars through a query.Camille GILLOT-7/+3
2023-02-23Unify validity checks into a single queryNilstrieb-6/+2
Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
2023-02-22Remove some resolver outputs.Camille GILLOT-3/+0
2023-02-21Rollup merge of #108141 - spastorino:add_rpitit_queries, r=compiler-errorsDylan DPC-4/+23
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-20Move the resolver into a queryOli Scherer-1/+13
2023-02-19Document associated_item methodsSantiago Pastorino-1/+6
2023-02-19Add associated_item_for_impl_trait_in_trait querySantiago Pastorino-0/+8
2023-02-19Add associated_items_for_impl_trait_in_trait querySantiago Pastorino-0/+7
2023-02-17Make encode_attrs use opt_local_def_id_to_hir_id so we can feed it with None ↵Santiago Pastorino-4/+3
for definitions that have no HIR
2023-02-17Auto merge of #108075 - WaffleLapkin:de-arena-allocates-you-OwO, r=Nilstriebbors-3/+2
Remove `arena_cache` modifier from `associated_item` query & copy `ty::AssocItem` instead of passing by ref r? `@ghost`
2023-02-17Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwUbors-1/+1
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-1/+1
in metadata
2023-02-17Rollup merge of #108133 - kylematsuda:earlybinder-cleanups, r=compiler-errorsMatthias Krüger-1/+1
Small cleanups around `EarlyBinder` Cleaning up a few things that were brought up by `@lcnr` in reviewing #106696: - [make `issue33140_self_ty` query return `Option<EarlyBinder<Ty>>`](https://github.com/rust-lang/rust/pull/106696#discussion_r1067821423) - [small style improvement](https://github.com/rust-lang/rust/pull/106696#discussion_r1067816772)
2023-02-16make issue33140_self_ty return Option<EarlyBinder<Ty>>Kyle Matsuda-1/+1
2023-02-16Rename some region-specific stuffMichael Goulet-3/+3
2023-02-15Auto merge of #108012 - compiler-errors:issue-107999, r=oli-obkbors-4/+4
Don't ICE in `might_permit_raw_init` if reference is polymorphic Emitting optimized MIR for a polymorphic function may require computing layout of a type that isn't (yet) known. This happens in the instcombine pass, for example. Let's fail gracefully in that condition. cc `@saethlin` fixes #107999
2023-02-15Copy `ty::AssocItem` all other the placeMaybe Waffle-1/+1
2023-02-15Remove `arena_cache` modifier from queries which return `Copy` typesMaybe Waffle-2/+1
2023-02-15Auto merge of #107940 - BoxyUwU:const_ty_assertion_use_semantic_equality, ↵bors-0/+7
r=compiler-errors use semantic equality for const param type equality assertion Fixes #107898 See added test for what caused this ICE --- The current in assertion in `relate.rs` is rather inadequate when keeping in mind future expansions to const generics: - it will ICE when there are infer vars in a projection in a const param ty - it will spurriously return false when either ty has infer vars because of using `==` instead of `infcx.at(..).eq` - i am also unsure if it would be possible with `adt_const_params` to craft a situation where the const param type is not wf causing `normalize_erasing_regions` to `bug!` when we would have emitted a diagnostic. This impl feels pretty Not Great to me although i am not sure what a better idea would be. - We have to have the logic behind a query because neither `relate.rs` or `combine.rs` have access to trait solving machinery (without evaluating nested obligations this assert will become _far_ less useful under lazy norm, which consts are already doing) - `relate.rs` does not have access to canonicalization machinery which is necessary in order to have types potentially containing infer vars in query arguments. We could possible add a method to `TypeRelation` to do this assertion rather than a query but to avoid implementing the same logic over and over we'd probably end up with the logic in a free function somewhere in `rustc_trait_selection` _anyway_ so I don't think that would be much better. We could also just remove this assertion, it should not actually be necessary for it to be present. It has caught some bugs in the past though so if possible I would like to keep it. r? `@compiler-errors`
2023-02-14Make permit_uninit/zero_init fallibleMichael Goulet-4/+4
2023-02-13rustdoc: Eliminate remaining uses of resolverVadim Petrochenkov-0/+5
2023-02-12rename query and use `NoSolution`Boxy-1/+1
2023-02-11make `relate`'s const ty assertion use semantic equalityBoxy-0/+7
2023-02-10Resolve documentation links in rustc and store the results in metadataVadim Petrochenkov-0/+12
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584 It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2023-02-08Change `arena_cache` to not alter the declared query resultJohn Kåre Alsaker-54/+55
2023-02-06Remove `arena_cache` modifier from `upstream_monomorphizations_for`Maybe Waffle-1/+0
2023-01-30Auto merge of #107463 - Dylan-DPC:rollup-6mq1li8, r=Dylan-DPCbors-0/+9
Rollup of 6 pull requests Successful merges: - #101569 (Don't re-export private/unstable ArgumentV1 from `alloc`.) - #106106 (Pass `branch.{branch}.remote=origin` to `git submodule update`) - #107146 (Make `unsizing_params_for_adt` into a query) - #107264 (Add option to include private items in library docs) - #107452 (Fix typo in `{Rc, Arc}::get_mut_unchecked` docs) - #107459 (end entry paragraph with a period (.)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-30Rollup merge of #107146 - compiler-errors:unsizing-params, r=cjgillotDylan DPC-0/+9
Make `unsizing_params_for_adt` into a query Addresses a FIXME in confirmation. r? ``@ghost``
2023-01-30Auto merge of #104429 - nnethercote:more-deriving-on-packed-structs, r=RalfJungbors-9/+0
More deriving on packed structs See [here](https://github.com/rust-lang/rust/pull/104429#issuecomment-1320909245) for the t-lang nomination summary, and [here](https://github.com/rust-lang/rust/pull/104429#issuecomment-1360077895) for the approval. r? `@RalfJung`
2023-01-30Allow more deriving on packed structs.Nicholas Nethercote-9/+0
Currently, deriving on packed structs has some non-trivial limitations, related to the fact that taking references on unaligned fields is UB. The current approach to field accesses in derived code: - Normal case: `&self.0` - In a packed struct that derives `Copy`: `&{self.0}` - In a packed struct that doesn't derive `Copy`: `&self.0` Plus, we disallow deriving any builtin traits other than `Default` for any packed generic type, because it's possible that there might be misaligned fields. This is a fairly broad restriction. Plus, we disallow deriving any builtin traits other than `Default` for most packed types that don't derive `Copy`. (The exceptions are those where the alignments inherently satisfy the packing, e.g. in a type with `repr(packed(N))` where all the fields have alignments of `N` or less anyway. Such types are pretty strange, because the `packed` attribute is not having any effect.) This commit introduces a new, simpler approach to field accesses: - Normal case: `&self.0` - In a packed struct: `&{self.0}` In the latter case, this requires that all fields impl `Copy`, which is a new restriction. This means that the following example compiles under the old approach and doesn't compile under the new approach. ``` #[derive(Debug)] struct NonCopy(u8); #[derive(Debug) #[repr(packed)] struct MyType(NonCopy); ``` (Note that the old approach's support for cases like this was brittle. Changing the `u8` to a `u16` would be enough to stop it working. So not much capability is lost here.) However, the other constraints from the old rules are removed. We can now derive builtin traits for packed generic structs like this: ``` trait Trait { type A; } #[derive(Hash)] #[repr(packed)] pub struct Foo<T: Trait>(T, T::A); ``` To allow this, we add a `T: Copy` bound in the derived impl and a `T::A: Copy` bound in where clauses. So `T` and `T::A` must impl `Copy`. We can now also derive builtin traits for packed structs that don't derive `Copy`, so long as the fields impl `Copy`: ``` #[derive(Hash)] #[repr(packed)] pub struct Foo(u32); ``` This includes types that hand-impl `Copy` rather than deriving it, such as the following, that show up in winapi-0.2: ``` #[derive(Clone)] #[repr(packed)] struct MyType(i32); impl Copy for MyType {} ``` The new approach is simpler to understand and implement, and it avoids the need for the `unsafe_derive_on_repr_packed` check. One exception is required for backwards-compatibility: we allow `[u8]` fields for now. There is a new lint for this, `byte_slice_in_packed_struct_with_derive`.
2023-01-29Rollup merge of #107006 - b-naber:thir-tree, r=jackh726Matthias Krüger-0/+7
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-29Auto merge of #106253 - nbdd0121:upcast, r=compiler-errorsbors-0/+3
Skip possible where_clause_object_safety lints when checking `multiple_supertrait_upcastable` Fix #106247 To achieve this, I lifted the `WhereClauseReferencesSelf` out from `object_safety_violations` and move it into `is_object_safe` (which is changed to a new query). cc `@dtolnay` r? `@compiler-errors`
2023-01-28Make unsizing_params_for_adt into a queryMichael Goulet-0/+9
2023-01-28Rename `is_object_safe` to `check_is_object_safe` to hint side effectsGary Guo-2/+2
2023-01-28Make `is_object_safe` a query and move lint_object_unsafe_trait call thereGary Guo-0/+3
2023-01-28Remove `HirId -> LocalDefId` map from HIR.Camille GILLOT-1/+1
2023-01-27Compute generator saved locals on MIR.Camille GILLOT-0/+4
2023-01-27Separate witness type computation from the generator transform.Camille GILLOT-0/+7
2023-01-26change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add ↵Kyle Matsuda-1/+1
EarlyBinder to fn_sig in metadata
2023-01-26previous thir unpretty output through thir-flatb-naber-0/+7
2023-01-26Auto merge of #106812 - oli-obk:output_filenames, r=petrochenkovbors-1/+2
make `output_filenames` a real query part of #105462 This may be a perf regression and is not obviously the right way forward. We may store this information in the resolver after freezing it for example.
2023-01-26Auto merge of #105582 - saethlin:instcombine-assert-inhabited, r=cjgillotbors-4/+4
InstCombine away intrinsic validity assertions This optimization (currently) fires 246 times on the standard library. It seems to fire hardly at all on the big crates in the benchmark suite. Interesting.