Expand description
The GNU compatibility surface: features.toml, attributes, builtins, pragmas.
Design: spec/13-gnu-compat.md. Layer rank 4, see spec/18-package-layout.md.
§Status
The matrix is real. features.toml next to this file is the source of truth for what the
compiler claims to support, build.rs turns it into the table below, and the __has_*
family in the preprocessor answers out of it. The attributes and builtins themselves land
with the parser, and every row that says unimplemented says so because it is.
The rule that makes the table worth having is in section 13.2: answering __has_builtin
untruthfully is worse than answering no, because a header that gets a yes and then fails
to compile is much harder to diagnose than one that takes its fallback path. So only a row
marked implemented answers yes, and a row marked implemented with no test named
against it fails the build.
use rucc_gnu::{Kind, Status};
assert_eq!(rucc_gnu::has_feature("__has_include"), 1);
assert_eq!(rucc_gnu::has_attribute("cleanup"), 0, "not until the parser lands");
assert_eq!(rucc_gnu::has_attribute("no_such_attribute"), 0);
// The armoured spelling is the same question.
assert_eq!(rucc_gnu::lookup(Kind::Attribute, "__packed__").map(|f| f.name), Some("packed"));
// Nested functions are refused rather than pending, and the table says which.
let nested = rucc_gnu::lookup(Kind::Extension, "nested_functions").unwrap();
assert_eq!(nested.status, Status::Rejected);Every crate in the workspace is published, and publishing implies a promise. This one is
tier 3: its Rust API is explicitly unstable and will change without a major version bump.
Depend on the rucc binary’s behaviour, not on this.
Structs§
- Feature
- One row of the matrix.
Enums§
- Answer
- What happens when the compiler meets something this row describes and cannot do it.
- Kind
- What kind of thing a row of the matrix describes.
- Status
- How far along a row is.
Constants§
- MILESTONE
- The milestone in
spec/17-milestones.mdthat fills this crate in.
Statics§
- FEATURES
- Every row of the matrix, sorted by kind and then by name.
Functions§
- features
- The whole matrix, sorted by kind and then by name.
- has_
attribute - What
__has_attribute(name)answers. - has_
builtin - What
__has_builtin(name)answers. - has_
c_ attribute - What
__has_c_attribute(name)answers, which is the number the standard gives the attribute rather than one. - has_
extension - What
__has_extension(name)answers. - has_
feature - What
__has_feature(name)answers. - lookup
- The row for a name, if the matrix has one.