about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-10-06 16:26:16 +0900
committerGitHub <noreply@github.com>2020-10-06 16:26:16 +0900
commit552933b79d3927dc8df63389417982513156a5eb (patch)
treef770a439c36866d01c22f34d8e615e096fe3354d /src
parentcc908f3b7005eb9762f81148e3668603edd92003 (diff)
parent8d11f90a16fb374d68b4aae5486c3e12c74c63b7 (diff)
downloadrust-552933b79d3927dc8df63389417982513156a5eb.tar.gz
rust-552933b79d3927dc8df63389417982513156a5eb.zip
Rollup merge of #77591 - Aaron1011:fix/hygiene-def-scope, r=estebank
Record `expansion_that_defined` into crate metadata

Fixes #77523

Now that hygiene serialization is implemented, we also need to record
`expansion_that_defined` so that we properly handle a foreign
`SyntaxContext`.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/hygiene/auxiliary/def-site-async-await.rs7
-rw-r--r--src/test/ui/hygiene/auxiliary/opaque-hygiene.rs21
-rw-r--r--src/test/ui/hygiene/issue-77523-def-site-async-await.rs19
3 files changed, 47 insertions, 0 deletions
diff --git a/src/test/ui/hygiene/auxiliary/def-site-async-await.rs b/src/test/ui/hygiene/auxiliary/def-site-async-await.rs
new file mode 100644
index 00000000000..f7e9b801318
--- /dev/null
+++ b/src/test/ui/hygiene/auxiliary/def-site-async-await.rs
@@ -0,0 +1,7 @@
+// edition:2018
+
+extern crate opaque_hygiene;
+
+pub async fn serve() {
+    opaque_hygiene::make_it!();
+}
diff --git a/src/test/ui/hygiene/auxiliary/opaque-hygiene.rs b/src/test/ui/hygiene/auxiliary/opaque-hygiene.rs
new file mode 100644
index 00000000000..7730f91bd6a
--- /dev/null
+++ b/src/test/ui/hygiene/auxiliary/opaque-hygiene.rs
@@ -0,0 +1,21 @@
+// force-host
+// no-prefer-dynamic
+
+#![feature(proc_macro_quote)]
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+use proc_macro::{TokenStream, quote};
+
+#[proc_macro]
+pub fn make_it(input: TokenStream) -> TokenStream {
+    // `quote!` applies def-site hygiene
+    quote! {
+        trait Foo {
+            fn my_fn(&self) {}
+        }
+
+        impl<T> Foo for T {}
+        "a".my_fn();
+    }
+}
diff --git a/src/test/ui/hygiene/issue-77523-def-site-async-await.rs b/src/test/ui/hygiene/issue-77523-def-site-async-await.rs
new file mode 100644
index 00000000000..2af60ff6f53
--- /dev/null
+++ b/src/test/ui/hygiene/issue-77523-def-site-async-await.rs
@@ -0,0 +1,19 @@
+// build-pass
+// aux-build:opaque-hygiene.rs
+// aux-build:def-site-async-await.rs
+
+// Regression test for issue #77523
+// Tests that we don't ICE when an unusual combination
+// of def-site hygiene and cross-crate monomorphization occurs.
+
+extern crate def_site_async_await;
+
+use std::future::Future;
+
+fn mk_ctxt() -> std::task::Context<'static> {
+    panic!()
+}
+
+fn main() {
+    Box::pin(def_site_async_await::serve()).as_mut().poll(&mut mk_ctxt());
+}