mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
the scope of the return type is not the body of the function
This commit is contained in:
parent
519d7484f3
commit
fbf8e12234
3 changed files with 30 additions and 7 deletions
|
@ -600,13 +600,11 @@ fn scope_for_offset(
|
||||||
.filter(|it| it.value.kind() == SyntaxKind::MACRO_CALL)?;
|
.filter(|it| it.value.kind() == SyntaxKind::MACRO_CALL)?;
|
||||||
Some((source.value.text_range(), scope))
|
Some((source.value.text_range(), scope))
|
||||||
})
|
})
|
||||||
// find containing scope
|
.filter(|(expr_range, _scope)| {
|
||||||
.min_by_key(|(expr_range, _scope)| {
|
expr_range.start() <= offset.value && offset.value <= expr_range.end()
|
||||||
(
|
|
||||||
!(expr_range.start() <= offset.value && offset.value <= expr_range.end()),
|
|
||||||
expr_range.len(),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
// find containing scope
|
||||||
|
.min_by_key(|(expr_range, _scope)| expr_range.len())
|
||||||
.map(|(expr_range, scope)| {
|
.map(|(expr_range, scope)| {
|
||||||
adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope)
|
adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope)
|
||||||
})
|
})
|
||||||
|
|
|
@ -513,7 +513,6 @@ fn quux(x: i32) {
|
||||||
",
|
",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
fn quux(…) fn(i32)
|
fn quux(…) fn(i32)
|
||||||
lc x i32
|
|
||||||
ma m!(…) macro_rules! m
|
ma m!(…) macro_rules! m
|
||||||
bt u32
|
bt u32
|
||||||
kw crate::
|
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]
|
#[test]
|
||||||
fn inferred_type_const() {
|
fn inferred_type_const() {
|
||||||
check(
|
check(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue