the scope of the return type is not the body of the function
This commit is contained in:
parent
519d7484f3
commit
fbf8e12234
@ -600,13 +600,11 @@ fn scope_for_offset(
|
||||
.filter(|it| it.value.kind() == SyntaxKind::MACRO_CALL)?;
|
||||
Some((source.value.text_range(), scope))
|
||||
})
|
||||
// find containing scope
|
||||
.min_by_key(|(expr_range, _scope)| {
|
||||
(
|
||||
!(expr_range.start() <= offset.value && offset.value <= expr_range.end()),
|
||||
expr_range.len(),
|
||||
)
|
||||
.filter(|(expr_range, _scope)| {
|
||||
expr_range.start() <= offset.value && offset.value <= expr_range.end()
|
||||
})
|
||||
// find containing scope
|
||||
.min_by_key(|(expr_range, _scope)| expr_range.len())
|
||||
.map(|(expr_range, scope)| {
|
||||
adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope)
|
||||
})
|
||||
|
@ -513,7 +513,6 @@ fn quux(x: i32) {
|
||||
",
|
||||
expect![[r#"
|
||||
fn quux(…) fn(i32)
|
||||
lc x i32
|
||||
ma m!(…) macro_rules! m
|
||||
bt u32
|
||||
kw crate::
|
||||
|
@ -89,6 +89,32 @@ fn x<'lt, T, const C: usize>() -> $0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fn_return_type2() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() -> B$0 {
|
||||
struct Bar;
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
en Enum
|
||||
ma makro!(…) macro_rules! makro
|
||||
md module
|
||||
st Record
|
||||
st Tuple
|
||||
st Unit
|
||||
tt Trait
|
||||
un Union
|
||||
bt u32
|
||||
it ()
|
||||
kw crate::
|
||||
kw self::
|
||||
kw super::
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inferred_type_const() {
|
||||
check(
|
||||
|
Loading…
Reference in New Issue
Block a user