Disable nightly-only tests on non nightly compiler
diff --git a/build.rs b/build.rs
index 1b71593..644bf75 100644
--- a/build.rs
+++ b/build.rs
@@ -6,22 +6,31 @@
 // opening a GitHub issue if your build environment requires some way to enable
 // these cfgs other than by executing our build script.
 fn main() {
-    let minor = match rustc_minor_version() {
-        Some(minor) => minor,
+    let compiler = match rustc_version() {
+        Some(compiler) => compiler,
         None => return,
     };
 
-    if minor >= 19 {
+    if compiler.minor >= 19 {
         println!("cargo:rustc-cfg=syn_can_use_thread_id");
     }
 
     // Macro modularization allows re-exporting the `quote!` macro in 1.30+.
-    if minor >= 30 {
+    if compiler.minor >= 30 {
         println!("cargo:rustc-cfg=syn_can_call_macro_by_path");
     }
+
+    if !compiler.nightly {
+        println!("cargo:rustc-cfg=syn_disable_nightly_tests");
+    }
 }
 
-fn rustc_minor_version() -> Option<u32> {
+struct Compiler {
+    minor: u32,
+    nightly: bool,
+}
+
+fn rustc_version() -> Option<Compiler> {
     let rustc = match env::var_os("RUSTC") {
         Some(rustc) => rustc,
         None => return None,
@@ -47,5 +56,13 @@
         None => return None,
     };
 
-    u32::from_str(next).ok()
+    let minor = match u32::from_str(next) {
+        Ok(minor) => minor,
+        Err(_) => return None,
+    };
+
+    Some(Compiler {
+        minor: minor,
+        nightly: version.contains("nightly"),
+    })
 }
diff --git a/tests/test_generics.rs b/tests/test_generics.rs
index 1bd15f3..74771d5 100644
--- a/tests/test_generics.rs
+++ b/tests/test_generics.rs
@@ -1,3 +1,4 @@
+#![cfg(not(syn_disable_nightly_tests))]
 #![recursion_limit = "1024"]
 #![feature(rustc_private)]
 
diff --git a/tests/test_grouping.rs b/tests/test_grouping.rs
index 887ac48..a2357e9 100644
--- a/tests/test_grouping.rs
+++ b/tests/test_grouping.rs
@@ -1,3 +1,4 @@
+#![cfg(not(syn_disable_nightly_tests))]
 #![recursion_limit = "1024"]
 #![feature(rustc_private)]
 
diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs
index 71017b6..f516b40 100644
--- a/tests/test_precedence.rs
+++ b/tests/test_precedence.rs
@@ -1,3 +1,4 @@
+#![cfg(not(syn_disable_nightly_tests))]
 #![recursion_limit = "1024"]
 #![feature(rustc_private)]
 
diff --git a/tests/test_round_trip.rs b/tests/test_round_trip.rs
index 4c7886a..bf1ee1c 100644
--- a/tests/test_round_trip.rs
+++ b/tests/test_round_trip.rs
@@ -1,3 +1,4 @@
+#![cfg(not(syn_disable_nightly_tests))]
 #![recursion_limit = "1024"]
 #![feature(rustc_private)]