Structural types again -- desugar to named struct in std

ok, so def-site hygiene can be accounted for by adding an extra field to NAMES:

// in std::somewhere
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
pub struct FieldName {
    pub name: &'static str,
    pub hygiene: &'static str,
pub struct AnonymousStruct<Fields: std::marker::Tuple, const NAMES: &'static [FieldName]>(pub Fields);

I'm assuming the compiler can provide a unique string for each hygiene, probably a combination of crate name, module path, path to identifier in module, and some optional disambiguator for anonymous scopes. globally nameable hygienes would just be the empty string.

That's roughly the structure I was intending for Atom, but not pub because I don't think there should be a public API for creating hygienic names other than copying ones handed to user code by AnonymousStruct instances created by the compiler on parsing a { a: u32 } type. It seems like it would be a huge stability issue if you could just stick hygiene strings in there with the (current) compiler mangling scheme and being able to forge identifiers created in random macros.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.