Skip to content

Commit 4201fd2

Browse files
committed
Remove associated opaque types
They're unused now.
1 parent 4e49e67 commit 4201fd2

File tree

36 files changed

+116
-300
lines changed

36 files changed

+116
-300
lines changed

src/librustc_hir/def.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,11 @@ pub enum DefKind {
5454
/// Refers to the variant itself, `DefKind::Ctor` refers to its constructor if it exists.
5555
Variant,
5656
Trait,
57-
/// `type Foo = impl Bar;`
58-
OpaqueTy,
5957
/// `type Foo = Bar;`
6058
TyAlias,
6159
ForeignTy,
6260
TraitAlias,
6361
AssocTy,
64-
/// `type Foo = impl Bar;`
65-
AssocOpaqueTy,
6662
TyParam,
6763

6864
// Value namespace
@@ -83,6 +79,7 @@ pub enum DefKind {
8379
Use,
8480
ForeignMod,
8581
AnonConst,
82+
OpaqueTy,
8683
Field,
8784
LifetimeParam,
8885
GlobalAsm,
@@ -115,7 +112,6 @@ impl DefKind {
115112
DefKind::TyAlias => "type alias",
116113
DefKind::TraitAlias => "trait alias",
117114
DefKind::AssocTy => "associated type",
118-
DefKind::AssocOpaqueTy => "associated opaque type",
119115
DefKind::Union => "union",
120116
DefKind::Trait => "trait",
121117
DefKind::ForeignTy => "foreign type",
@@ -143,7 +139,6 @@ impl DefKind {
143139
match *self {
144140
DefKind::AssocTy
145141
| DefKind::AssocConst
146-
| DefKind::AssocOpaqueTy
147142
| DefKind::AssocFn
148143
| DefKind::Enum
149144
| DefKind::OpaqueTy
@@ -168,7 +163,6 @@ impl DefKind {
168163
| DefKind::ForeignTy
169164
| DefKind::TraitAlias
170165
| DefKind::AssocTy
171-
| DefKind::AssocOpaqueTy
172166
| DefKind::TyParam => ns == Namespace::TypeNS,
173167

174168
DefKind::Fn

src/librustc_hir/hir.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,14 +1919,12 @@ pub enum ImplItemKind<'hir> {
19191919
Fn(FnSig<'hir>, BodyId),
19201920
/// An associated type.
19211921
TyAlias(&'hir Ty<'hir>),
1922-
/// An associated `type = impl Trait`.
1923-
OpaqueTy(GenericBounds<'hir>),
19241922
}
19251923

19261924
impl ImplItemKind<'_> {
19271925
pub fn namespace(&self) -> Namespace {
19281926
match self {
1929-
ImplItemKind::OpaqueTy(..) | ImplItemKind::TyAlias(..) => Namespace::TypeNS,
1927+
ImplItemKind::TyAlias(..) => Namespace::TypeNS,
19301928
ImplItemKind::Const(..) | ImplItemKind::Fn(..) => Namespace::ValueNS,
19311929
}
19321930
}
@@ -2016,8 +2014,6 @@ pub struct OpaqueTy<'hir> {
20162014
/// From whence the opaque type came.
20172015
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
20182016
pub enum OpaqueTyOrigin {
2019-
/// `type Foo = impl Trait;`
2020-
TypeAlias,
20212017
/// `-> impl Trait`
20222018
FnReturn,
20232019
/// `async fn`
@@ -2614,7 +2610,6 @@ pub enum AssocItemKind {
26142610
Const,
26152611
Fn { has_self: bool },
26162612
Type,
2617-
OpaqueTy,
26182613
}
26192614

26202615
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]

src/librustc_hir/intravisit.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,10 +1007,6 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
10071007
visitor.visit_id(impl_item.hir_id);
10081008
visitor.visit_ty(ty);
10091009
}
1010-
ImplItemKind::OpaqueTy(bounds) => {
1011-
visitor.visit_id(impl_item.hir_id);
1012-
walk_list!(visitor, visit_param_bound, bounds);
1013-
}
10141010
}
10151011
}
10161012

src/librustc_hir_pretty/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,12 +1003,6 @@ impl<'a> State<'a> {
10031003
hir::ImplItemKind::TyAlias(ref ty) => {
10041004
self.print_associated_type(ii.ident, &ii.generics, None, Some(ty));
10051005
}
1006-
hir::ImplItemKind::OpaqueTy(bounds) => {
1007-
self.word_space("type");
1008-
self.print_ident(ii.ident);
1009-
self.print_bounds("= impl", bounds);
1010-
self.s.word(";");
1011-
}
10121006
}
10131007
self.ann.post(self, AnnNode::SubItem(ii.hir_id))
10141008
}

src/librustc_incremental/persist/dirty_clean.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ impl DirtyCleanVisitor<'tcx> {
336336
ImplItemKind::Fn(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL),
337337
ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
338338
ImplItemKind::TyAlias(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
339-
ImplItemKind::OpaqueTy(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
340339
},
341340
_ => self.tcx.sess.span_fatal(
342341
attr.span,

src/librustc_infer/infer/error_reporting/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ fn trait_item_scope_tag(item: &hir::TraitItem<'_>) -> &'static str {
224224
fn impl_item_scope_tag(item: &hir::ImplItem<'_>) -> &'static str {
225225
match item.kind {
226226
hir::ImplItemKind::Fn(..) => "method body",
227-
hir::ImplItemKind::Const(..)
228-
| hir::ImplItemKind::OpaqueTy(..)
229-
| hir::ImplItemKind::TyAlias(..) => "associated item",
227+
hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(..) => "associated item",
230228
}
231229
}
232230

src/librustc_metadata/rmeta/decoder.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ impl EntryKind {
579579
EntryKind::ConstParam => DefKind::ConstParam,
580580
EntryKind::OpaqueTy => DefKind::OpaqueTy,
581581
EntryKind::AssocType(_) => DefKind::AssocTy,
582-
EntryKind::AssocOpaqueTy(_) => DefKind::AssocOpaqueTy,
583582
EntryKind::Mod(_) => DefKind::Mod,
584583
EntryKind::Variant(_) => DefKind::Variant,
585584
EntryKind::Trait(_) => DefKind::Trait,
@@ -1145,7 +1144,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11451144
(ty::AssocKind::Fn, data.container, data.has_self)
11461145
}
11471146
EntryKind::AssocType(container) => (ty::AssocKind::Type, container, false),
1148-
EntryKind::AssocOpaqueTy(container) => (ty::AssocKind::OpaqueTy, container, false),
11491147
_ => bug!("cannot get associated-item of `{:?}`", def_key),
11501148
};
11511149

src/librustc_metadata/rmeta/encoder.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,6 @@ impl EncodeContext<'tcx> {
874874
}))
875875
}
876876
ty::AssocKind::Type => EntryKind::AssocType(container),
877-
ty::AssocKind::OpaqueTy => span_bug!(ast_item.span, "opaque type in trait"),
878877
});
879878
record!(self.tables.visibility[def_id] <- trait_item.vis);
880879
record!(self.tables.span[def_id] <- ast_item.span);
@@ -892,7 +891,6 @@ impl EncodeContext<'tcx> {
892891
self.encode_item_type(def_id);
893892
}
894893
}
895-
ty::AssocKind::OpaqueTy => unreachable!(),
896894
}
897895
if trait_item.kind == ty::AssocKind::Fn {
898896
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
@@ -957,7 +955,6 @@ impl EncodeContext<'tcx> {
957955
has_self: impl_item.fn_has_self_parameter,
958956
}))
959957
}
960-
ty::AssocKind::OpaqueTy => EntryKind::AssocOpaqueTy(container),
961958
ty::AssocKind::Type => EntryKind::AssocType(container)
962959
});
963960
record!(self.tables.visibility[def_id] <- impl_item.vis);
@@ -989,7 +986,7 @@ impl EncodeContext<'tcx> {
989986
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
990987
needs_inline || is_const_fn || always_encode_mir
991988
}
992-
hir::ImplItemKind::OpaqueTy(..) | hir::ImplItemKind::TyAlias(..) => false,
989+
hir::ImplItemKind::TyAlias(..) => false,
993990
};
994991
if mir {
995992
self.encode_optimized_mir(def_id.expect_local());
@@ -1786,7 +1783,7 @@ impl<'tcx, 'v> ParItemLikeVisitor<'v> for PrefetchVisitor<'tcx> {
17861783
self.prefetch_mir(def_id)
17871784
}
17881785
}
1789-
hir::ImplItemKind::OpaqueTy(..) | hir::ImplItemKind::TyAlias(..) => (),
1786+
hir::ImplItemKind::TyAlias(..) => (),
17901787
}
17911788
}
17921789
}

