Skip to content

Commit aa523a9

Browse files
committed
Fix errors on blanket impls by ignoring the children of their generated implementations
1 parent 72e74d7 commit aa523a9

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/librustdoc/clean/types.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ impl ItemId {
7575
}
7676
}
7777

78+
#[inline]
79+
crate fn is_local_impl(self) -> bool {
80+
match self {
81+
ItemId::Blanket { impl_id, .. } => impl_id.is_local(),
82+
ItemId::Auto { .. } | ItemId::DefId(_) | ItemId::Primitive(_, _) => false,
83+
}
84+
}
85+
7886
#[inline]
7987
#[track_caller]
8088
crate fn expect_def_id(self) -> DefId {

src/librustdoc/json/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
172172
/// implementations filled out before they're inserted.
173173
fn item(&mut self, item: clean::Item) -> Result<(), Error> {
174174
// Flatten items that recursively store other items
175-
item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap());
175+
// We skip local blanket implementations, as we'll have already seen the actual generic
176+
// impl, and the generated ones don't need documenting.
177+
if !item.def_id.is_local_impl() {
178+
item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap());
179+
}
176180

177181
let id = item.def_id;
178182
if let Some(mut new_item) = self.convert_item(item) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Test for the ICE in rust/83718
2+
// A blanket impl plus a local type together shouldn't result in mismatched ID issues
3+
4+
// @has method_abi.json "$.index[*][?(@.name=='Load')]"
5+
pub trait Load {
6+
fn load() {}
7+
}
8+
9+
impl<P> Load for P {
10+
fn load() {}
11+
}
12+
13+
// @has - "$.index[*][?(@.name=='Wrapper')]"
14+
pub struct Wrapper {}

0 commit comments

Comments
 (0)