Compiler error message is unhelpful when trying `ndarray::s!([2..3])`
还没有人认领这个 Issue。
评估
调研方向
Start with the ndarray::s! macro and the failing call shown at src/tiler.rs:59. Reproduce the compiler diagnostic for ndarray::s!([2..3]), then inspect the macro documentation and determine whether the finished change should provide a clearer diagnostic or explain the nested-bracket mistake in the documentation.
由索引模型根据 Issue 内容生成。
描述
error[E0277]: the trait bound `[std::ops::Range<{integer}>; 1]: ndarray::SliceNextDim` is not satisfied
--> src/tiler.rs:59:25
|
59 | input.slice(ndarray::s!([2..3]));
| ^^^^^^^^^^^^^^^^^^^ the trait `ndarray::SliceNextDim` is not implemented for `[std::ops::Range<{integer}>; 1]`
|
note: required by a bound in `ndarray::SliceNextDim::next_in_dim`
I type () after function-like macro call (that is not constructing a data structure sample) almost automatically and I also remember that I need array of ranges for ndarray::s!. That has resulted in s!([...]) twice already, and I spend more than a minute looking at the code, documentation and error message.
The error message looks as if arrays or ranges are not OK for ndarray::s. It is not obvious that the mistake is not in usage of ranges or arrays, but in usage of extra outer parentheses.. Although one should not use arrays when doing ndarray:s, square brackets in documentation makes it feels as if we were specifying a Rust array as input to the macro, which may result in actual Rust array being fed to it.
Maybe the macro should detect extra brackets and output more more helpful warning or error? Or at least documentation of ndarray::s should mention possible compiler error about []: SliceNextDim and tell user to look at nested brackets?
- 主要语言
- Rust
- 星标
- 4.3k
- 派生
- 391
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rust-ndarray/ndarray 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
rust-ndarray/ndarray#1612 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 48/100
rust-ndarray/ndarray#1617 · 1 条评论 ·
-
bug good first issue
难度 3/5 1-2 天 新手友好度 68/100
rust-ndarray/ndarray#1615 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 48/100
rust-ndarray/ndarray#1610 ·
-
难度 3/5 1-2 天 新手友好度 72/100
rust-ndarray/ndarray#1609 ·
查看 rust-ndarray/ndarray 的全部 Issue
相似的 Issue
-
risk:low runtime status:in-progress type:test
难度 1/5 1 小时以内 新手友好度 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 84/100
EricSpencer00/Resilient#4835 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
bisq-network/bisq-musig#204 ·
-
agent:ready documentation
难度 2/5 1-3 小时 新手友好度 88/100
cesarferreira/stax#890 ·