Skip to content

Commit 5309a3e

Browse files
committed
Auto merge of #40915 - nrc:save-assoc, r=eddyb
save-analysis: track associated types r? @eddyb
2 parents 72ecd79 + e3acebf commit 5309a3e

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

src/librustc_save_analysis/dump_visitor.rs

+27-3
Original file line numberDiff line numberDiff line change
@@ -1149,8 +1149,32 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
11491149
&trait_item.attrs,
11501150
trait_item.span);
11511151
}
1152-
ast::TraitItemKind::Const(_, None) |
1153-
ast::TraitItemKind::Type(..) |
1152+
ast::TraitItemKind::Type(ref _bounds, ref default_ty) => {
1153+
// FIXME do something with _bounds (for type refs)
1154+
let name = trait_item.ident.name.to_string();
1155+
let qualname = format!("::{}", self.tcx.node_path_str(trait_item.id));
1156+
let sub_span = self.span.sub_span_after_keyword(trait_item.span, keywords::Type);
1157+
1158+
if !self.span.filter_generated(sub_span, trait_item.span) {
1159+
self.dumper.typedef(TypeDefData {
1160+
span: sub_span.expect("No span found for assoc type"),
1161+
name: name,
1162+
id: trait_item.id,
1163+
qualname: qualname,
1164+
value: self.span.snippet(trait_item.span),
1165+
visibility: Visibility::Public,
1166+
parent: Some(trait_id),
1167+
docs: docs_for_attrs(&trait_item.attrs),
1168+
sig: None,
1169+
attributes: trait_item.attrs.clone(),
1170+
}.lower(self.tcx));
1171+
}
1172+
1173+
if let &Some(ref default_ty) = default_ty {
1174+
self.visit_ty(default_ty)
1175+
}
1176+
}
1177+
ast::TraitItemKind::Const(ref ty, None) => self.visit_ty(ty),
11541178
ast::TraitItemKind::Macro(_) => {}
11551179
}
11561180
}
@@ -1177,7 +1201,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
11771201
&impl_item.attrs,
11781202
impl_item.span);
11791203
}
1180-
ast::ImplItemKind::Type(_) |
1204+
ast::ImplItemKind::Type(ref ty) => self.visit_ty(ty),
11811205
ast::ImplItemKind::Macro(_) => {}
11821206
}
11831207
}

src/test/run-make/save-analysis/foo.rs

+17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![ crate_name = "test" ]
1212
#![feature(box_syntax)]
1313
#![feature(rustc_private)]
14+
#![feature(associated_type_defaults)]
1415

1516
extern crate graphviz;
1617
// A simple rust project
@@ -441,3 +442,19 @@ fn test_format_args() {
441442
print!("{0} + {} = {}", x, y);
442443
print!("x is {}, y is {1}, name is {n}", x, y, n = name);
443444
}
445+
446+
struct FrameBuffer;
447+
448+
struct SilenceGenerator;
449+
450+
impl Iterator for SilenceGenerator {
451+
type Item = FrameBuffer;
452+
453+
fn next(&mut self) -> Option<Self::Item> {
454+
panic!();
455+
}
456+
}
457+
458+
trait Foo {
459+
type Bar = FrameBuffer;
460+
}

0 commit comments

Comments
 (0)