Skip to content

Commit

Permalink
Fix ambiguity
Browse files Browse the repository at this point in the history
  • Loading branch information
aibaars committed Sep 13, 2024
1 parent e682298 commit 71d816c
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions rust/extractor/src/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use ra_ap_hir::TypeRef;
use ra_ap_hir::{Crate, Module, ModuleDef};
use ra_ap_hir_def::body::{Body, BodySourceMap};
use ra_ap_hir_def::hir::{
CaptureBy, ExprId, LabelId, MatchArm, PatId, RecordFieldPat, RecordLitField, Statement,
BindingAnnotation, CaptureBy, ExprId, LabelId, MatchArm, PatId, RecordFieldPat, RecordLitField,
Statement,
};
use ra_ap_hir_def::path::Path;
use ra_ap_ide_db::line_index::LineIndex;
Expand Down Expand Up @@ -310,6 +311,7 @@ impl CrateTranslator<'_> {
suffix,
})
}

ra_ap_hir_def::hir::Pat::Path(path) => {
let path = self.emit_path(path, location);
self.trap.emit(generated::PathPat {
Expand All @@ -327,13 +329,24 @@ impl CrateTranslator<'_> {
})
}
ra_ap_hir_def::hir::Pat::Bind { id, subpat } => {
let subpat = subpat.map(|pat| self.emit_pat(pat, body, source_map));
self.trap.emit(generated::IdentPat {
id: TrapId::Star,
location,
subpat,
binding_id: body.bindings[*id].name.as_str().into(),
})
let binding = &body.bindings[*id];
if binding.mode == BindingAnnotation::Unannotated && subpat.is_none() {
let name = binding.name.to_owned();
let path = self.emit_path(&name.into(), location);
self.trap.emit(generated::PathPat {
id: TrapId::Star,
location,
path,
})
} else {
let subpat = subpat.map(|pat| self.emit_pat(pat, body, source_map));
self.trap.emit(generated::IdentPat {
id: TrapId::Star,
location,
subpat,
binding_id: binding.name.as_str().into(),
})
}
}
ra_ap_hir_def::hir::Pat::TupleStruct {
path,
Expand Down

0 comments on commit 71d816c

Please sign in to comment.