rust-embedded / rust-embedded/svd2rust

FYI for new warn-by-default lint `mismatched_lifetime_syntaxes`

Open
#937 1 comment 0 reactions 0 assignees View on GitHub

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,

(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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.