src/librustc_metadata/rmeta/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ enum EntryKind {
308308
Impl(Lazy<ImplData>),
309309
AssocFn(Lazy<AssocFnData>),
310310
AssocType(AssocContainer),
311-
AssocOpaqueTy(AssocContainer),
312311
AssocConst(AssocContainer, mir::ConstQualifs, Lazy<RenderedConst>),
313312
TraitAlias,
314313
}

src/librustc_middle/hir/map/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ impl<'hir> Map<'hir> {
228228
ImplItemKind::Const(..) => DefKind::AssocConst,
229229
ImplItemKind::Fn(..) => DefKind::AssocFn,
230230
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
231-
ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy,
232231
},
233232
Node::Variant(_) => DefKind::Variant,
234233
Node::Ctor(variant_data) => {
@@ -1023,9 +1022,6 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String {
10231022
ImplItemKind::TyAlias(_) => {
10241023
format!("assoc type {} in {}{}", ii.ident, path_str(), id_str)
10251024
}
1026-
ImplItemKind::OpaqueTy(_) => {
1027-
format!("assoc opaque type {} in {}{}", ii.ident, path_str(), id_str)
1028-
}
10291025
},
10301026
Some(Node::TraitItem(ti)) => {
10311027
let kind = match ti.kind {

src/librustc_middle/traits/specialization_graph.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,11 @@ impl<'tcx> Node {
100100
trait_item_kind: ty::AssocKind,
101101
trait_def_id: DefId,
102102
) -> Option<ty::AssocItem> {
103-
use crate::ty::AssocKind::*;
104-
105103
tcx.associated_items(self.def_id())
106104
.filter_by_name_unhygienic(trait_item_name.name)
107105
.find(move |impl_item| {
108-
match (trait_item_kind, impl_item.kind) {
109-
| (Const, Const)
110-
| (Fn, Fn)
111-
| (Type, Type)
112-
| (Type, OpaqueTy) // assoc. types can be made opaque in impls
113-
=> tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id),
114-
115-
| (Const, _)
116-
| (Fn, _)
117-
| (Type, _)
118-
| (OpaqueTy, _)
119-
=> false,
120-
}
106+
trait_item_kind == impl_item.kind
107+
&& tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id)
121108
})
122109
.copied()
123110
}

src/librustc_middle/ty/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ fn foo(&self) -> Self::T { String::new() }
814814
// FIXME: account for `#![feature(specialization)]`
815815
for item in &items[..] {
816816
match item.kind {
817-
hir::AssocItemKind::Type | hir::AssocItemKind::OpaqueTy => {
817+
hir::AssocItemKind::Type => {
818818
// FIXME: account for returning some type in a trait fn impl that has
819819
// an assoc type as a return type (#72076).
820820
if let hir::Defaultness::Default { has_value: true } = item.defaultness
@@ -838,7 +838,7 @@ fn foo(&self) -> Self::T { String::new() }
838838
})) => {
839839
for item in &items[..] {
840840
match item.kind {
841-
hir::AssocItemKind::Type | hir::AssocItemKind::OpaqueTy => {
841+
hir::AssocItemKind::Type => {
842842
if self.type_of(self.hir().local_def_id(item.id.hir_id)) == found {
843843
db.span_label(item.span, "expected this associated type");
844844
return true;

src/librustc_middle/ty/mod.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,13 @@ pub struct AssocItem {
198198
pub enum AssocKind {
199199
Const,
200200
Fn,
201-
OpaqueTy,
202201
Type,
203202
}
204203

205204
impl AssocKind {
206205
pub fn namespace(&self) -> Namespace {
207206
match *self {
208-
ty::AssocKind::OpaqueTy | ty::AssocKind::Type => Namespace::TypeNS,
207+
ty::AssocKind::Type => Namespace::TypeNS,
209208
ty::AssocKind::Const | ty::AssocKind::Fn => Namespace::ValueNS,
210209
}
211210
}
@@ -215,22 +214,11 @@ impl AssocKind {
215214
AssocKind::Const => DefKind::AssocConst,
216215
AssocKind::Fn => DefKind::AssocFn,
217216
AssocKind::Type => DefKind::AssocTy,
218-
AssocKind::OpaqueTy => DefKind::AssocOpaqueTy,
219217
}
220218
}
221219
}
222220

223221
impl AssocItem {
224-
/// Tests whether the associated item admits a non-trivial implementation
225-
/// for !
226-
pub fn relevant_for_never(&self) -> bool {
227-
match self.kind {
228-
AssocKind::OpaqueTy | AssocKind::Const | AssocKind::Type => true,
229-
// FIXME(canndrew): Be more thorough here, check if any argument is uninhabited.
230-
AssocKind::Fn => !self.fn_has_self_parameter,
231-
}
232-
}
233-
234222
pub fn signature(&self, tcx: TyCtxt<'_>) -> String {
235223
match self.kind {
236224
ty::AssocKind::Fn => {
@@ -241,8 +229,6 @@ impl AssocItem {
241229
tcx.fn_sig(self.def_id).skip_binder().to_string()
242230
}
243231
ty::AssocKind::Type => format!("type {};", self.ident),
244-
// FIXME(type_alias_impl_trait): we should print bounds here too.
245-
ty::AssocKind::OpaqueTy => format!("type {};", self.ident),
246232
ty::AssocKind::Const => {
247233
format!("const {}: {:?};", self.ident, tcx.type_of(self.def_id))
248234
}
@@ -2581,10 +2567,6 @@ impl<'tcx> TyCtxt<'tcx> {
25812567
.filter(|item| item.kind == AssocKind::Fn && item.defaultness.has_value())
25822568
}
25832569

2584-
pub fn trait_relevant_for_never(self, did: DefId) -> bool {
2585-
self.associated_items(did).in_definition_order().any(|item| item.relevant_for_never())
2586-
}
2587-
25882570
pub fn opt_item_name(self, def_id: DefId) -> Option<Ident> {
25892571
def_id
25902572
.as_local()

src/librustc_passes/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>)
3737
Target::Method(MethodKind::Inherent)
3838
}
3939
}
40-
hir::ImplItemKind::TyAlias(..) | hir::ImplItemKind::OpaqueTy(..) => Target::AssocTy,
40+
hir::ImplItemKind::TyAlias(..) => Target::AssocTy,
4141
}
4242
}
4343

src/librustc_passes/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
668668
}
669669
self.visit_nested_body(body_id)
670670
}
671-
hir::ImplItemKind::OpaqueTy(..) | hir::ImplItemKind::TyAlias(..) => {}
671+
hir::ImplItemKind::TyAlias(..) => {}
672672
}
673673
}
674674

src/librustc_passes/reachable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
180180
}
181181
}
182182
}
183-
hir::ImplItemKind::OpaqueTy(..) | hir::ImplItemKind::TyAlias(_) => false,
183+
hir::ImplItemKind::TyAlias(_) => false,
184184
}
185185
}
186186
Some(_) => false,
@@ -289,7 +289,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
289289
self.visit_nested_body(body)
290290
}
291291
}
292-
hir::ImplItemKind::OpaqueTy(..) | hir::ImplItemKind::TyAlias(_) => {}
292+
hir::ImplItemKind::TyAlias(_) => {}
293293
},
294294
Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(.., body, _, _), .. }) => {
295295
self.visit_nested_body(body);

src/librustc_privacy/lib.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ impl EmbargoVisitor<'tcx> {
615615
// public, or are not namespaced at all.
616616
DefKind::AssocConst
617617
| DefKind::AssocTy
618-
| DefKind::AssocOpaqueTy
619618
| DefKind::ConstParam
620619
| DefKind::Ctor(_, _)
621620
| DefKind::Enum
@@ -1333,11 +1332,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
13331332
_ => None,
13341333
};
13351334
let def = def.filter(|(kind, _)| match kind {
1336-
DefKind::AssocFn
1337-
| DefKind::AssocConst
1338-
| DefKind::AssocTy
1339-
| DefKind::AssocOpaqueTy
1340-
| DefKind::Static => true,
1335+
DefKind::AssocFn | DefKind::AssocConst | DefKind::AssocTy | DefKind::Static => true,
13411336
_ => false,
13421337
});
13431338
if let Some((kind, def_id)) = def {
@@ -1602,9 +1597,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
16021597
hir::ImplItemKind::Const(..) | hir::ImplItemKind::Fn(..) => {
16031598
self.access_levels.is_reachable(impl_item_ref.id.hir_id)
16041599
}
1605-
hir::ImplItemKind::OpaqueTy(..) | hir::ImplItemKind::TyAlias(_) => {
1606-
false
1607-
}
1600+
hir::ImplItemKind::TyAlias(_) => false,
16081601
}
16091602
});
16101603

@@ -1952,9 +1945,6 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
19521945
let (check_ty, is_assoc_ty) = match assoc_item_kind {
19531946
AssocItemKind::Const | AssocItemKind::Fn { .. } => (true, false),
19541947
AssocItemKind::Type => (defaultness.has_value(), true),
1955-
// `ty()` for opaque types is the underlying type,
1956-
// it's not a part of interface, so we skip it.
1957-
AssocItemKind::OpaqueTy => (false, true),
19581948
};
19591949
check.in_assoc_ty = is_assoc_ty;
19601950
check.generics().predicates();

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
916916
| DefKind::ForeignTy
917917
| DefKind::OpaqueTy
918918
| DefKind::TraitAlias
919-
| DefKind::AssocTy
920-
| DefKind::AssocOpaqueTy,
919+
| DefKind::AssocTy,
921920
_,
922921
)
923922
| Res::PrimTy(..)

0 commit comments

Comments
 (0)