rust-embedded / rust-embedded/svd2rust
FYI for new warn-by-default lint `mismatched_lifetime_syntaxes`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 857
- Forks
- 164
- PR merge metrics
- No merged PRs in 30d
Description
(Meta: this issue is a forward of https://github.com/stm32-rs/stm32-rs/issues/1245.)
Hi svd2rust maintainers, we landed a new warn-by-default lint mismatched_lifetime_syntaxes on the nightly channel. The lint is intended to warn on cases where the same lifetime is referred to by different syntactical forms between function arguments and return types, which has been a long-standing source of confusion for users. See https://doc.rust-lang.org/nightly/rustc/lints/listing/warn-by-default.html#mismatched-lifetime-syntaxes.
For certain generated crates (e.g. stm32f4), it was reported that the performance of the lint might be a concern. We analyzed the performance regression, and found that the performance regression is dominated by the emission of a lot of warnings on the generated code.
This is expected to only impact build times when working on the generated crates, not when the crates are used as dependencies because in that case they will be built with --cap-lints=allow preventing warnings from being emitted.
To address the build time impact for when working on the generated crates:
- You may wish to
#[allow(mismatched_lifetime_syntaxes)]on the generated crates. Or, - You may wish to adjust the generation implementation to emit code that uses consistent lifetime syntaxes for function arguments and return values.
For your reference,
- See performance regression discussion thread.
- See feedback on the
mismatched_lifetime_syntaxesthread. - Or you can also open new issues on rust-lang/rust and tag the issue with
@rustbot label: +L-mismatched_lifetime_syntaxes.
(Please use the threads or new rust-lang/rust issues for feedback, as otherwise I may lose the notification.)
Contributor guide
No contributing guide indexed for this repository
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
No specific file or test is named. Start by reviewing the generation implementation and affected generated crates such as stm32f4, then determine whether consistent lifetime syntax or an allow attribute is appropriate; done means the generated crates no longer produce the warning-related build-time impact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100