Skip to content

Commit 9ecca51

Browse files
committed
Remove ImplSubject
1 parent eec6bd9 commit 9ecca51

File tree

5 files changed

+7
-61
lines changed

5 files changed

+7
-61
lines changed

compiler/rustc_infer/src/infer/at.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
use relate::lattice::{LatticeOp, LatticeOpKind};
2929
use rustc_middle::bug;
3030
use rustc_middle::ty::relate::solver_relating::RelateExt as NextSolverRelate;
31-
use rustc_middle::ty::{Const, ImplSubject, TypingMode};
31+
use rustc_middle::ty::{Const, TypingMode};
3232

3333
use super::*;
3434
use crate::infer::relate::type_relating::TypeRelating;
@@ -304,23 +304,6 @@ impl<'a, 'tcx> At<'a, 'tcx> {
304304
}
305305
}
306306

307-
impl<'tcx> ToTrace<'tcx> for ImplSubject<'tcx> {
308-
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
309-
match (a, b) {
310-
(ImplSubject::Trait(trait_ref_a), ImplSubject::Trait(trait_ref_b)) => {
311-
ToTrace::to_trace(cause, trait_ref_a, trait_ref_b)
312-
}
313-
(ImplSubject::Inherent(ty_a), ImplSubject::Inherent(ty_b)) => {
314-
ToTrace::to_trace(cause, ty_a, ty_b)
315-
}
316-
(ImplSubject::Trait(_), ImplSubject::Inherent(_))
317-
| (ImplSubject::Inherent(_), ImplSubject::Trait(_)) => {
318-
bug!("can not trace TraitRef and Ty");
319-
}
320-
}
321-
}
322-
}
323-
324307
impl<'tcx> ToTrace<'tcx> for Ty<'tcx> {
325308
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
326309
TypeTrace {

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_macros::{Decodable, Encodable, HashStable};
1818
use rustc_span::{ErrorGuaranteed, ExpnId, Span};
1919

2020
use crate::query::Providers;
21-
use crate::ty::{EarlyBinder, ImplSubject, TyCtxt};
21+
use crate::ty::TyCtxt;
2222

2323
/// Gather the LocalDefId for each item-like within a module, including items contained within
2424
/// bodies. The Ids are in visitor order. This is used to partition a pass between modules.
@@ -154,13 +154,6 @@ impl<'tcx> TyCtxt<'tcx> {
154154
LocalModDefId::new_unchecked(id)
155155
}
156156

157-
pub fn impl_subject(self, def_id: DefId) -> EarlyBinder<'tcx, ImplSubject<'tcx>> {
158-
match self.impl_trait_ref(def_id) {
159-
Some(t) => t.map_bound(ImplSubject::Trait),
160-
None => self.type_of(def_id).map_bound(ImplSubject::Inherent),
161-
}
162-
}
163-
164157
/// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
165158
pub fn is_foreign_item(self, def_id: impl Into<DefId>) -> bool {
166159
self.opt_parent(def_id.into())

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,6 @@ pub struct ImplTraitHeader<'tcx> {
254254
pub constness: hir::Constness,
255255
}
256256

257-
#[derive(Copy, Clone, PartialEq, Eq, Debug, TypeFoldable, TypeVisitable)]
258-
pub enum ImplSubject<'tcx> {
259-
Trait(TraitRef<'tcx>),
260-
Inherent(Ty<'tcx>),
261-
}
262-
263257
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable, Debug)]
264258
#[derive(TypeFoldable, TypeVisitable)]
265259
pub enum Asyncness {

compiler/rustc_middle/src/ty/relate.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,6 @@ use crate::ty::{self as ty, Ty, TyCtxt};
77

88
pub type RelateResult<'tcx, T> = rustc_type_ir::relate::RelateResult<TyCtxt<'tcx>, T>;
99

10-
impl<'tcx> Relate<TyCtxt<'tcx>> for ty::ImplSubject<'tcx> {
11-
#[inline]
12-
fn relate<R: TypeRelation<TyCtxt<'tcx>>>(
13-
relation: &mut R,
14-
a: ty::ImplSubject<'tcx>,
15-
b: ty::ImplSubject<'tcx>,
16-
) -> RelateResult<'tcx, ty::ImplSubject<'tcx>> {
17-
match (a, b) {
18-
(ty::ImplSubject::Trait(trait_ref_a), ty::ImplSubject::Trait(trait_ref_b)) => {
19-
let trait_ref = ty::TraitRef::relate(relation, trait_ref_a, trait_ref_b)?;
20-
Ok(ty::ImplSubject::Trait(trait_ref))
21-
}
22-
(ty::ImplSubject::Inherent(ty_a), ty::ImplSubject::Inherent(ty_b)) => {
23-
let ty = Ty::relate(relation, ty_a, ty_b)?;
24-
Ok(ty::ImplSubject::Inherent(ty))
25-
}
26-
(ty::ImplSubject::Trait(_), ty::ImplSubject::Inherent(_))
27-
| (ty::ImplSubject::Inherent(_), ty::ImplSubject::Trait(_)) => {
28-
bug!("can not relate TraitRef and Ty");
29-
}
30-
}
31-
}
32-
}
33-
3410
impl<'tcx> Relate<TyCtxt<'tcx>> for Ty<'tcx> {
3511
#[inline]
3612
fn relate<R: TypeRelation<TyCtxt<'tcx>>>(

src/librustdoc/html/render/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,11 +2454,11 @@ fn get_id_for_impl(tcx: TyCtxt<'_>, impl_id: ItemId) -> String {
24542454
(ty, Some(ty::TraitRef::new(tcx, trait_, [ty])))
24552455
}
24562456
ItemId::Blanket { impl_id, .. } | ItemId::DefId(impl_id) => {
2457-
match tcx.impl_subject(impl_id).skip_binder() {
2458-
ty::ImplSubject::Trait(trait_ref) => {
2459-
(trait_ref.args[0].expect_ty(), Some(trait_ref))
2460-
}
2461-
ty::ImplSubject::Inherent(ty) => (ty, None),
2457+
if let Some(trait_ref) = tcx.impl_trait_ref(impl_id) {
2458+
let trait_ref = trait_ref.skip_binder();
2459+
(trait_ref.self_ty(), Some(trait_ref))
2460+
} else {
2461+
(tcx.type_of(impl_id).skip_binder(), None)
24622462
}
24632463
}
24642464
};

0 commit comments

Comments
 (0)