A plenty of questions about Reference/Language

The form of this post basically guaranteed a dumpster fire of a discussion, so apologies if I've missed places where these are already settled.

  1. I think I disagree slightly with @paramagnetic. I gather from context that a "qualified path" in this sentence is not the same thing as a QualifiedPathInExpression or QualifiedPathInType but rather any path that is qualified, i.e. contains a "namespace qualifier (::)". (See also "Path qualifiers".) The reference would benefit from a single clear definition of "qualified path".

    Anyway, the sentence you quoted states a restriction in addition to the grammar. It is not merely restating the grammar. ::A syntactically matches the grammar, but since it doesn't refer to an associated constant, you'll get a compiler error.

    <Enum>::A is allowed and refers to an enum variant (or "constructor"). I think it must be that for the purpose of this sentence, that's considered a constant even though it wasn't defined with const. But you're right, I don't see anywhere that is spelled out and the reference should say what it means.

  2. Another badly worded bit of the reference. The distinction is between structural types and nominal types. Rust has a nominal type system.

  3. Another badly worded bit of the reference. All this means is that a function pointer type has many different possible values, all the possible functions and non-capturing closures matching that signature. The type of each individual fn item and closure is known at compile time; but in code that takes a function pointer as an argument, the identity of the function is not known at compile time. Any function with that signature could be passed in.

  4. The reference seems to say so. If that's wrong, it's worth filing an issue against the documentation.

  5. Yes.

Please consider filing issues about these. Perhaps individual issues instead of one big issue.

1 Like