mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Add test for invalidation of inferred types when typing inside function
This currently fails, but should work once we have hir::Expr.
This commit is contained in:
parent
3e42a15878
commit
a6f33b4ca5
2 changed files with 58 additions and 0 deletions
|
@ -87,6 +87,20 @@ fn module_from_source(
|
|||
Ok(Some(Module::new(db, source_root_id, module_id)?))
|
||||
}
|
||||
|
||||
pub fn function_from_position(
|
||||
db: &impl HirDatabase,
|
||||
position: FilePosition,
|
||||
) -> Cancelable<Option<Function>> {
|
||||
let file = db.source_file(position.file_id);
|
||||
let fn_def = if let Some(f) = find_node_at_offset::<ast::FnDef>(file.syntax(), position.offset)
|
||||
{
|
||||
f
|
||||
} else {
|
||||
return Ok(None);
|
||||
};
|
||||
function_from_source(db, position.file_id, fn_def)
|
||||
}
|
||||
|
||||
pub fn function_from_source(
|
||||
db: &impl HirDatabase,
|
||||
file_id: FileId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue