mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +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;
|
Deref, sym::deref, deref_trait, Target::Trait;
|
||||||
DerefMut, sym::deref_mut, deref_mut_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;
|
Receiver, sym::receiver, receiver_trait, Target::Trait;
|
||||||
|
|
||||||
Fn, kw::Fn, fn_trait, Target::Trait;
|
Fn, kw::Fn, fn_trait, Target::Trait;
|
||||||
|
@ -1112,22 +1112,6 @@ pub struct ProjectionTy<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> 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.
|
/// Extracts the underlying trait reference from this projection.
|
||||||
/// For example, if this is a projection of `<T as Iterator>::Item`,
|
/// For example, if this is a projection of `<T as Iterator>::Item`,
|
||||||
/// then this function would return a `T: Iterator` trait reference.
|
/// 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::{self, TraitRef, Ty, TyCtxt, WithConstness};
|
||||||
use rustc_middle::ty::{ToPredicate, TypeFoldable};
|
use rustc_middle::ty::{ToPredicate, TypeFoldable};
|
||||||
use rustc_session::DiagnosticMessageId;
|
use rustc_session::DiagnosticMessageId;
|
||||||
use rustc_span::symbol::{sym, Ident};
|
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
@ -146,11 +145,10 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
|
|||||||
let normalized_ty = fulfillcx.normalize_projection_type(
|
let normalized_ty = fulfillcx.normalize_projection_type(
|
||||||
&self.infcx,
|
&self.infcx,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::ProjectionTy::from_ref_and_name(
|
ty::ProjectionTy {
|
||||||
tcx,
|
item_def_id: tcx.lang_items().deref_target()?,
|
||||||
trait_ref,
|
substs: trait_ref.substs,
|
||||||
Ident::with_dummy_span(sym::Target),
|
},
|
||||||
),
|
|
||||||
cause,
|
cause,
|
||||||
);
|
);
|
||||||
if let Err(e) = fulfillcx.select_where_possible(&self.infcx) {
|
if let Err(e) = fulfillcx.select_where_possible(&self.infcx) {
|
||||||
|
@ -64,6 +64,7 @@ pub trait Deref {
|
|||||||
/// The resulting type after dereferencing.
|
/// The resulting type after dereferencing.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_diagnostic_item = "deref_target"]
|
#[rustc_diagnostic_item = "deref_target"]
|
||||||
|
#[cfg_attr(not(bootstrap), lang = "deref_target")]
|
||||||
type Target: ?Sized;
|
type Target: ?Sized;
|
||||||
|
|
||||||
/// Dereferences the value.
|
/// Dereferences the value.
|
||||||
|
Loading…
Reference in New Issue
Block a user