about summary refs log tree commit diff
path: root/src/test/run-pass
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-20 22:37:06 +0000
committerbors <bors@rust-lang.org>2018-05-20 22:37:06 +0000
commit538fea57573ab8143e6c7a4f64ff1c2c03febd93 (patch)
tree207259a55a86a638a71a84ee5c1e55f765731037 /src/test/run-pass
parenta1d4a9503e236b9f49cbdb23d00893201c117b2a (diff)
parent26aad254875464ff352a4e18d16f668b5bd9b7cb (diff)
downloadrust-538fea57573ab8143e6c7a4f64ff1c2c03febd93.tar.gz
rust-538fea57573ab8143e6c7a4f64ff1c2c03febd93.zip
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
Diffstat (limited to 'src/test/run-pass')
-rw-r--r--src/test/run-pass/issue-50689.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/run-pass/issue-50689.rs b/src/test/run-pass/issue-50689.rs
new file mode 100644
index 00000000000..d437b9d88f4
--- /dev/null
+++ b/src/test/run-pass/issue-50689.rs
@@ -0,0 +1,17 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+enum Foo {
+    Bar = (|x: i32| { }, 42).1,
+}
+
+fn main() {
+    assert_eq!(Foo::Bar as usize, 42);
+}