Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hygiene: test macros with no_implicit_prelude #70

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/lib.rs
Expand Up @@ -154,7 +154,7 @@ macro_rules! assert_eq {
match (&($left), &($right)) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
panic!("assertion failed: `(left == right)`\
::std::panic!("assertion failed: `(left == right)`\
\n\
\n{}\
\n",
Expand All @@ -167,7 +167,7 @@ macro_rules! assert_eq {
match (&($left), &($right)) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
panic!("assertion failed: `(left == right)`: {}\
::std::panic!("assertion failed: `(left == right)`: {}\
\n\
\n{}\
\n",
Expand Down Expand Up @@ -213,11 +213,11 @@ macro_rules! assert_ne {
match (&($left), &($right)) {
(left_val, right_val) => {
if *left_val == *right_val {
let left_dbg = format!("{:?}", &*left_val);
let right_dbg = format!("{:?}", &*right_val);
let left_dbg = ::std::format!("{:?}", &*left_val);
let right_dbg = ::std::format!("{:?}", &*right_val);
if left_dbg != right_dbg {

panic!("assertion failed: `(left != right)`{}{}\
::std::panic!("assertion failed: `(left != right)`{}{}\
\n\
\n{}\
\n{}: According to the `PartialEq` implementation, both of the values \
Expand All @@ -233,7 +233,7 @@ macro_rules! assert_ne {
.paint("Note"))
}

panic!("assertion failed: `(left != right)`{}{}\
::std::panic!("assertion failed: `(left != right)`{}{}\
\n\
\n{}:\
\n{:#?}\
Expand All @@ -251,8 +251,11 @@ macro_rules! assert_ne {

#[cfg(test)]
#[allow(clippy::eq_op)]
#[no_implicit_prelude]
mod test {
mod assert_eq {
use ::std::string::{String, ToString};

#[test]
fn passes() {
let a = "some value";
Expand Down Expand Up @@ -342,6 +345,8 @@ mod test {
}

mod assert_ne {
use ::std::string::{String, ToString};

#[test]
fn passes() {
let a = "a";
Expand Down Expand Up @@ -442,11 +447,11 @@ mod test {
use ::std::fmt;
impl fmt::Debug for Foo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:.1?}", self.0)
::std::write!(f, "{:.1?}", self.0)
}
}

impl PartialEq for Foo {
impl ::std::cmp::PartialEq for Foo {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
Expand Down