Skip to content

F0092 stk-2

Rule: Build.rs prints only directives Cargo knows.

Code F0092 (stable, never reused)
Id stk-2
Category stk
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded deny bedrock error: cargo:rustc-linker= (or another unknown cargo: key) printed by build.rs: not a build-script directive, Cargo ignores it silently
ui off
egui off
units-strict off
units-paranoid off

Why

A build script that prints cargo:rustc-linker=... (or any other cargo: key Cargo doesn't recognise) expecting it to take effect.

Cargo silently ignores a build-script directive it doesn't recognise — there is no warning, no error, nothing in the build log. A build.rs that means to set the linker this way builds and links fine, just with whatever linker .cargo/config.toml actually specifies, which may not be flip-link (stk-1).

Example

Embedded_bedrock ROB-12: a build.rs attempt to set the linker via a cargo: print did nothing, and flip-link's absence was only found later by its real symptom.

How to fix

Set the linker in .cargo/config.toml (stk-1), not from build.rs; use build.rs only for directives Cargo documents.

How it is checked

cfg easy: scan build.rs for cargo: prints against the set of keys Cargo actually recognises, and flag anything outside it.

Source

Ported from embedded_bedrock's firmware check catalogue, STK-2 (book/checks.md, detail in book/checks/stk.md). Found on: embedded_bedrock ROB-12.

Configure

[lints.stk-2]
level = "deny"
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(stk-2) <reason> (waivers); the code works there too, as in [lints.F0092].