Skip to content

Commit f8a7a33

Browse files
committed
Disable std prelude
This makes visible the dependency on std prelude macros such as `error::Error`. Helpful for planning how to do no-std. Tested with `cargo hack clippy --feature-powerset -- --deny warnings` (all 2112 combinations).
1 parent 888a207 commit f8a7a33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+238
-140
lines changed

codegen/src/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub fn generate(defs: &Definitions) -> Result<()> {
198198
quote! {
199199
#![allow(unknown_lints, non_local_definitions)]
200200

201-
use std::fmt::{self, Debug};
201+
use core::fmt::{self, Debug};
202202

203203
#impls
204204
},

codegen/src/eq.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ pub fn generate(defs: &Definitions) -> Result<()> {
158158
quote! {
159159
#[cfg(any(feature = "derive", feature = "full"))]
160160
use crate::tt::TokenStreamHelper;
161+
#[cfg(feature = "extra-traits")]
162+
use alloc::string::ToString;
161163

162164
#impls
163165
},

codegen/src/fold.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ pub fn generate(defs: &Definitions) -> Result<()> {
255255
clippy::needless_pass_by_ref_mut,
256256
)]
257257

258+
#[cfg(any(feature = "derive", feature = "full"))]
259+
use alloc::boxed::Box;
260+
#[cfg(any(feature = "derive", feature = "full"))]
261+
use alloc::vec::Vec;
262+
258263
#full_macro
259264

260265
/// Syntax tree traversal to transform the nodes of an owned syntax tree.

codegen/src/hash.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ pub fn generate(defs: &Definitions) -> Result<()> {
160160
quote! {
161161
#[cfg(any(feature = "derive", feature = "full"))]
162162
use crate::tt::TokenStreamHelper;
163-
use std::hash::{Hash, Hasher};
163+
#[cfg(feature = "extra-traits")]
164+
use alloc::string::ToString;
165+
use core::hash::{Hash, Hasher};
164166

165167
#impls
166168
},

codegen/src/snapshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ pub fn generate(defs: &Definitions) -> Result<()> {
363363

364364
use super::{Lite, Present};
365365
use ref_cast::RefCast;
366-
use std::fmt::{self, Debug, Display};
366+
use core::fmt::{self, Debug, Display};
367367

368368
#impls
369369
},

codegen/src/visit_mut.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ pub fn generate(defs: &Definitions) -> Result<()> {
233233
#![allow(unused_variables)]
234234
#![allow(clippy::needless_pass_by_ref_mut)]
235235

236+
#[cfg(any(feature = "derive", feature = "full"))]
237+
use alloc::vec::Vec;
236238
#[cfg(any(feature = "full", feature = "derive"))]
237239
use crate::punctuated::Punctuated;
238240

src/attr.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ use crate::meta::{self, ParseNestedMeta};
1010
use crate::parse::{Parse, ParseStream, Parser};
1111
use crate::path::Path;
1212
use crate::token;
13-
use proc_macro2::TokenStream;
13+
#[cfg(feature = "parsing")]
14+
use alloc::format;
15+
#[cfg(feature = "parsing")]
16+
use alloc::vec::Vec;
1417
#[cfg(feature = "printing")]
15-
use std::iter;
18+
use core::iter;
1619
#[cfg(feature = "printing")]
17-
use std::slice;
20+
use core::slice;
21+
use proc_macro2::TokenStream;
1822

1923
ast_struct! {
2024
/// An attribute, like `#[repr(transparent)]`.
@@ -653,8 +657,9 @@ pub(crate) mod parsing {
653657
use crate::parse::{Parse, ParseStream};
654658
use crate::path::Path;
655659
use crate::{mac, token};
660+
use alloc::vec::Vec;
661+
use core::fmt::{self, Display};
656662
use proc_macro2::Ident;
657-
use std::fmt::{self, Display};
658663

659664
pub(crate) fn parse_inner(input: ParseStream, attrs: &mut Vec<Attribute>) -> Result<()> {
660665
while input.peek(Token![#]) && input.peek2(Token![!]) {

src/bigint.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use std::ops::{AddAssign, MulAssign};
1+
use alloc::string::String;
2+
use alloc::vec::Vec;
3+
use core::ops::{AddAssign, MulAssign};
24

35
// For implementing base10_digits() accessor on LitInt.
46
pub(crate) struct BigInt {

src/buffer.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
use crate::ext::TokenStreamExt as _;
99
use crate::Lifetime;
10+
use alloc::boxed::Box;
11+
use alloc::vec::Vec;
12+
use core::cmp::Ordering;
13+
use core::marker::PhantomData;
14+
use core::ptr;
1015
use proc_macro2::extra::DelimSpan;
1116
use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
12-
use std::cmp::Ordering;
13-
use std::marker::PhantomData;
14-
use std::ptr;
1517

1618
/// Internal type which is used instead of `TokenTree` to represent a token tree
1719
/// within a `TokenBuffer`.

src/classify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use crate::path::{Path, PathArguments};
88
use crate::punctuated::Punctuated;
99
#[cfg(any(feature = "printing", feature = "full"))]
1010
use crate::ty::{ReturnType, Type};
11+
#[cfg(any(feature = "printing", feature = "full"))]
12+
use core::ops::ControlFlow;
1113
#[cfg(feature = "full")]
1214
use proc_macro2::{Delimiter, TokenStream, TokenTree};
13-
#[cfg(any(feature = "printing", feature = "full"))]
14-
use std::ops::ControlFlow;
1515

1616
#[cfg(feature = "full")]
1717
pub(crate) fn requires_semi_to_be_stmt(expr: &Expr) -> bool {

0 commit comments

Comments
 (0)