Skip to content

Commit 971948a

Browse files
committed
Change std imports to core where possible
Useful for seeing what are the gaps toward being compatible with no-std. Useful for copying chunks of code into a no-std crate.
1 parent 40c2cef commit 971948a

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

src/detection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::sync::atomic::{AtomicUsize, Ordering};
1+
use core::sync::atomic::{AtomicUsize, Ordering};
22
use std::sync::Once;
33

44
static WORKS: AtomicUsize = AtomicUsize::new(0);

src/fallback.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ use crate::parse::{self, Cursor};
22
use crate::rcvec::{RcVec, RcVecBuilder, RcVecIntoIter, RcVecMut};
33
use crate::{Delimiter, Spacing, TokenTree};
44
#[cfg(span_locations)]
5-
use std::cell::RefCell;
5+
use core::cell::RefCell;
66
#[cfg(span_locations)]
7-
use std::cmp;
8-
use std::fmt::{self, Debug, Display, Write};
9-
use std::iter::FromIterator;
10-
use std::mem::ManuallyDrop;
11-
use std::ops::RangeBounds;
7+
use core::cmp;
8+
use core::fmt::{self, Debug, Display, Write};
9+
use core::iter::FromIterator;
10+
use core::mem::ManuallyDrop;
11+
use core::ops::RangeBounds;
12+
use core::ptr;
13+
use core::str::FromStr;
1214
#[cfg(procmacro2_semver_exempt)]
1315
use std::path::Path;
1416
use std::path::PathBuf;
15-
use std::ptr;
16-
use std::str::FromStr;
1717

1818
/// Force use of proc-macro2's fallback implementation of the API for now, even
1919
/// if the compiler's implementation is available.

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ use crate::fallback as imp;
137137
mod imp;
138138

139139
use crate::marker::Marker;
140-
use std::cmp::Ordering;
140+
use core::cmp::Ordering;
141+
use core::fmt::{self, Debug, Display};
142+
use core::hash::{Hash, Hasher};
143+
use core::iter::FromIterator;
144+
use core::ops::RangeBounds;
145+
use core::str::FromStr;
141146
use std::error::Error;
142-
use std::fmt::{self, Debug, Display};
143-
use std::hash::{Hash, Hasher};
144-
use std::iter::FromIterator;
145-
use std::ops::RangeBounds;
146147
#[cfg(procmacro2_semver_exempt)]
147148
use std::path::PathBuf;
148-
use std::str::FromStr;
149149

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

12761276
pub use crate::TokenStream;
12771277

src/marker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::marker::PhantomData;
1+
use core::marker::PhantomData;
22
use std::panic::{RefUnwindSafe, UnwindSafe};
33
use std::rc::Rc;
44

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

1111
mod value {
12-
pub(crate) use std::marker::PhantomData as Marker;
12+
pub(crate) use core::marker::PhantomData as Marker;
1313
}
1414

1515
pub(crate) struct ProcMacroAutoTraits(Rc<()>);

src/parse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::fallback::{
33
TokenStreamBuilder,
44
};
55
use crate::{Delimiter, Punct, Spacing, TokenTree};
6-
use std::char;
7-
use std::str::{Bytes, CharIndices, Chars};
6+
use core::char;
7+
use core::str::{Bytes, CharIndices, Chars};
88

99
#[derive(Copy, Clone, Eq, PartialEq)]
1010
pub(crate) struct Cursor<'a> {

src/rcvec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use std::mem;
1+
use core::mem;
2+
use core::slice;
23
use std::rc::Rc;
3-
use std::slice;
44
use std::vec;
55

66
pub(crate) struct RcVec<T> {

src/wrapper.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use crate::detection::inside_proc_macro;
22
use crate::{fallback, Delimiter, Punct, Spacing, TokenTree};
3-
use std::fmt::{self, Debug, Display};
4-
use std::iter::FromIterator;
5-
use std::ops::RangeBounds;
3+
use core::fmt::{self, Debug, Display};
4+
use core::iter::FromIterator;
5+
use core::ops::RangeBounds;
6+
use core::str::FromStr;
67
use std::panic;
78
#[cfg(super_unstable)]
89
use std::path::PathBuf;
9-
use std::str::FromStr;
1010

1111
#[derive(Clone)]
1212
pub(crate) enum TokenStream {

0 commit comments

Comments
 (0)