Skip to content

Commit 6fb7026

Browse files
committed
Work around prelude redundant import warnings
rust-lang/rust#117772 warning: the item `String` is imported redundantly --> src/de.rs:8:5 | 8 | use alloc::string::String; | ^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here | = note: `#[warn(unused_imports)]` on by default warning: the item `Vec` is imported redundantly --> src/de.rs:9:5 | 9 | use alloc::vec::Vec; | ^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `Vec` is already defined here warning: the item `Box` is imported redundantly --> src/error.rs:4:5 | 4 | use alloc::boxed::Box; | ^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `Box` is already defined here warning: the item `String` is imported redundantly --> src/error.rs:5:21 | 5 | use alloc::string::{String, ToString}; | ^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here warning: the item `ToString` is imported redundantly --> src/error.rs:5:29 | 5 | use alloc::string::{String, ToString}; | ^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `ToString` is already defined here warning: the item `String` is imported redundantly --> src/map.rs:10:5 | 10 | use alloc::string::String; | ^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here warning: the item `indexmap` is imported redundantly --> src/map.rs:23:16 | 23 | use indexmap::{self, IndexMap}; | ^^^^ the item `indexmap` is already defined here | = note: `#[warn(unused_imports)]` on by default warning: the item `String` is imported redundantly --> src/ser.rs:5:21 | 5 | use alloc::string::{String, ToString}; | ^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here warning: the item `ToString` is imported redundantly --> src/ser.rs:5:29 | 5 | use alloc::string::{String, ToString}; | ^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `ToString` is already defined here warning: the item `Vec` is imported redundantly --> src/ser.rs:6:5 | 6 | use alloc::vec::Vec; | ^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `Vec` is already defined here warning: the item `String` is imported redundantly --> src/value/mod.rs:95:5 | 95 | use alloc::string::String; | ^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here warning: the item `Vec` is imported redundantly --> src/value/mod.rs:96:5 | 96 | use alloc::vec::Vec; | ^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `Vec` is already defined here warning: the item `ToOwned` is imported redundantly --> src/value/de.rs:5:26 | 5 | use alloc::borrow::{Cow, ToOwned}; | ^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `ToOwned` is already defined here warning: the item `String` is imported redundantly --> src/value/de.rs:6:5 | 6 | use alloc::string::String; | ^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here warning: the item `Vec` is imported redundantly --> src/value/de.rs:9:24 | 9 | use alloc::vec::{self, Vec}; | ^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `Vec` is already defined here warning: the item `String` is imported redundantly --> src/value/from.rs:5:21 | 5 | use alloc::string::{String, ToString}; | ^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here warning: the item `ToString` is imported redundantly --> src/value/from.rs:5:29 | 5 | use alloc::string::{String, ToString}; | ^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `ToString` is already defined here warning: the item `Vec` is imported redundantly --> src/value/from.rs:6:5 | 6 | use alloc::vec::Vec; | ^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `Vec` is already defined here warning: the item `ToOwned` is imported redundantly --> src/value/index.rs:3:5 | 3 | use alloc::borrow::ToOwned; | ^^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `ToOwned` is already defined here warning: the item `String` is imported redundantly --> src/value/index.rs:4:5 | 4 | use alloc::string::String; | ^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here warning: the item `String` is imported redundantly --> src/value/partial_eq.rs:2:5 | 2 | use alloc::string::String; | ^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here warning: the item `ToOwned` is imported redundantly --> src/value/ser.rs:4:5 | 4 | use alloc::borrow::ToOwned; | ^^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `ToOwned` is already defined here warning: the item `String` is imported redundantly --> src/value/ser.rs:5:21 | 5 | use alloc::string::{String, ToString}; | ^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `String` is already defined here warning: the item `ToString` is imported redundantly --> src/value/ser.rs:5:29 | 5 | use alloc::string::{String, ToString}; | ^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `ToString` is already defined here warning: the item `Vec` is imported redundantly --> src/value/ser.rs:6:5 | 6 | use alloc::vec::Vec; | ^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `Vec` is already defined here warning: the item `Vec` is imported redundantly --> src/read.rs:2:5 | 2 | use alloc::vec::Vec; | ^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `Vec` is already defined here warning: the item `ToString` is imported redundantly --> tests/test.rs:46:5 | 46 | use std::string::ToString; | ^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `ToString` is already defined here | = note: `#[warn(unused_imports)]` on by default warning: the item `Vec` is imported redundantly --> tests/../src/lexical/bignum.rs:6:5 | 6 | use alloc::vec::Vec; | ^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13 | 125 | pub use super::v1::*; | --------- the item `Vec` is already defined here | = note: `#[warn(unused_imports)]` on by default
1 parent 34a04c5 commit 6fb7026

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

