]> git.lizzy.rs Git - rust.git/commit
Auto merge of #50851 - eddyb:the-only-constant, r=nikomatsakis
authorbors <bors@rust-lang.org>
Sun, 20 May 2018 22:37:06 +0000 (22:37 +0000)
committerbors <bors@rust-lang.org>
Sun, 20 May 2018 22:37:06 +0000 (22:37 +0000)
commit538fea57573ab8143e6c7a4f64ff1c2c03febd93
tree207259a55a86a638a71a84ee5c1e55f765731037
parenta1d4a9503e236b9f49cbdb23d00893201c117b2a
parent26aad254875464ff352a4e18d16f668b5bd9b7cb
Auto merge of #50851 - eddyb:the-only-constant, r=nikomatsakis

rustc: introduce {ast,hir}::AnonConst to consolidate so-called "embedded constants".

Previously, constants in array lengths and enum variant discriminants were "merely an expression", and had no separate ID for, e.g. type-checking or const-eval, instead reusing the expression's.

That complicated code working with bodies, because such constants were the only special case where the "owner" of the body wasn't the HIR parent, but rather the same node as the body itself.
Also, if the body happened to be a closure, we had no way to allocate a `DefId` for both the constant *and* the closure, leading to *several* bugs (mostly ICEs where type errors were expected).

This PR rectifies the situation by adding another (`{ast,hir}::AnonConst`) node around every such constant. Also, const generics are expected to rely on the new `AnonConst` nodes, as well (cc @varkor).
* fixes #48838
* fixes #50600
* fixes #50688
* fixes #50689
* obsoletes #50623

r? @nikomatsakis
src/librustc_resolve/lib.rs
src/librustc_resolve/macros.rs
src/libsyntax/parse/parser.rs