Skip to content

Commit 9bbd3e0

Browse files
committed
Remove ProjectionTy::from_ref_and_name
1 parent dfa581f commit 9bbd3e0

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

compiler/rustc_hir/src/lang_items.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ language_item_table! {
238238

239239
Deref, sym::deref, deref_trait, Target::Trait;
240240
DerefMut, sym::deref_mut, deref_mut_trait, Target::Trait;
241+
DerefTarget, sym::deref_target, deref_target, Target::AssocTy;
241242
Receiver, sym::receiver, receiver_trait, Target::Trait;
242243

243244
Fn, kw::Fn, fn_trait, Target::Trait;

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,22 +1112,6 @@ pub struct ProjectionTy<'tcx> {
11121112
}
11131113

11141114
impl<'tcx> ProjectionTy<'tcx> {
1115-
/// Construct a `ProjectionTy` by searching the trait from `trait_ref` for the
1116-
/// associated item named `item_name`.
1117-
pub fn from_ref_and_name(
1118-
tcx: TyCtxt<'_>,
1119-
trait_ref: ty::TraitRef<'tcx>,
1120-
item_name: Ident,
1121-
) -> ProjectionTy<'tcx> {
1122-
let item_def_id = tcx
1123-
.associated_items(trait_ref.def_id)
1124-
.find_by_name_and_kind(tcx, item_name, ty::AssocKind::Type, trait_ref.def_id)
1125-
.unwrap()
1126-
.def_id;
1127-
1128-
ProjectionTy { substs: trait_ref.substs, item_def_id }
1129-
}
1130-
11311115
/// Extracts the underlying trait reference from this projection.
11321116
/// For example, if this is a projection of `<T as Iterator>::Item`,
11331117
/// then this function would return a `T: Iterator` trait reference.

compiler/rustc_trait_selection/src/autoderef.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_infer::infer::InferCtxt;
66
use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt, WithConstness};
77
use rustc_middle::ty::{ToPredicate, TypeFoldable};
88
use rustc_session::DiagnosticMessageId;
9-
use rustc_span::symbol::{sym, Ident};
109
use rustc_span::Span;
1110

1211
#[derive(Copy, Clone, Debug)]
@@ -146,11 +145,10 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
146145
let normalized_ty = fulfillcx.normalize_projection_type(
147146
&self.infcx,
148147
self.param_env,
149-
ty::ProjectionTy::from_ref_and_name(
150-
tcx,
151-
trait_ref,
152-
Ident::with_dummy_span(sym::Target),
153-
),
148+
ty::ProjectionTy {
149+
item_def_id: tcx.lang_items().deref_target()?,
150+
substs: trait_ref.substs,
151+
},
154152
cause,
155153
);
156154
if let Err(e) = fulfillcx.select_where_possible(&self.infcx) {

library/core/src/ops/deref.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub trait Deref {
6464
/// The resulting type after dereferencing.
6565
#[stable(feature = "rust1", since = "1.0.0")]
6666
#[rustc_diagnostic_item = "deref_target"]
67+
#[cfg_attr(not(bootstrap), lang = "deref_target")]
6768
type Target: ?Sized;
6869

6970
/// Dereferences the value.

0 commit comments

Comments
 (0)