about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-11-18 19:21:47 -0800
committerGitHub <noreply@github.com>2016-11-18 19:21:47 -0800
commit49d3fd3b38cd838b241858baaaa6162666badba1 (patch)
treea09068946f0e895c38a65086ae7b9241eec30fce /src/test
parentac635aa95ba851898e125b047ad7b8d6a8fecf8e (diff)
parentc722a1eb9992ac76f5c3dd0aee36b8734d613f11 (diff)
downloadrust-49d3fd3b38cd838b241858baaaa6162666badba1.tar.gz
rust-49d3fd3b38cd838b241858baaaa6162666badba1.zip
Auto merge of #37787 - michaelwoerister:macro-def-ich, r=nikomatsakis
ICH: Handle MacroDef HIR instances.

As of recently, `hir::MacroDef` instances are exported in crate metadata, which means we also store their ICH when doing incremental compilation. Even though exported macro definitions should not (yet) interact with incremental compilation, the ICH is also used for the general purpose crate hash, where macros should be included.

This PR implements ICH computation for `MacroDef`. In theory, the ICH of these MacroDefs is less stable than that of other HIR items, since I opted to just call the compiler-generated `Hash::hash()` for `Token::Interpolated` variants. `Token::Interpolated` contains AST data structures and it would have been a lot of effort to expand ICH computation to the AST too. Since quasi-quoting is rarely used *and* it would only make a difference if incremental compilation was extended to macros, the simpler implementation seemed like a good idea.

This fixes the problem reported in https://github.com/rust-lang/rust/issues/37756. The test still fails because of broken codegen-unit support though.

r? @nikomatsakis
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/incr_comp_with_macro_export.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/compile-fail/incr_comp_with_macro_export.rs b/src/test/compile-fail/incr_comp_with_macro_export.rs
new file mode 100644
index 00000000000..eafef172303
--- /dev/null
+++ b/src/test/compile-fail/incr_comp_with_macro_export.rs
@@ -0,0 +1,23 @@
+// Copyright 2016 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.
+
+// compile-flags: -Zincremental=tmp/cfail-tests/incr_comp_with_macro_export
+// must-compile-successfully
+
+
+// This test case makes sure that we can compile with incremental compilation
+// enabled when there are macros exported from this crate. (See #37756)
+
+#![crate_type="rlib"]
+
+#[macro_export]
+macro_rules! some_macro {
+    ($e:expr) => ($e + 1)
+}