Merge pull request #146 from dtolnay/doctest

Enable testing of documentation examples
diff --git a/.travis.yml b/.travis.yml
index b07a4d4..0234f4e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,11 @@
 
 matrix:
   include:
-    - rust: 1.15.0
+    - rust: 1.15.0 # oldest supported version
+      script: cargo build
+    - rust: 1.19.0 # first release with the --tests flag
+      script: cargo test --tests
+    - rust: 1.26.0 # first release on which our doc tests pass
     - rust: stable
     - rust: beta
     - rust: nightly
diff --git a/Cargo.toml b/Cargo.toml
index f15b987..da1c1e0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,9 +15,6 @@
 unstable API.
 """
 
-[lib]
-doctest = false
-
 [package.metadata.docs.rs]
 rustc-args = ["--cfg", "procmacro2_semver_exempt"]
 rustdoc-args = ["--cfg", "procmacro2_semver_exempt"]
@@ -25,6 +22,9 @@
 [dependencies]
 unicode-xid = "0.1"
 
+[dev-dependencies]
+quote = "0.6"
+
 [features]
 # When enabled: act as a shim around the nightly compiler's proc_macro crate.
 # This requires a nightly compiler.
@@ -38,3 +38,11 @@
 
 [badges]
 travis-ci = { repository = "alexcrichton/proc-macro2" }
+
+[patch.crates-io]
+# Our doc tests depend on quote which depends on proc-macro2. Without this line,
+# the proc-macro2 dependency of quote would be the released version of
+# proc-macro2. Quote would implement its traits for types from that proc-macro2,
+# meaning impls would be missing when tested against types from the local
+# proc-macro2.
+proc-macro2 = { path = "." }