rust/src/tools
bors 7e11379f3b Auto merge of #74113 - lcnr:type-dependent-consts-2, r=eddyb
Support const args in type dependent paths (Take 2)

once more, except it is sound this time 🥰 previously #71154

-----
```rust
#![feature(const_generics)]

struct A;
impl A {
    fn foo<const N: usize>(&self) -> usize { N }
}
struct B;
impl B {
    fn foo<const N: usize>(&self) -> usize { 42 }
}

fn main() {
    let a = A;
    a.foo::<7>();
}
```
When calling `type_of` for generic const arguments, we now use the `TypeckTables` of the surrounding body to get the expected type.

This alone causes cycle errors though, as we now have `typeck_tables_of(main)` -> `...` ->
`type_of(main_ANON0 := 7)` -> `typeck_tables_of(main)`  (see https://github.com/rust-lang/rust/issues/68400#issuecomment-611760290)

To prevent this we must not call `type_of(const_arg)` during `typeck_tables_of`. This is achieved by
calling `type_of(param_def_id)` instead.

We have to somehow remember the `DefId` of the param through all of typeck, which is done using the
struct `ty::WithOptConstParam<DefId>`, which replaces `DefId` where needed and contains an `Option<DefId>` to
be able to store the const parameter in case it exists.

Queries which are currently cached on disk are split into two variants: `query_name`(cached) and `query_name_(of|for)_const_arg`(not cached), with `query_name_of_const_arg` taking a pair `(did, param_did): (LocalDefId, DefId)`.

For some queries a method `query_name_of_opt_const_arg` is added to `TyCtxt` which takes a `ty::WithOptConstParam` and either calls `query_name` or `query_name_of_const_arg` depending on the value of `const_param_did`.

r? @eddyb @varkor
2020-07-15 12:49:25 +00:00
..
build-manifest build dist for x86_64-unknown-illumos 2020-07-08 23:39:09 +00:00
cargo@43cf77395c Update cargo 2020-07-14 07:50:18 -07:00
cargotest Support configurable deny-warnings for all in-tree crates. 2020-06-25 21:17:21 -07:00
clippy WithOptConstParam::dummy -> WithOptConstParam::unknown 2020-07-15 13:06:47 +02:00
compiletest Avoid "blacklist" 2020-07-08 12:08:27 -04:00
error_index_generator Eliminate confusing "globals" terminology. 2020-07-09 14:11:44 +10:00
expand-yaml-anchors Support configurable deny-warnings for all in-tree crates. 2020-06-25 21:17:21 -07:00
linkchecker Avoid "whitelist" 2020-07-10 07:39:28 -04:00
miri@eee22ffdda update miri 2020-07-11 11:53:18 +02:00
remote-test-client Support configurable deny-warnings for all in-tree crates. 2020-06-25 21:17:21 -07:00
remote-test-server Support configurable deny-warnings for all in-tree crates. 2020-06-25 21:17:21 -07:00
rls@dd341d5307 Update rls 2020-07-02 15:58:27 -07:00
rust-analyzer@8b0983e89a ⬆️ rust-analyzer 2020-07-07 18:37:41 +02:00
rust-installer@d66f476b4d Update rust-installer to latest version 2020-07-07 14:15:51 -07:00
rustbook Update mdbook. 2020-06-26 07:47:19 -07:00
rustc-std-workspace-alloc Update version of rustc-std-workspace-* crates 2019-09-09 13:02:10 -07:00
rustc-std-workspace-core Update version of rustc-std-workspace-* crates 2019-09-09 13:02:10 -07:00
rustc-std-workspace-std Update version of rustc-std-workspace-* crates 2019-09-09 13:02:10 -07:00
rustc-workspace-hack Stop using old version of syn in rustc-workspace-hack 2020-06-22 13:29:39 -04:00
rustdoc Format the world 2019-12-22 17:42:47 -05:00
rustdoc-js rustdoc: Fix doc aliases with crate filtering 2020-06-23 09:27:37 +01:00
rustdoc-themes Format the world 2019-12-22 17:42:47 -05:00
rustfmt@c1e9b7b874 Bump Rustfmt and RLS 2020-06-19 15:38:14 +02:00
tidy Avoid "whitelist" 2020-07-10 07:39:28 -04:00
unicode-table-generator Migrate to numeric associated consts 2020-06-10 01:35:47 +00:00
unstable-book-gen Support configurable deny-warnings for all in-tree crates. 2020-06-25 21:17:21 -07:00
publish_toolstate.py Allow rust-highfive to label issues it creates. 2020-05-22 17:28:22 +02:00