Skip to content

Commit

Permalink
revert core import for macro code
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbguy committed Nov 14, 2024
1 parent 9d671f9 commit 541cffe
Show file tree
Hide file tree
Showing 28 changed files with 86 additions and 87 deletions.
20 changes: 10 additions & 10 deletions rstest/src/magic_conversion.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub struct Magic<T>(pub core::marker::PhantomData<T>);
pub struct Magic<T>(pub std::marker::PhantomData<T>);

pub trait ViaParseDebug<'a, T> {
fn magic_conversion(&self, input: &'a str) -> T;
}

impl<'a, T> ViaParseDebug<'a, T> for &&Magic<T>
where
T: core::str::FromStr,
T::Err: core::fmt::Debug,
T: std::str::FromStr,
T::Err: std::fmt::Debug,
{
fn magic_conversion(&self, input: &'a str) -> T {
T::from_str(input).unwrap()
Expand All @@ -20,7 +20,7 @@ pub trait ViaParse<'a, T> {

impl<'a, T> ViaParse<'a, T> for &Magic<T>
where
T: core::str::FromStr,
T: std::str::FromStr,
{
fn magic_conversion(&self, input: &'a str) -> T {
match T::from_str(input) {
Expand All @@ -29,7 +29,7 @@ where
panic!(
"Cannot parse '{}' to get {}",
input,
core::any::type_name::<T>()
std::any::type_name::<T>()
);
}
}
Expand All @@ -49,21 +49,21 @@ impl<'a> ViaIdent<'a, &'a str> for &&Magic<&'a str> {
#[cfg(test)]
mod test {
use super::*;
use core::str::FromStr;
use std::str::FromStr;

#[test]
fn should_return_the_same_slice_string() {
assert_eq!(
"something",
(&&&Magic::<&str>(core::marker::PhantomData)).magic_conversion("something")
(&&&Magic::<&str>(std::marker::PhantomData)).magic_conversion("something")
);
}

#[test]
fn should_parse_via_parse_debug() {
assert_eq!(
42u32,
(&&&Magic::<u32>(core::marker::PhantomData)).magic_conversion("42")
(&&&Magic::<u32>(std::marker::PhantomData)).magic_conversion("42")
);
}

Expand All @@ -81,7 +81,7 @@ mod test {

assert_eq!(
"some",
(&&&Magic::<S>(core::marker::PhantomData))
(&&&Magic::<S>(std::marker::PhantomData))
.magic_conversion("some")
.0
);
Expand All @@ -99,6 +99,6 @@ mod test {
Err(E)
}
}
(&&&Magic::<MyTypeName>(core::marker::PhantomData)).magic_conversion("");
(&&&Magic::<MyTypeName>(std::marker::PhantomData)).magic_conversion("");
}
}
5 changes: 2 additions & 3 deletions rstest/src/timeout.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use core::time::Duration;
use std::{sync::mpsc, thread};
use std::{sync::mpsc, thread, time::Duration};

#[cfg(feature = "async-timeout")]
use futures::{select, Future, FutureExt};
Expand Down Expand Up @@ -52,7 +51,7 @@ mod tests {
mod async_version {

use super::*;
use core::time::Duration;
use std::time::Duration;

async fn delayed_sum(a: u32, b: u32, delay: Duration) -> u32 {
async_std::task::sleep(delay).await;
Expand Down
2 changes: 1 addition & 1 deletion rstest/tests/resources/fixture/default_conversion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rstest::{fixture, rstest};
use core::net::{Ipv4Addr, SocketAddr};
use std::net::{Ipv4Addr, SocketAddr};

struct MyType(String);
struct E;
Expand Down
4 changes: 2 additions & 2 deletions rstest/tests/resources/fixture/defined_return_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn j() -> i32 {

#[fixture(::default<impl Iterator<Item=(u32, i32)>>::partial_1<impl Iterator<Item=(I,i32)>>)]
pub fn fx<I, J>(i: I, j: J) -> impl Iterator<Item=(I, J)> {
core::iter::once((i, j))
std::iter::once((i, j))
}

#[test]
Expand All @@ -29,7 +29,7 @@ fn resolve_partial() {
#[default(impl Iterator<Item=(u32, i32)>)]
#[partial_1(impl Iterator<Item=(I,i32)>)]
pub fn fx_attrs<I, J>(i: I, j: J) -> impl Iterator<Item=(I, J)> {
core::iter::once((i, j))
std::iter::once((i, j))
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions rstest/tests/resources/fixture/dyn.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use rstest::*;

#[fixture]
fn dyn_box() -> Box<dyn Iterator<Item = i32>> {
Box::new(core::iter::once(42))
fn dyn_box() -> Box<dyn Iterator<Item=i32>> {
Box::new(std::iter::once(42))
}

#[fixture]
Expand Down
8 changes: 4 additions & 4 deletions rstest/tests/resources/fixture/errors_once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ async fn error_async_once_fixture() {

#[fixture]
#[once]
fn error_generics_once_fixture<T: core::fmt::Debug>() -> T {
fn error_generics_once_fixture<T: std::fmt::Debug>() -> T {
42
}

#[fixture]
#[once]
fn error_generics_once_fixture() -> impl Iterator<Item = u32> {
core::iter::once(42)
std::iter::once(42)
}

#[fixture]
#[once]
fn error_once_fixture_not_sync() -> core::cell::Cell<u32> {
core::cell::Cell::new(42)
fn error_once_fixture_not_sync() -> std::cell::Cell<u32> {
std::cell::Cell::new(42)
}
6 changes: 3 additions & 3 deletions rstest/tests/resources/fixture/impl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rstest::*;

#[fixture]
fn fx_base_impl_return() -> impl Iterator<Item=u32> { core::iter::once(42) }
fn fx_base_impl_return() -> impl Iterator<Item=u32> { std::iter::once(42) }

#[fixture]
fn fx_base_impl_input(mut fx_base_impl_return: impl Iterator<Item=u32>) -> u32 {
Expand All @@ -19,7 +19,7 @@ fn base_impl_input(mut fx_base_impl_input: u32) {
}

#[fixture]
fn fx_nested_impl_return() -> impl Iterator<Item=impl ToString> { core::iter::once(42) }
fn fx_nested_impl_return() -> impl Iterator<Item=impl ToString> { std::iter::once(42) }

#[fixture]
fn fx_nested_impl_input(mut fx_nested_impl_return: impl Iterator<Item=impl ToString>) -> String {
Expand All @@ -38,7 +38,7 @@ fn nested_impl_input(mut fx_nested_impl_input: String) {

#[fixture]
fn fx_nested_multiple_impl_return() -> (impl Iterator<Item=impl ToString>, impl ToString) {
(core::iter::once(42), 42i32)
(std::iter::once(42), 42i32)
}

#[fixture]
Expand Down
4 changes: 2 additions & 2 deletions rstest/tests/resources/rstest/cases/inject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use actix_rt;
use core::future::Future;
use rstest::*;
use actix_rt;
use std::future::Future;

#[rstest(expected, value,
case::pass(42, 42),
Expand Down
2 changes: 1 addition & 1 deletion rstest/tests/resources/rstest/convert_string_literal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::net::SocketAddr;
use rstest::*;
use std::net::SocketAddr;

#[rstest]
#[case(true, "1.2.3.4:42")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::net::SocketAddr;
use other_name::*;
use std::net::SocketAddr;

#[rstest]
#[case(true, "1.2.3.4:42")]
Expand Down
2 changes: 1 addition & 1 deletion rstest/tests/resources/rstest/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rstest::*;

enum E<'a> {
A(bool),
B(&'a core::cell::Cell<E<'a>>),
B(&'a std::cell::Cell<E<'a>>),
}

#[rstest]
Expand Down
2 changes: 1 addition & 1 deletion rstest/tests/resources/rstest/local_lifetime.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::cell::Cell;
use std::cell::Cell;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum E<'a> {
Expand Down
2 changes: 1 addition & 1 deletion rstest/tests/resources/rstest/matrix/inject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rstest::*;
use actix_rt;
use core::future::Future;
use std::future::Future;

#[rstest(
first => [1, 2],
Expand Down
2 changes: 1 addition & 1 deletion rstest/tests/resources/rstest/timeout.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rstest::*;
use core::time::Duration;
use std::time::Duration;

fn ms(ms: u32) -> Duration {
Duration::from_millis(ms.into())
Expand Down
2 changes: 1 addition & 1 deletion rstest/tests/resources/rstest/timeout_async.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::time::Duration;
use rstest::*;
use std::time::Duration;

fn ms(ms: u32) -> Duration {
Duration::from_millis(ms.into())
Expand Down
2 changes: 1 addition & 1 deletion rstest/tests/resources/rstest/timeout_other_name.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::time::Duration;
use other_name::*;
use std::time::Duration;

fn ms(ms: u32) -> Duration {
Duration::from_millis(ms.into())
Expand Down
6 changes: 3 additions & 3 deletions rstest_fixtures/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::fmt::Debug;
use std::fmt::Debug;

pub trait TearDown {
fn tear_down(self);
Expand Down Expand Up @@ -42,7 +42,7 @@ impl<T, G: TearDown> Fixture<T, G> {
}

impl<T: Debug, G: TearDown> Debug for Fixture<T, G> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
write!(f, "Fixture<{:?}>", self.inner)
}
}
Expand Down Expand Up @@ -76,7 +76,7 @@ impl<F: FnOnce()->()> From<F> for TearDownClosure<F> {
#[cfg(test)]
mod test {
use super::*;
use core::cell::RefCell;
use std::cell::RefCell;
use std::rc::Rc;

#[test]
Expand Down
14 changes: 7 additions & 7 deletions rstest_macros/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ pub(crate) fn fixture(test: &ItemFn, info: &FixtureInfo) -> TokenStream {

fn async_once<'a>(test: &'a ItemFn, info: &FixtureInfo) -> Errors<'a> {
match (test.sig.asyncness, info.arguments.get_once()) {
(Some(_asyncness), Some(once)) => Box::new(core::iter::once(syn::Error::new_spanned(
(Some(_asyncness), Some(once)) => Box::new(std::iter::once(syn::Error::new_spanned(
once,
"Cannot apply #[once] to async fixture.",
))),
_ => Box::new(core::iter::empty()),
_ => Box::new(std::iter::empty()),
}
}

Expand Down Expand Up @@ -79,11 +79,11 @@ fn has_some_generics(test: &ItemFn) -> bool {

fn generics_once<'a>(test: &'a ItemFn, info: &FixtureInfo) -> Errors<'a> {
match (has_some_generics(test), info.arguments.get_once()) {
(true, Some(once)) => Box::new(core::iter::once(syn::Error::new_spanned(
(true, Some(once)) => Box::new(std::iter::once(syn::Error::new_spanned(
once,
"Cannot apply #[once] on generic fixture.",
))),
_ => Box::new(core::iter::empty()),
_ => Box::new(std::iter::empty()),
}
}

Expand Down Expand Up @@ -156,14 +156,14 @@ macro_rules! composed_tuple {
};
}

impl core::ops::Deref for ErrorsVec {
impl std::ops::Deref for ErrorsVec {
type Target = Vec<syn::Error>;
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl core::ops::DerefMut for ErrorsVec {
impl std::ops::DerefMut for ErrorsVec {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
Expand Down Expand Up @@ -270,7 +270,7 @@ fn case_args_without_cases(params: &RsTestData) -> Errors {
.map(|a| syn::Error::new(a.span(), "No cases for this argument.")),
);
}
Box::new(core::iter::empty())
Box::new(std::iter::empty())
}

trait RenderType {
Expand Down
4 changes: 2 additions & 2 deletions rstest_macros/src/parse/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl ExtendWithFunctionAttrs for FixtureInfo {
fn extend_with_function_attrs(
&mut self,
item_fn: &mut ItemFn,
) -> core::result::Result<(), ErrorsVec> {
) -> std::result::Result<(), ErrorsVec> {
let composed_tuple!(
fixtures,
defaults,
Expand Down Expand Up @@ -132,7 +132,7 @@ impl VisitMut for FixturesFunctionExtractor {
Some(pt) => pt,
None => return,
};
let (extracted, remain): (Vec<_>, Vec<_>) = core::mem::take(&mut arg.attrs)
let (extracted, remain): (Vec<_>, Vec<_>) = std::mem::take(&mut arg.attrs)
.into_iter()
.partition(|attr| attr_in(attr, &["with", "from"]));
arg.attrs = remain;
Expand Down
6 changes: 3 additions & 3 deletions rstest_macros/src/parse/just_once.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::marker::PhantomData;
use std::marker::PhantomData;

use quote::ToTokens;
use syn::{visit_mut::VisitMut, Attribute, FnArg, ItemFn, Pat};
Expand Down Expand Up @@ -87,7 +87,7 @@ where
};
if let FnArg::Typed(ref mut arg) = node {
// Extract interesting attributes
let attrs = core::mem::take(&mut arg.attrs);
let attrs = std::mem::take(&mut arg.attrs);
let (extracted, remain): (Vec<_>, Vec<_>) =
attrs.into_iter().partition(|a| attr_is(a, self.name));

Expand Down Expand Up @@ -167,7 +167,7 @@ where
{
fn visit_item_fn_mut(&mut self, item_fn: &mut ItemFn) {
// Extract interesting attributes
let attrs = core::mem::take(&mut item_fn.attrs);
let attrs = std::mem::take(&mut item_fn.attrs);
let (extracted, remain): (Vec<_>, Vec<_>) =
attrs.into_iter().partition(|a| attr_is(a, self.name));

Expand Down
Loading

0 comments on commit 541cffe

Please sign in to comment.