Use a diagnostic item instead of filtering for Index::Output
This commit is contained in:
parent
770c303c00
commit
d84b5f9b3d
3 changed files with 4 additions and 9 deletions
|
@ -2871,6 +2871,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
base_ty: Ty<'tcx>,
|
base_ty: Ty<'tcx>,
|
||||||
) -> Option<(ErrorGuaranteed, Ty<'tcx>, Ty<'tcx>)> {
|
) -> Option<(ErrorGuaranteed, Ty<'tcx>, Ty<'tcx>)> {
|
||||||
let index_trait_def_id = self.tcx.lang_items().index_trait()?;
|
let index_trait_def_id = self.tcx.lang_items().index_trait()?;
|
||||||
|
let index_trait_output_def_id = self.tcx.get_diagnostic_item(sym::IndexOutput)?;
|
||||||
|
|
||||||
let mut relevant_impls = vec![];
|
let mut relevant_impls = vec![];
|
||||||
self.tcx.for_each_relevant_impl(index_trait_def_id, base_ty, |impl_def_id| {
|
self.tcx.for_each_relevant_impl(index_trait_def_id, base_ty, |impl_def_id| {
|
||||||
|
@ -2917,15 +2918,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let element_ty = ocx.normalize(
|
let element_ty = ocx.normalize(
|
||||||
&cause,
|
&cause,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
self.tcx.mk_projection(
|
self.tcx.mk_projection(index_trait_output_def_id, impl_trait_ref.substs),
|
||||||
self.tcx
|
|
||||||
.associated_items(index_trait_def_id)
|
|
||||||
.filter_by_name_unhygienic(sym::Output)
|
|
||||||
.next()
|
|
||||||
.unwrap()
|
|
||||||
.def_id,
|
|
||||||
impl_trait_ref.substs,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let errors = ocx.select_where_possible();
|
let errors = ocx.select_where_possible();
|
||||||
|
|
|
@ -204,6 +204,7 @@ symbols! {
|
||||||
HashSet,
|
HashSet,
|
||||||
Hasher,
|
Hasher,
|
||||||
Implied,
|
Implied,
|
||||||
|
IndexOutput,
|
||||||
Input,
|
Input,
|
||||||
Into,
|
Into,
|
||||||
IntoDiagnostic,
|
IntoDiagnostic,
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
pub trait Index<Idx: ?Sized> {
|
pub trait Index<Idx: ?Sized> {
|
||||||
/// The returned type after indexing.
|
/// The returned type after indexing.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[rustc_diagnostic_item = "IndexOutput"]
|
||||||
type Output: ?Sized;
|
type Output: ?Sized;
|
||||||
|
|
||||||
/// Performs the indexing (`container[index]`) operation.
|
/// Performs the indexing (`container[index]`) operation.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue