Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix strict const_err #1049

Merged
merged 1 commit into from
Oct 3, 2019
Merged

Conversation

HeroicKatora
Copy link
Member

An array is indexed with constants that exceed its size. This is
inopportune even in a branch that never gets executed. This changes it
so that the indexing happens on a slice. This is a potential forward
compatibility hazard that isn't too hard to fix.

Also removes a bunch of annotations by avoiding primitive casts with
explicit type annotations in constants.

@HeroicKatora
Copy link
Member Author

Waiting on some feedback from rust: rust-lang/rust#65005

@HeroicKatora
Copy link
Member Author

So looks like const_err is a deny-by-default lint and lints are allowed to be arbitrarily broadened. Since the 'bug' in question exists since 0.19 and versions before only work because they are buggy 😆 . I'll probably backport to 0.21 like before, it's still about equal to 0.22 in terms of users, slowly declining.

The better fix probably involves adding allow(const_err) to the macro in question since I'm not sure if the allow changes may not even potentially allow evaluating self.0[..][4] as if a const expression, despite the slice type in the middel.

@HeroicKatora
Copy link
Member Author

So, the difference between deny(lint) and an error is that the former still gets silenced when image is used as a non-path dependency. Phew. So no risk of downstream crates breaking (until it gets turned into a hard error which is likely not soon).

An array is indexed with constants that exceed its size. This is
inopportune even in a branch that never gets executed. This changes it
so that the indexing happens on a slice.

Also removes a bunch of annotations by avoiding primitive casts with
explicit type annotations in constants.
@HeroicKatora
Copy link
Member Author

And I found a cute way to avoid the issue regardless. Since old versions as dependencies won't break there is no reason to backport except if someone complains because they use it by path.

@HeroicKatora HeroicKatora merged commit 1e7ce10 into image-rs:master Oct 3, 2019
@HeroicKatora HeroicKatora deleted the const-err branch October 3, 2019 03:26
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