mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00

* a rule * access * after * amount * annotations * assignment * assist * associated * attribute * borrowed * built-in type * clarification * command * const * constructor * corresponding * counterparts * curlies * dependencies * deterministic * diagnostic * duplicates * edge * edited * efficient * elsewhere * execution * expression * extensions * extracted * fill * github * helper * heuristic * incomplete * indent end * inlay * invocation * lifetime * looking * maybe * move * mutability * mutable * necessarily * necessary * negative * nonexistent * occurred * offsets * offsetted * overridden * parameters * params * params_and_where_preds_in_scope * paredit * parent * parentheses * prepended if * punctuation * receive * receiver * referring * repeated * representing * semantically * separately * shouldnot * siblings * similar * something's * statement * struct * structure * surprise * the * this * transparent * unimplemented * unnamed * unnecessary * unneeded * unreachable * unterminated * utilities * variant * variants * visibility * work around (v) * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
167 lines
3 KiB
Rust
167 lines
3 KiB
Rust
//! Completion tests for expressions.
|
|
use expect_test::{expect, Expect};
|
|
|
|
use crate::tests::completion_list;
|
|
|
|
fn check(ra_fixture: &str, expect: Expect) {
|
|
let actual = completion_list(ra_fixture);
|
|
expect.assert_eq(&actual)
|
|
}
|
|
|
|
#[test]
|
|
fn complete_dot_in_attr() {
|
|
check(
|
|
r#"
|
|
//- proc_macros: identity
|
|
pub struct Foo;
|
|
impl Foo {
|
|
fn foo(&self) {}
|
|
}
|
|
|
|
#[proc_macros::identity]
|
|
fn main() {
|
|
Foo.$0
|
|
}
|
|
"#,
|
|
expect![[r#"
|
|
me foo() fn(&self)
|
|
sn box Box::new(expr)
|
|
sn call function(expr)
|
|
sn dbg dbg!(expr)
|
|
sn dbgr dbg!(&expr)
|
|
sn let let
|
|
sn letm let mut
|
|
sn match match expr {}
|
|
sn ref &expr
|
|
sn refm &mut expr
|
|
sn unsafe unsafe {}
|
|
"#]],
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn complete_dot_in_attr2() {
|
|
check(
|
|
r#"
|
|
//- proc_macros: identity
|
|
pub struct Foo;
|
|
impl Foo {
|
|
fn foo(&self) {}
|
|
}
|
|
|
|
#[proc_macros::identity]
|
|
fn main() {
|
|
Foo.f$0
|
|
}
|
|
"#,
|
|
expect![[r#"
|
|
me foo() fn(&self)
|
|
sn box Box::new(expr)
|
|
sn call function(expr)
|
|
sn dbg dbg!(expr)
|
|
sn dbgr dbg!(&expr)
|
|
sn let let
|
|
sn letm let mut
|
|
sn match match expr {}
|
|
sn ref &expr
|
|
sn refm &mut expr
|
|
sn unsafe unsafe {}
|
|
"#]],
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn complete_dot_in_attr_input() {
|
|
check(
|
|
r#"
|
|
//- proc_macros: input_replace
|
|
pub struct Foo;
|
|
impl Foo {
|
|
fn foo(&self) {}
|
|
}
|
|
|
|
#[proc_macros::input_replace(
|
|
fn surprise() {
|
|
Foo.$0
|
|
}
|
|
)]
|
|
fn main() {}
|
|
"#,
|
|
expect![[r#"
|
|
me foo() fn(&self)
|
|
sn box Box::new(expr)
|
|
sn call function(expr)
|
|
sn dbg dbg!(expr)
|
|
sn dbgr dbg!(&expr)
|
|
sn let let
|
|
sn letm let mut
|
|
sn match match expr {}
|
|
sn ref &expr
|
|
sn refm &mut expr
|
|
sn unsafe unsafe {}
|
|
"#]],
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn complete_dot_in_attr_input2() {
|
|
check(
|
|
r#"
|
|
//- proc_macros: input_replace
|
|
pub struct Foo;
|
|
impl Foo {
|
|
fn foo(&self) {}
|
|
}
|
|
|
|
#[proc_macros::input_replace(
|
|
fn surprise() {
|
|
Foo.f$0
|
|
}
|
|
)]
|
|
fn main() {}
|
|
"#,
|
|
expect![[r#"
|
|
me foo() fn(&self)
|
|
sn box Box::new(expr)
|
|
sn call function(expr)
|
|
sn dbg dbg!(expr)
|
|
sn dbgr dbg!(&expr)
|
|
sn let let
|
|
sn letm let mut
|
|
sn match match expr {}
|
|
sn ref &expr
|
|
sn refm &mut expr
|
|
sn unsafe unsafe {}
|
|
"#]],
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn issue_13836_str() {
|
|
check(
|
|
r#"
|
|
//- proc_macros: shorten
|
|
fn main() {
|
|
let s = proc_macros::shorten!("text.$0");
|
|
}
|
|
"#,
|
|
expect![[r#""#]],
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn issue_13836_ident() {
|
|
check(
|
|
r#"
|
|
//- proc_macros: shorten
|
|
struct S;
|
|
impl S {
|
|
fn foo(&self) {}
|
|
}
|
|
fn main() {
|
|
let s = proc_macros::shorten!(S.fo$0);
|
|
}
|
|
"#,
|
|
expect![[r#""#]],
|
|
)
|
|
}
|