Compiler error message is unhelpful when trying `ndarray::s!([2..3])`

Aberta
#1,122 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
45/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
rust
Domínio
compilers

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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?

Linguagem predominante
Rust
Estrelas
4.3k
Forks
391
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de rust-ndarray/ndarray

Todas as issues de rust-ndarray/ndarray

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.