Compare commits

...

3 Commits

Author SHA1 Message Date
frozolotl
6c1789a433
Merge ed5f85e0cdc0dc7a7b8c5e7619d1a641520d9ae4 into e9f1b5825a9d37ca0c173a7b2830ba36a27ca9e0 2025-07-25 00:37:51 +08:00
Laurenz
e9f1b5825a
Lint for iterations over hash types (#6652) 2025-07-24 11:34:08 +00:00
frozolotl
ed5f85e0cd Follow the comment on setting the State's mask
This does not actually change any existing behavior, as `with_mask` is
not used in a way that uses it. However, it should align reality with
expectations.

## Alternatives

There is a case to be made for simply removing the function, or for not
changing its behavior, but simply the code. I think the new behavior
(and the one written about in the code's comment) makes sense though.

## Postface

Interestingly, this PR was inspired by another AI-generated slop PR.[^1]

[^1]: https://github.com/typst/typst/pull/6640/files#diff-756093ac5fe76dbe9e281b08197b3cec0a930f18fab8d23a57c781c21886a606R174-R175
2025-07-22 02:43:46 +02:00
4 changed files with 8 additions and 4 deletions

View File

@ -159,6 +159,7 @@ strip = true
[workspace.lints.clippy]
blocks_in_conditions = "allow"
comparison_chain = "allow"
iter_over_hash_type = "warn"
manual_range_contains = "allow"
mutable_key_type = "allow"
uninlined_format_args = "warn"

View File

@ -139,6 +139,7 @@ impl Watcher {
fn update(&mut self, iter: impl IntoIterator<Item = PathBuf>) -> StrResult<()> {
// Mark all files as not "seen" so that we may unwatch them if they
// aren't in the dependency list.
#[allow(clippy::iter_over_hash_type, reason = "order does not matter")]
for seen in self.watched.values_mut() {
*seen = false;
}

View File

@ -173,6 +173,7 @@ impl SystemWorld {
/// Reset the compilation state in preparation of a new compilation.
pub fn reset(&mut self) {
#[allow(clippy::iter_over_hash_type, reason = "order does not matter")]
for slot in self.slots.get_mut().values_mut() {
slot.reset();
}

View File

@ -93,7 +93,7 @@ struct State<'a> {
size: Size,
}
impl State<'_> {
impl<'a> State<'a> {
fn new(size: Size, transform: sk::Transform, pixel_per_pt: f32) -> Self {
Self {
size,
@ -128,9 +128,10 @@ impl State<'_> {
}
/// Sets the current mask.
fn with_mask(self, mask: Option<&sk::Mask>) -> State<'_> {
// Ensure that we're using the parent's mask if we don't have one.
if mask.is_some() { State { mask, ..self } } else { State { mask: None, ..self } }
///
/// If no mask is provided, the parent mask is used.
fn with_mask(self, mask: Option<&'a sk::Mask>) -> State<'a> {
State { mask: mask.or(self.mask), ..self }
}
/// Sets the size of the first hard frame in the hierarchy.