-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #60462 - eddyb:def-1-a-mere-resolution, r=petrochenkov
rustc: factor out most of hir::def::Def's variants into DefKind, and rename to Res. The first two commits are about introducing `DefKind`, both to simplify/orthogonalize `hir::def::Def`, and to allow reasoning about the kind of a definition without dealing with the redundant `DefId`. (There are likely more changes to be made, such as adding enough `DefKind` variants for `tcx.def_kind(def_id)` to return just `DefKind`, not `Option<DefKind>`, but this is pretty big as-is) The third commit frees up the `Def` name (which we may want to use in the future for "definitions", in the sense of "entities with a `DefId`") by renaming `hir::def::Def` to `Res` ("resolution"). IMO this fits, as it represents all the possible name resolution results, not just "definitions (with a `DefId`)". Quick examples: ```rust // Before: if tcx.describe_def(def_id) == Some(Def::Struct(def_id)) {...} if let Def::Struct(def_id) = path.def {...} ``` ```rust // After: if tcx.def_kind(def_id) == Some(DefKind::Struct) {...} if let Res::Def(DefKind::Struct, def_id) = path.res {...} ``` r? @petrochenkov cc @rust-lang/compiler
- Loading branch information
Showing
61 changed files
with
1,840 additions
and
1,692 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.