`format!` in a `proptest!` test: "macro `format!` is not supported yet" when a local module `alloc` is in scope

オープン
#239 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
devtools, testing

調査の方向性

Start by running the linked minimal reproducer from the issue and reading the proptest! macro expansion path in the Relax Rust JIT repository. Compare how format! is resolved inside and outside the generated test, with a local alloc module in scope. Done means the reproducer passes under relax test while preserving the shadowing module.

索引モデルが issue の本文から書いたものです。

説明

format! inside a proptest! test fails to expand when a local module named alloc is in scope:

mod gpu {
    pub mod alloc {
        pub fn bytes(n: usize) -> Vec<u8> { vec![0; n] }
    }
}
use gpu::alloc;

#[cfg(test)]
mod tests {
    use super::*;
    use proptest::prelude::*;
    proptest! {
        #[test]
        fn formats(n in 0usize..100) {
            let s = format!("{n}");
            prop_assert!(!s.is_empty());
        }
    }
}
cargo test:  test result: ok. 1 passed
relax test:  src/lib.rs:19:5: internal: macro `format!` is not supported yet

It looks like the local alloc shadows the alloc crate that format! comes from. Each of these makes it pass:

  • deleting use gpu::alloc;
  • calling format! from an ordinary function in a child module with the same use super::*;, with no proptest!.

Minimal reproducer (proptest only), checked on 193e0b6c.

主要言語
Rust
スター
601
フォーク
34
平均マージ
1時間 58分
マージ済み PR(30日)
45

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

makepad/relax のほかの issue

makepad/relax の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。