src/lexical/bignum.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! Big integer type definition.
44
55
use super::math::*;
6+
#[allow(unused_imports)]
67
use alloc::vec::Vec;
78

89
/// Storage for a big integer type.

src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,14 @@
360360
#![deny(clippy::question_mark_used)]
361361
#![allow(non_upper_case_globals)]
362362
#![deny(missing_docs)]
363-
#![cfg_attr(not(feature = "std"), no_std)]
363+
#![no_std]
364364
#![cfg_attr(docsrs, feature(doc_cfg))]
365365

366366
extern crate alloc;
367367

368+
#[cfg(feature = "std")]
369+
extern crate std;
370+
368371
#[cfg(feature = "std")]
369372
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
370373
#[doc(inline)]

src/map.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use serde::de;
2020
#[cfg(not(feature = "preserve_order"))]
2121
use alloc::collections::{btree_map, BTreeMap};
2222
#[cfg(feature = "preserve_order")]
23-
use indexmap::{self, IndexMap};
23+
use indexmap::IndexMap;
2424

2525
/// Represents a JSON key/value type.
2626
pub struct Map<K, V> {
@@ -176,6 +176,8 @@ impl Map<String, Value> {
176176
/// Like [`Vec::swap_remove`], the entry is removed by swapping it with the
177177
/// last element of the map and popping it off. This perturbs the position
178178
/// of what used to be the last element!
179+
///
180+
/// [`Vec::swap_remove`]: std::vec::Vec::swap_remove
179181
#[cfg(feature = "preserve_order")]
180182
#[cfg_attr(docsrs, doc(cfg(feature = "preserve_order")))]
181183
#[inline]
@@ -192,6 +194,8 @@ impl Map<String, Value> {
192194
/// Like [`Vec::swap_remove`], the entry is removed by swapping it with the
193195
/// last element of the map and popping it off. This perturbs the position
194196
/// of what used to be the last element!
197+
///
198+
/// [`Vec::swap_remove`]: std::vec::Vec::swap_remove
195199
#[cfg(feature = "preserve_order")]
196200
#[cfg_attr(docsrs, doc(cfg(feature = "preserve_order")))]
197201
#[inline]
@@ -208,6 +212,8 @@ impl Map<String, Value> {
208212
/// Like [`Vec::remove`], the entry is removed by shifting all of the
209213
/// elements that follow it, preserving their relative order. This perturbs
210214
/// the index of all of those elements!
215+
///
216+
/// [`Vec::remove`]: std::vec::Vec::remove
211217
#[cfg(feature = "preserve_order")]
212218
#[cfg_attr(docsrs, doc(cfg(feature = "preserve_order")))]
213219
#[inline]
@@ -224,6 +230,8 @@ impl Map<String, Value> {
224230
/// Like [`Vec::remove`], the entry is removed by shifting all of the
225231
/// elements that follow it, preserving their relative order. This perturbs
226232
/// the index of all of those elements!
233+
///
234+
/// [`Vec::remove`]: std::vec::Vec::remove
227235
#[cfg(feature = "preserve_order")]
228236
#[cfg_attr(docsrs, doc(cfg(feature = "preserve_order")))]
229237
#[inline]

src/read.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use crate::iter::LineColIterator;
1414
use crate::raw::BorrowedRawDeserializer;
1515
#[cfg(all(feature = "raw_value", feature = "std"))]
1616
use crate::raw::OwnedRawDeserializer;
17+
#[cfg(all(feature = "raw_value", feature = "std"))]
18+
use alloc::string::String;
1719
#[cfg(feature = "raw_value")]
1820
use serde::de::Visitor;
1921

tests/test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ use std::iter;
4343
use std::marker::PhantomData;
4444
use std::mem;
4545
use std::str::FromStr;
46-
use std::string::ToString;
4746
use std::{f32, f64};
4847
use std::{i16, i32, i64, i8};
4948
use std::{u16, u32, u64, u8};

0 commit comments

Comments
 (0)