From f0a7d8e2bd5a878ef65b34406637c1032507a675 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 16 Jan 2018 19:31:15 +0100 Subject: [PATCH] Add incremental-fulldeps test suite and regression test for #47290. --- src/bootstrap/check.rs | 5 +++ .../auxiliary/incremental_proc_macro_aux.rs | 31 +++++++++++++++++++ .../incremental_proc_macro.rs | 27 ++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs create mode 100644 src/test/incremental-fulldeps/incremental_proc_macro.rs diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index ed110762cb3..ecaf4d0c08c 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -568,6 +568,11 @@ static HOST_COMPILETESTS: &[Test] = &[ mode: "compile-fail", suite: "compile-fail-fulldeps", }, + Test { + path: "src/test/incremental-fulldeps", + mode: "incremental", + suite: "incremental-fulldeps", + }, Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" }, Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" }, diff --git a/src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs b/src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs new file mode 100644 index 00000000000..e9f9ba86f23 --- /dev/null +++ b/src/test/incremental-fulldeps/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 or the MIT license +// , 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-fulldeps/incremental_proc_macro.rs b/src/test/incremental-fulldeps/incremental_proc_macro.rs new file mode 100644 index 00000000000..e4345070853 --- /dev/null +++ b/src/test/incremental-fulldeps/incremental_proc_macro.rs @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:incremental_proc_macro_aux.rs +// ignore-stage1 +// revisions: cfail1 cfail2 +// must-compile-successfully + +// 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 +}