]> git.lizzy.rs Git - rust.git/commit
Auto merge of #104940 - cjgillot:query-feed-simple, r=oli-obk
authorbors <bors@rust-lang.org>
Wed, 30 Nov 2022 17:20:14 +0000 (17:20 +0000)
committerbors <bors@rust-lang.org>
Wed, 30 Nov 2022 17:20:14 +0000 (17:20 +0000)
commitc97b539e408ea353f4fde2f9251d598291fec421
tree1d6b1d663abdca782966f108c23cdee2c5ef296b
parent90711a86e5bdd4b0b65d293f0c2c48fd2db761b3
parent6477fd8fc3f30af2f691a69ab9ba772c65ee4f0b
Auto merge of #104940 - cjgillot:query-feed-simple, r=oli-obk

Allow to feed a value in another query's cache

Restricted version of https://github.com/rust-lang/rust/pull/96840

A query can create new definitions.

If those definitions are created after HIR lowering, they do not appear in the initial HIR map, and information for them cannot be provided in the normal pull-based way.

In order to make those definitions useful, we allow to feed values as query results for the newly created definition.

The API is as follows:
```rust
let feed = tcx.create_def(<parent def id>, <DefPathData>);
// `feed` is a TyCtxtFeed<'tcx>.

// Access the created definition.
let def_id: LocalDefId = feed.def_id;

// Assign `my_query(def_id) := my_value`.
feed.my_query(my_value).
```

This PR keeps the consistency checks introduced by https://github.com/rust-lang/rust/pull/96840, even if they are not reachable. This allows to extend the behaviour later without forgetting them.

cc `@oli-obk` `@spastorino`
compiler/rustc_middle/src/ty/context.rs