rust/compiler/rustc_codegen_llvm/src
Matthias Krüger fd74c93403
Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakis
Type inference for inline consts

Fixes #78132
Fixes #78174
Fixes #81857
Fixes #89964

Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure.

Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts.

The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure.

With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME.

Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck).
cc `````@spastorino````` `````@lcnr`````
r? `````@nikomatsakis`````

`````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-09 19:00:40 +01:00
..
back Don't abort compilation after giving a lint error 2021-11-08 01:22:28 +00:00
coverageinfo Fix clippy lints 2021-10-01 23:17:19 +02:00
debuginfo Rename functions reflect that inline const is also "typeck_child" 2021-11-07 04:00:34 +00:00
llvm Initialize LLVM time trace profiler on each code generation thread 2021-11-05 17:47:11 +01:00
abi.rs Remove some minor checks for LLVM < 12 2021-11-05 10:26:16 -07:00
allocator.rs Include debug info for the allocator shim 2021-08-31 15:24:20 -07:00
asm.rs Properly check target_features not to trigger an assertion 2021-10-26 11:02:51 +09:00
attributes.rs Enable AutoFDO. 2021-10-06 19:36:52 +00:00
base.rs Make hash_result an Option. 2021-10-20 18:29:18 +02:00
builder.rs Remove some minor checks for LLVM < 12 2021-11-05 10:26:16 -07:00
callee.rs add platform support details file for armv7-unknown-linux-uclibc 2021-10-06 14:33:13 +00:00
common.rs Make abi::Abi Copy and remove a *lot* of refs 2021-09-09 10:41:19 +02:00
consts.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
context.rs Remove some minor checks for LLVM < 12 2021-11-05 10:26:16 -07:00
declare.rs Remove the decl arg from FnAbi::llvm_type 2021-08-05 10:58:55 -07:00
intrinsic.rs Add LLVM CFI support to the Rust compiler 2021-10-25 16:23:01 -07:00
lib.rs Initialize LLVM time trace profiler on each code generation thread 2021-11-05 17:47:11 +01:00
llvm_util.rs Auto merge of #90617 - tmiasko:time-trace-threads, r=wesleywiser 2021-11-06 09:55:50 +00:00
mono_item.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
type_.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
type_of.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
va_arg.rs Fix clippy lints 2021-10-01 23:17:19 +02:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00