about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-03 23:11:17 +0000
committerbors <bors@rust-lang.org>2019-05-03 23:11:17 +0000
commit13fde05b12c28e1ed66bd13fdf1ea392f166b811 (patch)
treefb8d9b9657887be7e011edf90cd0d1c739a88cbc /src/test
parenta3404557c54ea48fb8efc805d93c450beb3364d4 (diff)
parentff174fe09e2e0a8f959b970e6ec410b3aafbc58a (diff)
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
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/imports/issue-53269.rs2
-rw-r--r--src/test/ui/imports/issue-53512.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/test/ui/imports/issue-53269.rs b/src/test/ui/imports/issue-53269.rs
index 444a16f7e7a..1031d507101 100644
--- a/src/test/ui/imports/issue-53269.rs
+++ b/src/test/ui/imports/issue-53269.rs
@@ -1,4 +1,4 @@
-// Ambiguity between a `macro_rules` macro and a non-existent import recovered as `Def::Err`
+// Ambiguity between a `macro_rules` macro and a non-existent import recovered as `Res::Err`
 
 macro_rules! mac { () => () }
 
diff --git a/src/test/ui/imports/issue-53512.rs b/src/test/ui/imports/issue-53512.rs
index 61d93531a15..615b36a0b21 100644
--- a/src/test/ui/imports/issue-53512.rs
+++ b/src/test/ui/imports/issue-53512.rs
@@ -1,4 +1,4 @@
-// Macro from prelude is shadowed by non-existent import recovered as `Def::Err`.
+// Macro from prelude is shadowed by non-existent import recovered as `Res::Err`.
 
 use std::assert; //~ ERROR unresolved import `std::assert`