Cargo "strict mode"

Would it make sense to add a "strict" mode to Cargo, i.e. one where Cargo errors on an unknown key rather than warning? It would prevent issues like today's universally by telling Cargo to not try to accept keys it knows nothing about.

4 Likes

Wouldn't it be even better to make this the default and offer an opt-out?

2 Likes

I would like to see some kind of escape hatch for "plugin keys", With a guarantee that cargo itself will never give meaning to keys with a specific prefix.

I tested out the idea in a patch, but haven't untangled my words yet to post an RFC (perhaps anyway, the recent issue has given me some pause.)

this implements said keys as "@pluginname.foo" = "bar"

1 Like

@ratmice this already exists for top-level config under the [package.metadata] table, e.g. docs.rs uses [package.metadata.docs.rs] to configure its build. If you want per-dependency metadata that could be encoded as a side-table like:

[package.metadata.pluginname.dependencies]
depname = { foo = "bar" }
4 Likes

It's part 1 of a 2 part proposal. I don't really want to get into the 2nd part here since it isn't applicable at all to the thread really. But it essentially maps a key to an array of tables, which is much harder when said keys are non-local.