Open SpanishPear opened 1 year ago
I can't seem to reproduce this. Do these lints also show up during the build or just in the editor? And if so, could you provide a reproducible example I can just run on the command line (editor setup will be hard to get into test cases).
Looks like the same issue as https://github.com/yewstack/yew/issues/2006 - and is rust-analyzer specific (no errors with clippy/check)
I can only get it to sometimes pop up - but I'll note that cargo expand
does show snake_case syntax when expanding the macro
#[doc(hidden)]
pub struct HasAppPropschild_with_thing<How>(::std::marker::PhantomData<How>);
with the following app.rs
(modifying the starter template) cargo generate --git https://github.com/yewstack/yew-trunk-minimal-template
I'm not sure the compleixty of Vchild is needed, but it was the last time i could get it to show up reliably
use yew::prelude::*;
use yew::virtual_dom::VChild;
#[derive(Clone, PartialEq, Properties)]
pub struct AppProps {
pub child_with_thing: VChild<TestChild>,
}
#[function_component(App)]
pub fn app() -> Html {
html! {
<main>
<img class="logo" src="https://yew.rs/img/logo.png" alt="Yew logo" />
<h1>{ "Hello World!" }</h1>
<span class="subtitle">{ "from Yew with " }<i class="heart" /></span>
</main>
}
}
#[function_component(TestChild)]
pub fn render() -> Html {
html! {
<p>{"child"}</p>
}
}
I can only get it to sometimes pop up - but I'll note that
cargo expand
does show snake_case syntax when expanding the macro
Yep, it's quite to clear to me that the macro output results in these warnings and why. I'm trying to come up with a way to encode this in test cases, so this and similar warnings/errors don't show up in the future. So far, I haven't been able to come up with something that could be run with the CI.
In case you want to just fix the issue, have a look at the macro code, that'd be the place to start.
There might be other similar names generated around that could get a similar treatment.
You likely don't want to change the casing in the struct name. It's used for diagnostic information during the type checking process as proc macros don't have type information to generate the errors they need to so they generate code that fails to compile with a comprehensible error message as a workaround
Problem
when using
#[derive(Properties)]
- the autogenerated structures e.g.AppPropsmyprop_name
are not SnakeCase, leading to clippy errorsSteps To Reproduce Steps to reproduce the behavior:
#[derive(Properties)]
incorrect-ident-case
Expected behavior No clippy errors from macros
Screenshots this is from my own project
Environment:
Questionnaire