Skip to content

Rust-dogme #632

Open
Open
@graydon

Description

@graydon

In response to: https://llogiq.github.io/2016/02/05/hundred-sequel.html

Well, you asked for a followup! I guess I don't really know if lints are similar enough to restrictions to go in the same tool, which is why I phrased it in terms of a possibly-different tool. But I did want to at least broach the topic because people seem to pleased with clippy, and it's only exercising part of the intended purpose of the allow/warn/deny/forbid (AWDF?) system.

It's not just there to help you catch mistakes; it was also explicitly built as a way to restrict yourself (or .. your team) to subsets of the language. Like the difference between deny and forbid, or the application of those levels to specific modules scopes. These are part of the system so that you can make policy, at a relatively high level, about prohibited features in a project. My motivation/inspiration for this was always the set of restrictions you can pragma-into in the Ada language:

https://en.wikibooks.org/wiki/Ada_Programming/Pragmas/Restrictions

So I guess I'll leave this as a marker for that purpose, if anyone's interested. There are obviously multiple "levels" to doing this sort of thing -- strictly local analyses, intra-crate, or inter-crate come to mind! -- but even the local ones have some utility, and you can imagine approximating others even if the analysis isn't entirely sound. For example it'd be relatively easy to forbid dynamic dispatch locally, or operator overloading, or floating point, dynamic array indexing, explicit lifetimes, raw pointers, casting, destructors, recursion, panics, calls to particular lang items or intrinsics, marker traits, macros, mutability, statics, unsized types, target-dependent types ... I'm sure there are many others.

In contrast to lints, restrictions are not things that are "probably an error" when used; they're more things that you might, for peculiar and problem-specific reasons, feel disinclined to use. Even though they're perfectly good language features. You just might want to opt your project out of using them. Maybe they have too much performance variability at runtime, or require target-environment support you can't provide -- limited stack, no FPU, etc. -- or make your program harder to reason about, or make a 3rd party tool's analysis of your program harder, or simply seem distasteful to your team for some personal reason.

(I jokingly suggested calling such a tool rust-dogme, in reference to https://en.wikipedia.org/wiki/Dogme_95 ... which perhaps captures a more "artistic-purity" element of the idea also)

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-needs-discussionStatus: Needs further discussion before merging or work can be started

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions