Skip to content

fix: use core instead of std - #741

Draft
xtqqczze wants to merge 2 commits into
rust-lang:mainfrom
xtqqczze:clippy/std_instead_of_core
Draft

fix: use core instead of std#741
xtqqczze wants to merge 2 commits into
rust-lang:mainfrom
xtqqczze:clippy/std_instead_of_core

Conversation

@xtqqczze

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread benches/general_ops.rs Outdated
use criterion::Criterion;
use hashbrown::DefaultHashBuilder;
use hashbrown::{HashMap, HashSet};
use std::collections::hash_map::RandomState;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, with our MSRV bump, this can be std::hash::RandomState

Comment thread src/map.rs
///
/// // Existing key (or_insert)
/// let v = map.entry("b").or_insert(2);
/// assert_eq!(std::mem::replace(v, 2), 20);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly in favour of this change, but I would rather not update the doctests specifically since in general we prefer making those as simple as possible, and using only std allows better import grouping.

Comment thread src/raw.rs Outdated
Comment thread tests/hasher_unwind.rs
Comment on lines +18 to +20
use std::collections::BTreeSet;
use std::panic::catch_unwind;
use std::sync::Mutex;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would brace-group these:

Suggested change
use std::collections::BTreeSet;
use std::panic::catch_unwind;
use std::sync::Mutex;
use std::{
collections::BTreeSet,
panic::catch_unwind,
sync::Mutex,
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had considered that, but rustfmt wanted to remove whitespace which I didn't like:

use std::{collections::BTreeSet, panic::catch_unwind, sync::Mutex};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see; personally, I still would go with it, but it's up to you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an ideal world, we'd use imports_layout = Vertical like libc but it's an unstable feature.

@xtqqczze
xtqqczze marked this pull request as draft July 28, 2026 14:29
xtqqczze added 2 commits July 29, 2026 17:10
`std::collections::hash_map::RandomState` moved to `std::RandomState` in Rust 1.76.
@xtqqczze
xtqqczze force-pushed the clippy/std_instead_of_core branch from 89b0299 to 0119920 Compare July 29, 2026 16:11
@clarfonthey

Copy link
Copy Markdown
Contributor

FWIW: there are clippy lints for alloc_instead_of_core, std_instead_of_core, and std_instead_of_alloc. Don't think they can be set up to exclude doctests though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants