Skip to content

Commit 7d53d47

Browse files
committed
Remove DefKind::ImplTraitPlaceholder
1 parent fecf098 commit 7d53d47

File tree

25 files changed

+48
-64
lines changed

25 files changed

+48
-64
lines changed

compiler/rustc_hir/src/def.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ pub enum DefKind {
109109
InlineConst,
110110
/// Opaque type, aka `impl Trait`.
111111
OpaqueTy,
112-
/// A return-position `impl Trait` in a trait definition
113-
ImplTraitPlaceholder,
114112
Field,
115113
/// Lifetime parameter: the `'a` in `struct Foo<'a> { ... }`
116114
LifetimeParam,
@@ -140,7 +138,6 @@ impl DefKind {
140138
panic!("impossible struct constructor")
141139
}
142140
DefKind::OpaqueTy => "opaque type",
143-
DefKind::ImplTraitPlaceholder => "opaque type in trait",
144141
DefKind::TyAlias => "type alias",
145142
DefKind::TraitAlias => "trait alias",
146143
DefKind::AssocTy => "associated type",
@@ -220,8 +217,7 @@ impl DefKind {
220217
| DefKind::Use
221218
| DefKind::ForeignMod
222219
| DefKind::GlobalAsm
223-
| DefKind::Impl
224-
| DefKind::ImplTraitPlaceholder => None,
220+
| DefKind::Impl => None,
225221
}
226222
}
227223

@@ -258,7 +254,6 @@ impl DefKind {
258254
| DefKind::Use
259255
| DefKind::ForeignMod
260256
| DefKind::OpaqueTy
261-
| DefKind::ImplTraitPlaceholder
262257
| DefKind::Impl
263258
| DefKind::Field
264259
| DefKind::TyParam

compiler/rustc_hir/src/target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Target {
102102
DefKind::ForeignMod => Target::ForeignMod,
103103
DefKind::GlobalAsm => Target::GlobalAsm,
104104
DefKind::TyAlias => Target::TyAlias,
105-
DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder => Target::OpaqueTy,
105+
DefKind::OpaqueTy => Target::OpaqueTy,
106106
DefKind::Enum => Target::Enum,
107107
DefKind::Struct => Target::Struct,
108108
DefKind::Union => Target::Union,

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
24062406

24072407
let span = path.span;
24082408
match path.res {
2409-
Res::Def(DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder, did) => {
2409+
Res::Def(DefKind::OpaqueTy, did) => {
24102410
// Check for desugared `impl Trait`.
24112411
assert!(ty::is_impl_trait_defn(tcx, did).is_none());
24122412
let item_segment = path.segments.split_last().unwrap();

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,6 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
561561
check_union(tcx, id.owner_id.def_id);
562562
}
563563
DefKind::OpaqueTy => {
564-
check_opaque(tcx, id);
565-
}
566-
DefKind::ImplTraitPlaceholder => {
567564
if let Some((fn_def_id, _)) =
568565
tcx.def_path(id.owner_id.to_def_id()).get_impl_trait_in_trait_data()
569566
{
@@ -575,6 +572,8 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
575572
{
576573
check_opaque(tcx, id);
577574
}
575+
} else {
576+
check_opaque(tcx, id);
578577
}
579578
}
580579
DefKind::TyAlias => {

compiler/rustc_hir_analysis/src/check/compare_method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl<'tcx> TypeFolder<'tcx> for ImplTraitInTraitCollector<'_, 'tcx> {
582582

583583
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
584584
if let ty::Projection(proj) = ty.kind()
585-
&& self.tcx().def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder
585+
&& self.tcx().def_path(proj.item_def_id).get_impl_trait_in_trait_data().is_some()
586586
{
587587
if let Some((ty, _)) = self.types.get(&proj.item_def_id) {
588588
return *ty;

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter};
2-
use hir::def::DefKind;
32
use rustc_ast as ast;
43
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
54
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
@@ -1588,8 +1587,7 @@ fn check_return_position_impl_trait_in_trait_bounds<'tcx>(
15881587
for arg in fn_output.walk() {
15891588
if let ty::GenericArgKind::Type(ty) = arg.unpack()
15901589
&& let ty::Projection(proj) = ty.kind()
1591-
&& tcx.def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder
1592-
&& let (trait_fn_def_id, _) = tcx.def_path(proj.item_def_id).get_impl_trait_in_trait_data().unwrap()
1590+
&& let Some((trait_fn_def_id, _)) = tcx.def_path(proj.item_def_id).get_impl_trait_in_trait_data()
15931591
&& trait_fn_def_id == fn_def_id.to_def_id()
15941592
{
15951593
let bounds = wfcx.tcx().explicit_item_bounds(proj.item_def_id);

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use super::{check_fn, Expectation, FnCtxt, GeneratorTypes};
44

5-
use hir::def::DefKind;
65
use rustc_hir as hir;
76
use rustc_hir::def_id::LocalDefId;
87
use rustc_hir::lang_items::LangItem;
@@ -681,7 +680,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
681680
.find_map(|(p, s)| get_future_output(p, s))?,
682681
ty::Error(_) => return None,
683682
ty::Projection(proj)
684-
if self.tcx.def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder =>
683+
if self.tcx.def_path(proj.item_def_id).get_impl_trait_in_trait_data().is_some() =>
685684
{
686685
self.tcx
687686
.bound_explicit_item_bounds(proj.item_def_id)

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
6565
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed, IntoDiagnosticArg};
6666
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString, MultiSpan};
6767
use rustc_hir as hir;
68-
use rustc_hir::def::DefKind;
6968
use rustc_hir::def_id::{DefId, LocalDefId};
7069
use rustc_hir::intravisit::Visitor;
7170
use rustc_hir::lang_items::LangItem;
@@ -1839,8 +1838,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
18391838
)
18401839
}
18411840
(true, ty::Projection(proj))
1842-
if self.tcx.def_kind(proj.item_def_id)
1843-
== DefKind::ImplTraitPlaceholder =>
1841+
if self.tcx.def_path(proj.item_def_id).get_impl_trait_in_trait_data().is_some() =>
18441842
{
18451843
let sm = self.tcx.sess.source_map();
18461844
let pos = sm.lookup_char_pos(self.tcx.def_span(proj.item_def_id).lo());

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::errors::OpaqueHiddenTypeDiag;
22
use crate::infer::{DefiningAnchor, InferCtxt, InferOk};
33
use crate::traits;
4-
use hir::def::DefKind;
54
use hir::def_id::{DefId, LocalDefId};
65
use hir::{HirId, OpaqueTyOrigin};
76
use rustc_data_structures::sync::Lrc;
@@ -556,8 +555,10 @@ impl<'tcx> InferCtxt<'tcx> {
556555
// FIXME(RPITIT): Don't replace RPITITs with inference vars.
557556
ty::Projection(projection_ty)
558557
if !projection_ty.has_escaping_bound_vars()
559-
&& tcx.def_kind(projection_ty.item_def_id)
560-
!= DefKind::ImplTraitPlaceholder =>
558+
&& tcx
559+
.def_path(projection_ty.item_def_id)
560+
.get_impl_trait_in_trait_data()
561+
.is_none() =>
561562
{
562563
self.infer_projection(
563564
param_env,

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ fn should_encode_visibility(def_kind: DefKind) -> bool {
820820
| DefKind::Use
821821
| DefKind::ForeignMod
822822
| DefKind::OpaqueTy
823-
| DefKind::ImplTraitPlaceholder
824823
| DefKind::Impl
825824
| DefKind::Field => true,
826825
DefKind::TyParam
@@ -853,7 +852,6 @@ fn should_encode_stability(def_kind: DefKind) -> bool {
853852
| DefKind::ForeignMod
854853
| DefKind::TyAlias
855854
| DefKind::OpaqueTy
856-
| DefKind::ImplTraitPlaceholder
857855
| DefKind::Enum
858856
| DefKind::Union
859857
| DefKind::Impl
@@ -942,7 +940,6 @@ fn should_encode_variances(def_kind: DefKind) -> bool {
942940
| DefKind::ForeignMod
943941
| DefKind::TyAlias
944942
| DefKind::OpaqueTy
945-
| DefKind::ImplTraitPlaceholder
946943
| DefKind::Impl
947944
| DefKind::Trait
948945
| DefKind::TraitAlias
@@ -979,7 +976,6 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
979976
| DefKind::AnonConst
980977
| DefKind::InlineConst
981978
| DefKind::OpaqueTy
982-
| DefKind::ImplTraitPlaceholder
983979
| DefKind::Impl
984980
| DefKind::Field
985981
| DefKind::TyParam
@@ -1008,7 +1004,6 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
10081004
| DefKind::Const
10091005
| DefKind::Static(..)
10101006
| DefKind::TyAlias
1011-
| DefKind::OpaqueTy
10121007
| DefKind::ForeignTy
10131008
| DefKind::Impl
10141009
| DefKind::AssocFn
@@ -1019,7 +1014,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
10191014
| DefKind::AnonConst
10201015
| DefKind::InlineConst => true,
10211016

1022-
DefKind::ImplTraitPlaceholder => {
1017+
DefKind::OpaqueTy => {
10231018
if let Some((fn_def_id, _)) =
10241019
tcx.def_path(def_id.to_def_id()).get_impl_trait_in_trait_data()
10251020
{
@@ -1033,7 +1028,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
10331028
}
10341029
}
10351030
} else {
1036-
bug!();
1031+
true
10371032
}
10381033
}
10391034

@@ -1076,7 +1071,6 @@ fn should_encode_const(def_kind: DefKind) -> bool {
10761071
| DefKind::Static(..)
10771072
| DefKind::TyAlias
10781073
| DefKind::OpaqueTy
1079-
| DefKind::ImplTraitPlaceholder
10801074
| DefKind::ForeignTy
10811075
| DefKind::Impl
10821076
| DefKind::AssocFn
@@ -1117,7 +1111,7 @@ fn should_encode_trait_impl_trait_tys<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) ->
11171111
tcx.fn_sig(trait_item_def_id).skip_binder().output().walk().any(|arg| {
11181112
if let ty::GenericArgKind::Type(ty) = arg.unpack()
11191113
&& let ty::Projection(data) = ty.kind()
1120-
&& tcx.def_kind(data.item_def_id) == DefKind::ImplTraitPlaceholder
1114+
&& tcx.def_path(data.item_def_id).get_impl_trait_in_trait_data().is_some()
11211115
{
11221116
true
11231117
} else {

0 commit comments

Comments
 (0)