Skip to content

Commit 7572546

Browse files
committed
Improve handling of unimplemented nodes
1 parent 69761a2 commit 7572546

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+682
-189
lines changed

rust/extractor/src/generated/.generated.list

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/extractor/src/generated/top.rs

Lines changed: 53 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/extractor/src/translate.rs

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,12 @@ impl CrateTranslator<'_> {
183183
})
184184
}
185185

186-
fn emit_unimplemented(&mut self, location: Option<trap::Label>) -> trap::Label {
187-
self.trap.emit(generated::Unimplemented {
186+
fn emit_path(&mut self, _path: &Path, location: Option<trap::Label>) -> trap::Label {
187+
self.trap.emit(generated::Path {
188188
id: TrapId::Star,
189189
location,
190190
})
191191
}
192-
fn emit_path(&mut self, _path: &Path, location: Option<trap::Label>) -> trap::Label {
193-
self.emit_unimplemented(location)
194-
}
195192

196193
fn emit_record_field_pat(
197194
&mut self,
@@ -610,9 +607,12 @@ impl CrateTranslator<'_> {
610607
.into_iter()
611608
.map(|e| self.emit_expr(*e, body, source_map))
612609
.collect();
613-
let generic_args = generic_args
614-
.as_ref()
615-
.map(|_args| self.emit_unimplemented(None));
610+
let generic_args = generic_args.as_ref().map(|_args| {
611+
self.trap.emit(generated::GenericArgs {
612+
id: TrapId::Star,
613+
location: None,
614+
})
615+
});
616616
self.trap.emit(generated::MethodCallExpr {
617617
id: TrapId::Star,
618618
location,
@@ -929,8 +929,12 @@ impl CrateTranslator<'_> {
929929
labels: &mut Vec<trap::Label>,
930930
) {
931931
match id {
932-
ModuleDef::Module(_) => {
933-
self.emit_unimplemented(None);
932+
ModuleDef::Module(_module) => {
933+
let location = None;
934+
self.trap.emit(generated::UnimplementedDeclaration {
935+
id: TrapId::Star,
936+
location,
937+
});
934938
}
935939
ModuleDef::Function(function) => {
936940
let def: ra_ap_hir::DefWithBody = function.into();
@@ -958,38 +962,66 @@ impl CrateTranslator<'_> {
958962
}
959963
ModuleDef::Adt(adt) => {
960964
let location = self.emit_location(adt);
961-
self.emit_unimplemented(location);
965+
self.trap.emit(generated::UnimplementedDeclaration {
966+
id: TrapId::Star,
967+
location,
968+
});
962969
}
963970
ModuleDef::Variant(variant) => {
964971
let location = self.emit_location(variant);
965-
self.emit_unimplemented(location);
972+
self.trap.emit(generated::UnimplementedDeclaration {
973+
id: TrapId::Star,
974+
location,
975+
});
966976
}
967977
ModuleDef::Const(const_) => {
968978
let location = self.emit_location(const_);
969-
self.emit_unimplemented(location);
979+
self.trap.emit(generated::UnimplementedDeclaration {
980+
id: TrapId::Star,
981+
location,
982+
});
970983
}
971984
ModuleDef::Static(static_) => {
972985
let location = self.emit_location(static_);
973-
self.emit_unimplemented(location);
986+
self.trap.emit(generated::UnimplementedDeclaration {
987+
id: TrapId::Star,
988+
location,
989+
});
974990
}
975991
ModuleDef::Trait(trait_) => {
976992
let location = self.emit_location(trait_);
977-
self.emit_unimplemented(location);
993+
self.trap.emit(generated::UnimplementedDeclaration {
994+
id: TrapId::Star,
995+
location,
996+
});
978997
}
979998
ModuleDef::TraitAlias(alias) => {
980999
let location = self.emit_location(alias);
981-
self.emit_unimplemented(location);
1000+
self.trap.emit(generated::UnimplementedDeclaration {
1001+
id: TrapId::Star,
1002+
location,
1003+
});
9821004
}
9831005
ModuleDef::TypeAlias(type_alias) => {
9841006
let location = self.emit_location(type_alias);
985-
self.emit_unimplemented(location);
1007+
self.trap.emit(generated::UnimplementedDeclaration {
1008+
id: TrapId::Star,
1009+
location,
1010+
});
9861011
}
9871012
ModuleDef::BuiltinType(_builtin_type) => {
988-
self.emit_unimplemented(None);
1013+
let location = None;
1014+
self.trap.emit(generated::UnimplementedDeclaration {
1015+
id: TrapId::Star,
1016+
location,
1017+
});
9891018
}
9901019
ModuleDef::Macro(macro_) => {
9911020
let location = self.emit_location(macro_);
992-
self.emit_unimplemented(location);
1021+
self.trap.emit(generated::UnimplementedDeclaration {
1022+
id: TrapId::Star,
1023+
location,
1024+
});
9931025
}
9941026
}
9951027
}

0 commit comments

Comments
 (0)