-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 bad NodeId
limit checking.
#91404
Fix bad NodeId
limit checking.
#91404
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
`Resolver::next_node_id` converts a `u32` to a `usize` (which is possibly bigger), does a checked add, and then converts the result back to a `u32`. The `usize` conversion completely subverts the checked add! This commit removes the conversion to/from `usize`.
02d863c
to
e7ee823
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The use of usize
in this code seems to trace back to the old pub fn reserve_node_ids(&mut self, count: usize)
prior to 43a7405, which involved a usize addition. I guess the use of usize
in that signature was intended to be convenient to callers. (reserve_node_ids(foo.len())
?)
@bors r+ |
📌 Commit e7ee823 has been approved by |
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#87160 (When recovering from a `:` in a pattern, use adequate AST pattern) - rust-lang#90985 (Use `get_diagnostic_name` more) - rust-lang#91087 (Remove all migrate.nll.stderr files) - rust-lang#91207 (Add support for LLVM coverage mapping format versions 5 and 6) - rust-lang#91298 (Improve error message for `E0659` if the source is not available) - rust-lang#91346 (Add `Option::inspect` and `Result::{inspect, inspect_err}`) - rust-lang#91404 (Fix bad `NodeId` limit checking.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Resolver::next_node_id
converts au32
to ausize
(which ispossibly bigger), does a checked add, and then converts the result back
to a
u32
. Theusize
conversion completely subverts the checked add!This commit removes the conversion to/from
usize
.