summary refs log tree commit diff
path: root/src/test/incremental
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2018-03-20 22:19:52 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2018-11-30 06:15:20 +0200
commitfcca22cb4072097fc2cd1ae78ff84c7d59aacda2 (patch)
treeff9a90706e343251ea3b7e3f86e46f3401d089f1 /src/test/incremental
parentd3ab4a74efad266155fcd402c8d159af9e443e3d (diff)
downloadrust-fcca22cb4072097fc2cd1ae78ff84c7d59aacda2.tar.gz
rust-fcca22cb4072097fc2cd1ae78ff84c7d59aacda2.zip
tests: move all proc_macro tests from -fulldeps.
Diffstat (limited to 'src/test/incremental')
-rw-r--r--src/test/incremental/auxiliary/incremental_proc_macro_aux.rs31
-rw-r--r--src/test/incremental/auxiliary/issue_49482_macro_def.rs49
-rw-r--r--src/test/incremental/auxiliary/issue_49482_reexport.rs16
-rw-r--r--src/test/incremental/auxiliary/issue_54059.rs59
-rw-r--r--src/test/incremental/incremental_proc_macro.rs26
-rw-r--r--src/test/incremental/issue-49482.rs40
-rw-r--r--src/test/incremental/issue-54059.rs18
7 files changed, 239 insertions, 0 deletions
diff --git a/src/test/incremental/auxiliary/incremental_proc_macro_aux.rs b/src/test/incremental/auxiliary/incremental_proc_macro_aux.rs
new file mode 100644
index 00000000000..e9f9ba86f23
--- /dev/null
+++ b/src/test/incremental/auxiliary/incremental_proc_macro_aux.rs
@@ -0,0 +1,31 @@
+// 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.
+
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+// Add a function to shift DefIndex of registrar function
+#[cfg(cfail2)]
+fn foo() {}
+
+#[proc_macro_derive(IncrementalMacro)]
+pub fn derive(input: TokenStream) -> TokenStream {
+    #[cfg(cfail2)]
+    {
+        foo();
+    }
+
+    "".parse().unwrap()
+}
diff --git a/src/test/incremental/auxiliary/issue_49482_macro_def.rs b/src/test/incremental/auxiliary/issue_49482_macro_def.rs
new file mode 100644
index 00000000000..763c9eb138e
--- /dev/null
+++ b/src/test/incremental/auxiliary/issue_49482_macro_def.rs
@@ -0,0 +1,49 @@
+// 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.
+
+// no-prefer-dynamic
+
+#![crate_type="proc-macro"]
+#![allow(non_snake_case)]
+
+extern crate proc_macro;
+
+macro_rules! proc_macro_expr_impl {
+    ($(
+        $( #[$attr:meta] )*
+        pub fn $func:ident($input:ident: &str) -> String;
+    )+) => {
+        $(
+            $( #[$attr] )*
+            #[proc_macro_derive($func)]
+            pub fn $func(_input: ::proc_macro::TokenStream) -> ::proc_macro::TokenStream {
+                panic!()
+            }
+        )+
+    };
+}
+
+proc_macro_expr_impl! {
+    pub fn f1(input: &str) -> String;
+    pub fn f2(input: &str) -> String;
+    pub fn f3(input: &str) -> String;
+    pub fn f4(input: &str) -> String;
+    pub fn f5(input: &str) -> String;
+    pub fn f6(input: &str) -> String;
+    pub fn f7(input: &str) -> String;
+    pub fn f8(input: &str) -> String;
+    pub fn f9(input: &str) -> String;
+    pub fn fA(input: &str) -> String;
+    pub fn fB(input: &str) -> String;
+    pub fn fC(input: &str) -> String;
+    pub fn fD(input: &str) -> String;
+    pub fn fE(input: &str) -> String;
+    pub fn fF(input: &str) -> String;
+}
diff --git a/src/test/incremental/auxiliary/issue_49482_reexport.rs b/src/test/incremental/auxiliary/issue_49482_reexport.rs
new file mode 100644
index 00000000000..aa9aa3b58b9
--- /dev/null
+++ b/src/test/incremental/auxiliary/issue_49482_reexport.rs
@@ -0,0 +1,16 @@
+// 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.
+
+#[macro_use]
+extern crate issue_49482_macro_def;
+
+pub use issue_49482_macro_def::*;
+
+pub fn foo() {}
diff --git a/src/test/incremental/auxiliary/issue_54059.rs b/src/test/incremental/auxiliary/issue_54059.rs
new file mode 100644
index 00000000000..ec0d044d4bf
--- /dev/null
+++ b/src/test/incremental/auxiliary/issue_54059.rs
@@ -0,0 +1,59 @@
+// 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.
+
+// no-prefer-dynamic
+
+// check that having extern "C" functions in a proc macro doesn't crash.
+
+#![crate_type="proc-macro"]
+#![allow(non_snake_case)]
+
+extern crate proc_macro;
+
+macro_rules! proc_macro_tokenstream {
+    () => {
+        ::proc_macro::TokenStream
+    };
+}
+
+macro_rules! proc_macro_expr_impl {
+    ($(
+        $( #[$attr:meta] )*
+        pub fn $func:ident($input:ident: &str) -> String $body:block
+    )+) => {
+        $(
+            // Parses an input that looks like:
+            //
+            // ```
+            // #[allow(unused)]
+            // enum ProcMacroHack {
+            //     Input = (stringify!(ARGS), 0).1,
+            // }
+            // ```
+            $( #[$attr] )*
+            #[proc_macro_derive($func)]
+            pub fn $func(input: proc_macro_tokenstream!()) -> proc_macro_tokenstream!() {
+                unsafe { rust_dbg_extern_identity_u64(0); }
+                panic!()
+            }
+        )+
+    };
+}
+
+proc_macro_expr_impl! {
+    pub fn base2_impl(input: &str) -> String {
+        panic!()
+    }
+}
+
+#[link(name="rust_test_helpers")]
+extern "C" {
+    pub fn rust_dbg_extern_identity_u64(v: u64) -> u64;
+}
diff --git a/src/test/incremental/incremental_proc_macro.rs b/src/test/incremental/incremental_proc_macro.rs
new file mode 100644
index 00000000000..495f4ff0ed0
--- /dev/null
+++ b/src/test/incremental/incremental_proc_macro.rs
@@ -0,0 +1,26 @@
+// 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.
+
+// aux-build:incremental_proc_macro_aux.rs
+// revisions: cfail1 cfail2
+// compile-pass
+
+// This test makes sure that we still find the proc-macro registrar function
+// when we compile proc-macros incrementally (see #47292).
+
+#![crate_type = "rlib"]
+
+#[macro_use]
+extern crate incremental_proc_macro_aux;
+
+#[derive(IncrementalMacro)]
+pub struct Foo {
+    x: u32
+}
diff --git a/src/test/incremental/issue-49482.rs b/src/test/incremental/issue-49482.rs
new file mode 100644
index 00000000000..65e86e868bb
--- /dev/null
+++ b/src/test/incremental/issue-49482.rs
@@ -0,0 +1,40 @@
+// 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.
+
+// aux-build:issue_49482_macro_def.rs
+// aux-build:issue_49482_reexport.rs
+// revisions: rpass1
+
+extern crate issue_49482_reexport;
+
+pub trait KvStorage
+{
+    fn get(&self);
+}
+
+impl<K> KvStorage for Box<K>
+where
+    K: KvStorage + ?Sized,
+{
+    fn get(&self) {
+        (**self).get()
+    }
+}
+
+impl KvStorage for u32 {
+    fn get(&self) {}
+}
+
+fn main() {
+    /* force issue_49482_reexport to be loaded */
+    issue_49482_reexport::foo();
+
+    Box::new(2).get();
+}
diff --git a/src/test/incremental/issue-54059.rs b/src/test/incremental/issue-54059.rs
new file mode 100644
index 00000000000..2f4ea72b066
--- /dev/null
+++ b/src/test/incremental/issue-54059.rs
@@ -0,0 +1,18 @@
+// 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.
+
+// aux-build:issue_54059.rs
+// ignore-wasm32-bare no libc for ffi testing
+// ignore-windows - dealing with weird symbols issues on dylibs isn't worth it
+// revisions: rpass1
+
+extern crate issue_54059;
+
+fn main() {}