mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Remove ProjectionTy::from_ref_and_name
This commit is contained in:
parent
dfa581ff87
commit
9bbd3e0f8e
@ -238,6 +238,7 @@ language_item_table! {
|
||||
|
||||
Deref, sym::deref, deref_trait, Target::Trait;
|
||||
DerefMut, sym::deref_mut, deref_mut_trait, Target::Trait;
|
||||
DerefTarget, sym::deref_target, deref_target, Target::AssocTy;
|
||||
Receiver, sym::receiver, receiver_trait, Target::Trait;
|
||||
|
||||
Fn, kw::Fn, fn_trait, Target::Trait;
|
||||
|
@ -1112,22 +1112,6 @@ pub struct ProjectionTy<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> ProjectionTy<'tcx> {
|
||||
/// Construct a `ProjectionTy` by searching the trait from `trait_ref` for the
|
||||
/// associated item named `item_name`.
|
||||
pub fn from_ref_and_name(
|
||||
tcx: TyCtxt<'_>,
|
||||
trait_ref: ty::TraitRef<'tcx>,
|
||||
item_name: Ident,
|
||||
) -> ProjectionTy<'tcx> {
|
||||
let item_def_id = tcx
|
||||
.associated_items(trait_ref.def_id)
|
||||
.find_by_name_and_kind(tcx, item_name, ty::AssocKind::Type, trait_ref.def_id)
|
||||
.unwrap()
|
||||
.def_id;
|
||||
|
||||
ProjectionTy { substs: trait_ref.substs, item_def_id }
|
||||
}
|
||||
|
||||
/// Extracts the underlying trait reference from this projection.
|
||||
/// For example, if this is a projection of `<T as Iterator>::Item`,
|
||||
/// then this function would return a `T: Iterator` trait reference.
|
||||
|
@ -6,7 +6,6 @@ use rustc_infer::infer::InferCtxt;
|
||||
use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt, WithConstness};
|
||||
use rustc_middle::ty::{ToPredicate, TypeFoldable};
|
||||
use rustc_session::DiagnosticMessageId;
|
||||
use rustc_span::symbol::{sym, Ident};
|
||||
use rustc_span::Span;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
@ -146,11 +145,10 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
|
||||
let normalized_ty = fulfillcx.normalize_projection_type(
|
||||
&self.infcx,
|
||||
self.param_env,
|
||||
ty::ProjectionTy::from_ref_and_name(
|
||||
tcx,
|
||||
trait_ref,
|
||||
Ident::with_dummy_span(sym::Target),
|
||||
),
|
||||
ty::ProjectionTy {
|
||||
item_def_id: tcx.lang_items().deref_target()?,
|
||||
substs: trait_ref.substs,
|
||||
},
|
||||
cause,
|
||||
);
|
||||
if let Err(e) = fulfillcx.select_where_possible(&self.infcx) {
|
||||
|
@ -64,6 +64,7 @@ pub trait Deref {
|
||||
/// The resulting type after dereferencing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_diagnostic_item = "deref_target"]
|
||||
#[cfg_attr(not(bootstrap), lang = "deref_target")]
|
||||
type Target: ?Sized;
|
||||
|
||||
/// Dereferences the value.
|
||||
|
Loading…
Reference in New Issue
Block a user