From f38decc7253efed79c0015d7f11464d8bfb4212e Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Mon, 19 Dec 2022 15:16:03 +0100 Subject: [PATCH] Fix tests to compile without `proc-macro2` feature --- src/test_util.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test_util.rs b/src/test_util.rs index b156e27..fd284e9 100644 --- a/src/test_util.rs +++ b/src/test_util.rs @@ -1,5 +1,5 @@ use crate::*; -use std::{fmt::{Debug, Display}, convert::TryFrom}; +use std::fmt::{Debug, Display}; #[track_caller] @@ -39,12 +39,18 @@ pub(crate) fn assert_parse_ok_eq( } } +// This is not ideal, but to perform this check we need `proc-macro2`. So we +// just don't do anything if that feature is not enabled. +#[cfg(not(feature = "proc-macro2"))] +pub(crate) fn assert_roundtrip(_: T, _: &str) {} + +#[cfg(feature = "proc-macro2")] #[track_caller] pub(crate) fn assert_roundtrip(ours: T, input: &str) where - T: TryFrom + fmt::Debug + PartialEq + Clone, + T: std::convert::TryFrom + fmt::Debug + PartialEq + Clone, proc_macro2::Literal: From, - >::Error: std::fmt::Display, + >::Error: std::fmt::Display, { let pm_lit = input.parse::() .expect("failed to parse input as proc_macro2::Literal");