Skip to content

Commit 86c4c87

Browse files
committed
Revert "rustdoc: list matching impls on type aliases"
This reverts commit 19edb3c.
1 parent d3773ef commit 86c4c87

File tree

2 files changed

+4
-104
lines changed

2 files changed

+4
-104
lines changed

src/librustdoc/html/render/mod.rs

+4-43
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5454
use rustc_hir::def_id::{DefId, DefIdSet};
5555
use rustc_hir::Mutability;
5656
use rustc_middle::middle::stability;
57-
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
5857
use rustc_middle::ty::TyCtxt;
5958
use rustc_span::{
6059
symbol::{sym, Symbol},
@@ -63,7 +62,6 @@ use rustc_span::{
6362
use serde::ser::{SerializeMap, SerializeSeq};
6463
use serde::{Serialize, Serializer};
6564

66-
use crate::clean::types::TypeAliasItem;
6765
use crate::clean::{self, ItemId, RenderedLink, SelfTy};
6866
use crate::error::Error;
6967
use crate::formats::cache::Cache;
@@ -1155,40 +1153,8 @@ fn render_assoc_items_inner(
11551153
info!("Documenting associated items of {:?}", containing_item.name);
11561154
let shared = Rc::clone(&cx.shared);
11571155
let cache = &shared.cache;
1158-
let tcx = cx.tcx();
1159-
let av = if let TypeAliasItem(ait) = &*containing_item.kind &&
1160-
let aliased_clean_type = ait.item_type.as_ref().unwrap_or(&ait.type_) &&
1161-
let Some(aliased_type_defid) = aliased_clean_type.def_id(cache) &&
1162-
let Some(mut av) = cache.impls.get(&aliased_type_defid).cloned() &&
1163-
let Some(alias_def_id) = containing_item.item_id.as_def_id()
1164-
{
1165-
// This branch of the compiler compares types structually, but does
1166-
// not check trait bounds. That's probably fine, since type aliases
1167-
// don't normally constrain on them anyway.
1168-
// https://github.com/rust-lang/rust/issues/21903
1169-
//
1170-
// If that changes, then this will need to check them with type
1171-
// unification.
1172-
let aliased_ty = tcx.type_of(alias_def_id).skip_binder();
1173-
let reject_cx = DeepRejectCtxt {
1174-
treat_obligation_params: TreatParams::AsCandidateKey,
1175-
};
1176-
av.retain(|impl_| {
1177-
if let Some(impl_def_id) = impl_.impl_item.item_id.as_def_id() {
1178-
reject_cx.types_may_unify(aliased_ty, tcx.type_of(impl_def_id).skip_binder())
1179-
} else {
1180-
false
1181-
}
1182-
});
1183-
av
1184-
} else {
1185-
Vec::new()
1186-
};
1187-
let blank = Vec::new();
1188-
let v = cache.impls.get(&it).unwrap_or(&blank);
1189-
let (non_trait, traits): (Vec<_>, _) =
1190-
v.iter().chain(&av[..]).partition(|i| i.inner_impl().trait_.is_none());
1191-
let mut saw_impls = FxHashSet::default();
1156+
let Some(v) = cache.impls.get(&it) else { return };
1157+
let (non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| i.inner_impl().trait_.is_none());
11921158
if !non_trait.is_empty() {
11931159
let mut tmp_buf = Buffer::html();
11941160
let (render_mode, id, class_html) = match what {
@@ -1217,9 +1183,6 @@ fn render_assoc_items_inner(
12171183
};
12181184
let mut impls_buf = Buffer::html();
12191185
for i in &non_trait {
1220-
if !saw_impls.insert(i.def_id()) {
1221-
continue;
1222-
}
12231186
render_impl(
12241187
&mut impls_buf,
12251188
cx,
@@ -1265,10 +1228,8 @@ fn render_assoc_items_inner(
12651228

12661229
let (synthetic, concrete): (Vec<&Impl>, Vec<&Impl>) =
12671230
traits.into_iter().partition(|t| t.inner_impl().kind.is_auto());
1268-
let (blanket_impl, concrete): (Vec<&Impl>, _) = concrete
1269-
.into_iter()
1270-
.filter(|t| saw_impls.insert(t.def_id()))
1271-
.partition(|t| t.inner_impl().kind.is_blanket());
1231+
let (blanket_impl, concrete): (Vec<&Impl>, _) =
1232+
concrete.into_iter().partition(|t| t.inner_impl().kind.is_blanket());
12721233

12731234
render_all_impls(w, cx, containing_item, &concrete, &synthetic, &blanket_impl);
12741235
}

tests/rustdoc/issue-32077-type-alias-impls.rs

-61
This file was deleted.

0 commit comments

Comments
 (0)