-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix errors on blanket impls by ignoring the children of generated impls #92860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
aa523a9
74f0e58
a6aa3cb
aafcbf1
474e091
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,8 +171,19 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { | |
/// the hashmap because certain items (traits and types) need to have their mappings for trait | ||
/// implementations filled out before they're inserted. | ||
fn item(&mut self, item: clean::Item) -> Result<(), Error> { | ||
// We skip children of local blanket implementations, as we'll have already seen the actual | ||
// generic impl, and the generated ones don't need documenting. | ||
let local_blanket_impl = match item.def_id { | ||
clean::ItemId::Blanket { impl_id, .. } => impl_id.is_local(), | ||
clean::ItemId::Auto { .. } | ||
| clean::ItemId::DefId(_) | ||
| clean::ItemId::Primitive(_, _) => false, | ||
Comment on lines
+176
to
+178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not match these all with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When it was inside the ItemId def, it matched other methods. I figured it didn't hurt to ensure future changes required a decision on this code, as a future type may or may not want to do the same child-skipping trick until the underlying issues is fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I wanted to make it non-exhaustive, I'd probably reduce the whole thing to a matches, but I'd rather leave it as-is for now personally. I'll work on fixing the underlying issues so this code shouldn't be necessary forever either way. |
||
}; | ||
|
||
// Flatten items that recursively store other items | ||
item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap()); | ||
if !local_blanket_impl { | ||
item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap()); | ||
} | ||
|
||
let id = item.def_id; | ||
if let Some(mut new_item) = self.convert_item(item) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Test for the ICE in rust/83718 | ||
// A blanket impl plus a local type together shouldn't result in mismatched ID issues | ||
|
||
// @has blanket_with_local.json "$.index[*][?(@.name=='Load')]" | ||
pub trait Load { | ||
fn load() {} | ||
} | ||
|
||
impl<P> Load for P { | ||
fn load() {} | ||
} | ||
|
||
// @has - "$.index[*][?(@.name=='Wrapper')]" | ||
pub struct Wrapper {} |
Uh oh!
There was an error while loading. Please reload this page.