about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-07-14 20:27:56 +0000
committerbors <bors@rust-lang.org>2018-07-14 20:27:56 +0000
commitb486d3d13f1f8127614e1e182439c55fbac82964 (patch)
tree95c53051893b9f5663c7d2da7fcbef444e90fab2 /src/test
parentcbcd81a4a9312146942f8781376cabc109bfbcf0 (diff)
parent94c9ea4baee98c1d6579865d0e0d78a45927aa83 (diff)
downloadrust-b486d3d13f1f8127614e1e182439c55fbac82964.tar.gz
rust-b486d3d13f1f8127614e1e182439c55fbac82964.zip
Auto merge of #52326 - alexcrichton:tweak-proc-macro-expand, r=petrochenkov
rustc: Tweak expansion of #[proc_macro] for 2018

The syntactical expansion of `#[proc_macro]` and related attributes currently
contains absolute paths which conflicts with a lint for the 2018 edition,
causing issues like #52214. This commit puts a band-aid on the issue by ensuring
that procedural macros can also migrate to the 2018 edition for now by tweaking
the expansion based on what features are activated. A more long-term solution
would probably tweak the edition hygiene of spans, but this should do the trick
for now.

Closes #52214
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs b/src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs
new file mode 100644
index 00000000000..1068c058745
--- /dev/null
+++ b/src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs
@@ -0,0 +1,24 @@
+// 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.
+
+// compile-pass
+
+#![crate_type = "proc-macro"]
+#![deny(rust_2018_compatibility)]
+#![feature(rust_2018_preview)]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_derive(Template, attributes(template))]
+pub fn derive_template(input: TokenStream) -> TokenStream {
+    input
+}