Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: rename TypeRef and *Type to *TypeRepr, ty to type_repr, and expand some abbreviations in generated docs #18174

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

redsun82
Copy link
Contributor

@redsun82 redsun82 commented Dec 2, 2024

We were already renaming the tip of the type reference hierarchy from Type to TypeRef but weren't doing so with all its descendants.

Additionally, the pat and ty abbreviations are now expanded in generated documentation.

@redsun82 redsun82 requested a review from a team as a code owner December 2, 2024 09:16
@github-actions github-actions bot added the Rust Pull requests that update Rust code label Dec 2, 2024
@paldepind
Copy link
Contributor

Why do we want to rename *Type to *TypeRef? Why are they type references and not just types?

@redsun82
Copy link
Contributor Author

redsun82 commented Dec 2, 2024

Why do we want to rename *Type to *TypeRef? Why are they type references and not just types?

These are all instances of types written in the code (they are AstNodes, they have a location), and especially they can be optional. "Real" types are semantic, unique despite all the different references to them, and also present for terms that don't have a type spelled out in the code, so they really are a different thing from what I changed here.

@redsun82
Copy link
Contributor Author

redsun82 commented Dec 2, 2024

so they really are a different thing from what I changed here

(a thing we don't have, yet)

@paldepind
Copy link
Contributor

paldepind commented Dec 2, 2024

Thanks for the explanation @redsun82 👍 🙏 . I guess the name "Ref" wasn't immediately intuitive to me, but aside from that it makes sense. It's the distinction between syntax or notation representing a type and the actual type itself.

paldepind
paldepind previously approved these changes Dec 2, 2024
@redsun82
Copy link
Contributor Author

redsun82 commented Dec 2, 2024

Thanks for the explanation @redsun82 👍 🙏 . I guess the name "Ref" wasn't immediately intuitive to me, but aside from that it makes sense. It's the distinction between syntax or notation representing a type and the actual type itself.

we could also opt for using Repr instead of Ref (that's what we do in Swift for example). Do you think that would be clearer?

@paldepind
Copy link
Contributor

we could also opt for using Repr instead of Ref (that's what we do in Swift for example). Do you think that would be clearer?

Yes, subjectively I think that would be better! That also avoids clashes/confusion with the Rust concept of a reference. For instance the current class name RefTypeRef is a bit awkward.

@redsun82 redsun82 changed the title Rust: rename *Type to *TypeRef and expand some abbreviations in generated docs Rust: rename TypeRef and *Type to *TypeRepr and expand some abbreviations in generated docs Dec 3, 2024
import codeql.rust.elements.Pat
import codeql.rust.elements.Path
import codeql.rust.elements.PathExpr
import codeql.rust.elements.PathExprBase
import codeql.rust.elements.PathPat
import codeql.rust.elements.PathSegment
import codeql.rust.elements.PathType
import codeql.rust.elements.PathTypeRepr

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.PathSegment
.
import codeql.rust.elements.Rename
import codeql.rust.elements.Resolvable
import codeql.rust.elements.RestPat
import codeql.rust.elements.RetType
import codeql.rust.elements.RetTypeRepr

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.AssocTypeArg
.
Redundant import, the module is already imported inside
codeql.rust.elements.ClosureExpr
.
Redundant import, the module is already imported inside
codeql.rust.elements.FnPtrTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.Function
.
Redundant import, the module is already imported inside
codeql.rust.elements.PathSegment
.
import codeql.rust.elements.TypeAlias
import codeql.rust.elements.TypeArg
import codeql.rust.elements.TypeBound
import codeql.rust.elements.TypeBoundList
import codeql.rust.elements.TypeParam
import codeql.rust.elements.TypeRef
import codeql.rust.elements.TypeRepr

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.ArrayTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.AssocTypeArg
.
Redundant import, the module is already imported inside
codeql.rust.elements.CastExpr
.
Redundant import, the module is already imported inside
codeql.rust.elements.Const
.
Redundant import, the module is already imported inside
codeql.rust.elements.ConstParam
.
Redundant import, the module is already imported inside
codeql.rust.elements.DynTraitTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.FnPtrTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.ForTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.Impl
.
Redundant import, the module is already imported inside
codeql.rust.elements.ImplTraitTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.InferTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.LetStmt
.
Redundant import, the module is already imported inside
codeql.rust.elements.MacroTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.NeverTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.OffsetOfExpr
.
Redundant import, the module is already imported inside
codeql.rust.elements.ParamBase
.
Redundant import, the module is already imported inside
codeql.rust.elements.ParenTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.PathSegment
.
Redundant import, the module is already imported inside
codeql.rust.elements.PathTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.PtrTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.RecordField
.
Redundant import, the module is already imported inside
codeql.rust.elements.RefTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.RetTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.SliceTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.Static
.
Redundant import, the module is already imported inside
codeql.rust.elements.TupleField
.
Redundant import, the module is already imported inside
codeql.rust.elements.TupleTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.TypeAlias
.
Redundant import, the module is already imported inside
codeql.rust.elements.TypeArg
.
Redundant import, the module is already imported inside
codeql.rust.elements.TypeBound
.
Redundant import, the module is already imported inside
codeql.rust.elements.TypeParam
.
Redundant import, the module is already imported inside
codeql.rust.elements.WherePred
.
import codeql.rust.elements.ReturnTypeSyntax
import codeql.rust.elements.TypeBoundList
import codeql.rust.elements.TypeRef
import codeql.rust.elements.TypeRepr

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.RetTypeRepr
.
import codeql.rust.elements.Abi
import codeql.rust.elements.ParamList
import codeql.rust.elements.RetTypeRepr
import codeql.rust.elements.TypeRepr

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.RetTypeRepr
.
import codeql.rust.elements.ReturnTypeSyntax
import codeql.rust.elements.TypeRef
import codeql.rust.elements.TypeRepr

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.PathTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.RetTypeRepr
.
*/

private import internal.RetTypeReprImpl
import codeql.rust.elements.AstNode

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.TypeRepr
.
import codeql.rust.elements.ReturnTypeSyntax
import codeql.rust.elements.TypeBoundList
import codeql.rust.elements.TypeRef
import codeql.rust.elements.TypeRepr

Check warning

Code scanning / CodeQL

Redundant import Warning generated

Redundant import, the module is already imported inside
codeql.rust.elements.RetTypeRepr
.
import codeql.rust.elements.ReturnTypeSyntax
import codeql.rust.elements.TypeRef
import codeql.rust.elements.TypeRepr

Check warning

Code scanning / CodeQL

Redundant import Warning generated

Redundant import, the module is already imported inside
codeql.rust.elements.PathTypeRepr
.
Redundant import, the module is already imported inside
codeql.rust.elements.RetTypeRepr
.
@redsun82 redsun82 changed the title Rust: rename TypeRef and *Type to *TypeRepr and expand some abbreviations in generated docs Rust: rename TypeRef and *Type to *TypeRepr, ty to type_repr, and expand some abbreviations in generated docs Dec 3, 2024
@redsun82
Copy link
Contributor Author

redsun82 commented Dec 3, 2024

@paldepind I went with the rename to TypeRepr, I also find it more intuitive. I've also changed all the getTy predicates to more explicit getTypeRepr (which will also cause less confusion when we start to have getType for actual semantic types), and went for a more specific getElementTypeRepr for ArrayTypeRepr.

paldepind
paldepind previously approved these changes Dec 3, 2024
Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great changes 🤩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants