rust-lang / rust-lang/rust-analyzer
Weird mismatched-arg-count lint on gtx_pipeline! macro.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I'm new-ish to rust and don't know if the error is in the code or in the analyzer.
Opening https://github.com/PistonDevelopers/piston-examples/blob/master/examples/cube.rs in vscode makes rust-analyzer complain about mismatched-arg-count on lines 25-32. The exact message is a bit stranger still:
{
"resource": "<redacted>",
"owner": "rustc",
"code": {
"value": "mismatched-arg-count",
"target": {
"$mid": 1,
"external": "https://rust-analyzer.github.io/manual.html#mismatched-arg-count",
"path": "/manual.html",
"scheme": "https",
"authority": "rust-analyzer.github.io",
"fragment": "mismatched-arg-count"
}
},
"severity": 8,
"message": "expected 7 arguments, found 4",
"source": "rust-analyzer",
"startLineNumber": 25,
"startColumn": 1,
"endLineNumber": 32,
"endColumn": 4
}
The message says it expects 7 arguments, but found 4. Neither of these numbers make sense in any way I can think of.
Code of the macro:
/// Defines a set of pipeline-associated structures, and also
/// adds `new` constuctor for the `Init` structure.
#[macro_export]
macro_rules! gfx_pipeline {
($module:ident {
$( $field:ident: $ty:ty = $value:expr, )*
}) => {
#[allow(missing_docs)]
pub mod $module {
#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use super::gfx;
gfx_pipeline_inner!{ $(
$field: $ty,
)*}
pub fn new() -> Init<'static> {
Init {
$( $field: $value, )*
}
}
}
}
}
Application of the macro:
gfx_pipeline!( pipe {
vbuf: gfx::VertexBuffer<Vertex> = (),
u_model_view_proj: gfx::Global<[[f32; 4]; 4]> = "u_model_view_proj",
t_color: gfx::TextureSampler<[f32; 4]> = "t_color",
out_color: gfx::RenderTarget<::gfx::format::Srgba8> = "o_Color",
out_depth: gfx::DepthTarget<::gfx::format::DepthStencil> =
gfx::preset::depth::LESS_EQUAL_WRITE,
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic by opening examples/cube.rs in VS Code and inspect the gfx_pipeline! macro application and definition shown in the report. Trace how rust-analyzer counts arguments across this macro expansion; done means the reported mismatched-arg-count warning is resolved or correctly explained for lines 25-32.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100