RustCrypto / RustCrypto/KEMs

ml-kem/module-lattice: `integer_extend_truncate` warnings

Open
#308 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
111
Forks
53
Avg merge
5d 29m
Merged PRs (30d)
2

Description

Just started getting these warnings:

warning: an associated function with this name may be added to the standard library in the future
   --> ml-kem/src/algebra.rs:123:27
    |
123 |         let N = start_n + u8::truncate(i);
    |                           ^^^^^^^^^^^^
    |
    = help: call with fully qualified syntax `truncate(...)` to keep using the current method
    = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
    = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
    = note: `#[warn(unstable_name_collisions)]` (part of `#[warn(future_incompatible)]`) on by default
help: add `#![feature(integer_extend_truncate)]` to the crate attributes to enable `core::num::<impl u8>::truncate`
   --> ml-kem/src/lib.rs:45:1
    |
 45 + #![feature(integer_extend_truncate)]

It seems we should at least switch to using Truncate::truncate as the invocation syntax, but also this seems like a case where we should perhaps consider a different API entirely, or at least a different method name, so as not to clash with the standard library.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ml-kem/src/algebra.rs around line 123 and inspect the Truncate trait and its use, then check the crate attributes in ml-kem/src/lib.rs. Resolve the warning without relying on a name that may collide with the standard library; done means the warning is gone and the chosen API remains clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.