Skip to content

Commit

Permalink
Change std imports to core where possible
Browse files Browse the repository at this point in the history
Useful for seeing what are the gaps toward being compatible with
no-std. Useful for copying chunks of code into a no-std crate.
  • Loading branch information
dtolnay committed Aug 1, 2022
1 parent 40c2cef commit 971948a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/detection.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::atomic::{AtomicUsize, Ordering};
use core::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Once;

static WORKS: AtomicUsize = AtomicUsize::new(0);
Expand Down
16 changes: 8 additions & 8 deletions src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ use crate::parse::{self, Cursor};
use crate::rcvec::{RcVec, RcVecBuilder, RcVecIntoIter, RcVecMut};
use crate::{Delimiter, Spacing, TokenTree};
#[cfg(span_locations)]
use std::cell::RefCell;
use core::cell::RefCell;
#[cfg(span_locations)]
use std::cmp;
use std::fmt::{self, Debug, Display, Write};
use std::iter::FromIterator;
use std::mem::ManuallyDrop;
use std::ops::RangeBounds;
use core::cmp;
use core::fmt::{self, Debug, Display, Write};
use core::iter::FromIterator;
use core::mem::ManuallyDrop;
use core::ops::RangeBounds;
use core::ptr;
use core::str::FromStr;
#[cfg(procmacro2_semver_exempt)]
use std::path::Path;
use std::path::PathBuf;
use std::ptr;
use std::str::FromStr;

/// Force use of proc-macro2's fallback implementation of the API for now, even
/// if the compiler's implementation is available.
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ use crate::fallback as imp;
mod imp;

use crate::marker::Marker;
use std::cmp::Ordering;
use core::cmp::Ordering;
use core::fmt::{self, Debug, Display};
use core::hash::{Hash, Hasher};
use core::iter::FromIterator;
use core::ops::RangeBounds;
use core::str::FromStr;
use std::error::Error;
use std::fmt::{self, Debug, Display};
use std::hash::{Hash, Hasher};
use std::iter::FromIterator;
use std::ops::RangeBounds;
#[cfg(procmacro2_semver_exempt)]
use std::path::PathBuf;
use std::str::FromStr;

/// An abstract stream of tokens, or more concretely a sequence of token trees.
///
Expand Down Expand Up @@ -1271,7 +1271,7 @@ impl Display for Literal {
pub mod token_stream {
use crate::marker::Marker;
use crate::{imp, TokenTree};
use std::fmt::{self, Debug};
use core::fmt::{self, Debug};

pub use crate::TokenStream;

Expand Down
4 changes: 2 additions & 2 deletions src/marker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::marker::PhantomData;
use core::marker::PhantomData;
use std::panic::{RefUnwindSafe, UnwindSafe};
use std::rc::Rc;

Expand All @@ -9,7 +9,7 @@ pub(crate) type Marker = PhantomData<ProcMacroAutoTraits>;
pub(crate) use self::value::*;

mod value {
pub(crate) use std::marker::PhantomData as Marker;
pub(crate) use core::marker::PhantomData as Marker;
}

pub(crate) struct ProcMacroAutoTraits(Rc<()>);
Expand Down
4 changes: 2 additions & 2 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::fallback::{
TokenStreamBuilder,
};
use crate::{Delimiter, Punct, Spacing, TokenTree};
use std::char;
use std::str::{Bytes, CharIndices, Chars};
use core::char;
use core::str::{Bytes, CharIndices, Chars};

#[derive(Copy, Clone, Eq, PartialEq)]
pub(crate) struct Cursor<'a> {
Expand Down
4 changes: 2 additions & 2 deletions src/rcvec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::mem;
use core::mem;
use core::slice;
use std::rc::Rc;
use std::slice;
use std::vec;

pub(crate) struct RcVec<T> {
Expand Down
8 changes: 4 additions & 4 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::detection::inside_proc_macro;
use crate::{fallback, Delimiter, Punct, Spacing, TokenTree};
use std::fmt::{self, Debug, Display};
use std::iter::FromIterator;
use std::ops::RangeBounds;
use core::fmt::{self, Debug, Display};
use core::iter::FromIterator;
use core::ops::RangeBounds;
use core::str::FromStr;
use std::panic;
#[cfg(super_unstable)]
use std::path::PathBuf;
use std::str::FromStr;

#[derive(Clone)]
pub(crate) enum TokenStream {
Expand Down

0 comments on commit 971948a

Please sign in to comment.