Skip to content

Add unsafe attributes and impls to tidy unsafety check - #163781

Draft
clarfonthey wants to merge 2 commits into
rust-lang:mainfrom
clarfonthey:tidy-unsafe
Draft

clarfonthey wants to merge 2 commits into
rust-lang:mainfrom
clarfonthey:tidy-unsafe

Conversation

@clarfonthey

@clarfonthey clarfonthey commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

This is another big one.

r? nia-e

@rustbot rustbot added A-tidy Area: The tidy tool S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 5, 2026
@clarfonthey
clarfonthey force-pushed the tidy-unsafe branch 4 times, most recently from 54bf656 to 76cddd9 Compare October 5, 2026 03:12
Comment thread library/core/src/option.rs
@clarfonthey
clarfonthey force-pushed the tidy-unsafe branch 7 times, most recently from 217f6d0 to 6ff92ca Compare October 5, 2026 03:42
Comment thread library/core/src/result.rs Outdated
@rustbot

rustbot commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

nia-e is currently at their maximum review capacity.
They may take a while to respond.

Comment thread library/alloc/src/vec/is_zero.rs
Comment thread library/core/src/marker.rs Outdated

@nia-e nia-e left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is a few more. mostly nitpicks though

View changes since this review

impl<T, const N: usize, A: Allocator> FusedIterator for BoxedArrayIntoIter<T, N, A> {}

#[stable(feature = "boxed_array_value_iter", since = "1.99.0")]
// SAFETY: We just forward to `vec::IntoIter`, which has a trustable length.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We actually just take the raw length of the array here (see library/alloc/src/boxed/iter.rs:254)


#[doc(hidden)]
#[unstable(issue = "none", feature = "trusted_fused")]
// SAFETY: We just forward to `vec::IntoIter`, which is always fused.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The only safety req on the trait is that the impl isn't lifetime-dependent (library/core/src/iter/traits/marker.rs:8)

}

#[cfg(not(test))]
// SAFETY: We don't mutate the contained data when returning it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The trait bounds here are kinda underspecified but I read the safety req (library/alloc/src/vec/in_place_collect.rs:428) as being something like "The internals of IntoIter promise never to mutate the data or create a reference to the entire allocation"

@rust-bors

rust-bors Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #164187) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

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

Labels

A-tidy Area: The tidy tool S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants