mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Merge #9288
9288: internal: cleanup tests r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
1c1f30bebf
3 changed files with 600 additions and 613 deletions
|
@ -216,7 +216,7 @@ mod tests {
|
||||||
cov_mark::check!(qualify_path_unqualified_name);
|
cov_mark::check!(qualify_path_unqualified_name);
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod std {
|
mod std {
|
||||||
pub mod fmt {
|
pub mod fmt {
|
||||||
pub struct Formatter;
|
pub struct Formatter;
|
||||||
|
@ -226,8 +226,8 @@ mod tests {
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
$0Formatter
|
$0Formatter
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod std {
|
mod std {
|
||||||
pub mod fmt {
|
pub mod fmt {
|
||||||
pub struct Formatter;
|
pub struct Formatter;
|
||||||
|
@ -237,7 +237,7 @@ mod tests {
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
fmt::Formatter
|
fmt::Formatter
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,20 +245,20 @@ mod tests {
|
||||||
fn applicable_when_found_an_import() {
|
fn applicable_when_found_an_import() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
$0PubStruct
|
$0PubStruct
|
||||||
|
|
||||||
pub mod PubMod {
|
pub mod PubMod {
|
||||||
pub struct PubStruct;
|
pub struct PubStruct;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
PubMod::PubStruct
|
PubMod::PubStruct
|
||||||
|
|
||||||
pub mod PubMod {
|
pub mod PubMod {
|
||||||
pub struct PubStruct;
|
pub struct PubStruct;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ mod tests {
|
||||||
fn applicable_in_macros() {
|
fn applicable_in_macros() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
($i:ident) => { fn foo(a: $i) {} }
|
($i:ident) => { fn foo(a: $i) {} }
|
||||||
}
|
}
|
||||||
|
@ -275,8 +275,8 @@ mod tests {
|
||||||
pub mod PubMod {
|
pub mod PubMod {
|
||||||
pub struct PubStruct;
|
pub struct PubStruct;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
($i:ident) => { fn foo(a: $i) {} }
|
($i:ident) => { fn foo(a: $i) {} }
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ mod tests {
|
||||||
pub mod PubMod {
|
pub mod PubMod {
|
||||||
pub struct PubStruct;
|
pub struct PubStruct;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ mod tests {
|
||||||
fn applicable_when_found_multiple_imports() {
|
fn applicable_when_found_multiple_imports() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
PubSt$0ruct
|
PubSt$0ruct
|
||||||
|
|
||||||
pub mod PubMod1 {
|
pub mod PubMod1 {
|
||||||
|
@ -305,8 +305,8 @@ mod tests {
|
||||||
pub mod PubMod3 {
|
pub mod PubMod3 {
|
||||||
pub struct PubStruct;
|
pub struct PubStruct;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
PubMod3::PubStruct
|
PubMod3::PubStruct
|
||||||
|
|
||||||
pub mod PubMod1 {
|
pub mod PubMod1 {
|
||||||
|
@ -318,7 +318,7 @@ mod tests {
|
||||||
pub mod PubMod3 {
|
pub mod PubMod3 {
|
||||||
pub struct PubStruct;
|
pub struct PubStruct;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ mod tests {
|
||||||
fn not_applicable_for_already_imported_types() {
|
fn not_applicable_for_already_imported_types() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
use PubMod::PubStruct;
|
use PubMod::PubStruct;
|
||||||
|
|
||||||
PubStruct$0
|
PubStruct$0
|
||||||
|
@ -334,7 +334,7 @@ mod tests {
|
||||||
pub mod PubMod {
|
pub mod PubMod {
|
||||||
pub struct PubStruct;
|
pub struct PubStruct;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,35 +342,32 @@ mod tests {
|
||||||
fn not_applicable_for_types_with_private_paths() {
|
fn not_applicable_for_types_with_private_paths() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
PrivateStruct$0
|
PrivateStruct$0
|
||||||
|
|
||||||
pub mod PubMod {
|
pub mod PubMod {
|
||||||
struct PrivateStruct;
|
struct PrivateStruct;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn not_applicable_when_no_imports_found() {
|
fn not_applicable_when_no_imports_found() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(qualify_path, r#"PubStruct$0"#);
|
||||||
qualify_path,
|
|
||||||
"
|
|
||||||
PubStruct$0",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn not_applicable_in_import_statements() {
|
fn not_applicable_in_import_statements() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
use PubStruct$0;
|
use PubStruct$0;
|
||||||
|
|
||||||
pub mod PubMod {
|
pub mod PubMod {
|
||||||
pub struct PubStruct;
|
pub struct PubStruct;
|
||||||
}",
|
}
|
||||||
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,20 +375,20 @@ mod tests {
|
||||||
fn qualify_function() {
|
fn qualify_function() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
test_function$0
|
test_function$0
|
||||||
|
|
||||||
pub mod PubMod {
|
pub mod PubMod {
|
||||||
pub fn test_function() {};
|
pub fn test_function() {};
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
PubMod::test_function
|
PubMod::test_function
|
||||||
|
|
||||||
pub mod PubMod {
|
pub mod PubMod {
|
||||||
pub fn test_function() {};
|
pub fn test_function() {};
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +396,7 @@ mod tests {
|
||||||
fn qualify_macro() {
|
fn qualify_macro() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
//- /lib.rs crate:crate_with_macro
|
//- /lib.rs crate:crate_with_macro
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
|
@ -410,12 +407,12 @@ macro_rules! foo {
|
||||||
fn main() {
|
fn main() {
|
||||||
foo$0
|
foo$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
crate_with_macro::foo
|
crate_with_macro::foo
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,13 +420,13 @@ fn main() {
|
||||||
fn qualify_path_target() {
|
fn qualify_path_target() {
|
||||||
check_assist_target(
|
check_assist_target(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
struct AssistInfo {
|
struct AssistInfo {
|
||||||
group_label: Option<$0GroupLabel>,
|
group_label: Option<$0GroupLabel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
mod m { pub struct GroupLabel; }
|
mod m { pub struct GroupLabel; }
|
||||||
",
|
"#,
|
||||||
"GroupLabel",
|
"GroupLabel",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -438,7 +435,7 @@ fn main() {
|
||||||
fn not_applicable_when_path_start_is_imported() {
|
fn not_applicable_when_path_start_is_imported() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
pub mod mod1 {
|
pub mod mod1 {
|
||||||
pub mod mod2 {
|
pub mod mod2 {
|
||||||
pub mod mod3 {
|
pub mod mod3 {
|
||||||
|
@ -451,7 +448,7 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
mod2::mod3::TestStruct$0
|
mod2::mod3::TestStruct$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +456,7 @@ fn main() {
|
||||||
fn not_applicable_for_imported_function() {
|
fn not_applicable_for_imported_function() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
pub mod test_mod {
|
pub mod test_mod {
|
||||||
pub fn test_function() {}
|
pub fn test_function() {}
|
||||||
}
|
}
|
||||||
|
@ -468,7 +465,7 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
test_function$0
|
test_function$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +473,7 @@ fn main() {
|
||||||
fn associated_struct_function() {
|
fn associated_struct_function() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub struct TestStruct {}
|
pub struct TestStruct {}
|
||||||
impl TestStruct {
|
impl TestStruct {
|
||||||
|
@ -487,8 +484,8 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
TestStruct::test_function$0
|
TestStruct::test_function$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub struct TestStruct {}
|
pub struct TestStruct {}
|
||||||
impl TestStruct {
|
impl TestStruct {
|
||||||
|
@ -499,7 +496,7 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
test_mod::TestStruct::test_function
|
test_mod::TestStruct::test_function
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,7 +505,7 @@ fn main() {
|
||||||
cov_mark::check!(qualify_path_qualifier_start);
|
cov_mark::check!(qualify_path_qualifier_start);
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub struct TestStruct {}
|
pub struct TestStruct {}
|
||||||
impl TestStruct {
|
impl TestStruct {
|
||||||
|
@ -519,8 +516,8 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
TestStruct::TEST_CONST$0
|
TestStruct::TEST_CONST$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub struct TestStruct {}
|
pub struct TestStruct {}
|
||||||
impl TestStruct {
|
impl TestStruct {
|
||||||
|
@ -531,16 +528,16 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
test_mod::TestStruct::TEST_CONST
|
test_mod::TestStruct::TEST_CONST
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore = "FIXME: non-trait assoc items completion is unsupported yet, see FIXME in the import_assets.rs for more details"]
|
|
||||||
fn associated_struct_const_unqualified() {
|
fn associated_struct_const_unqualified() {
|
||||||
check_assist(
|
// FIXME: non-trait assoc items completion is unsupported yet, see FIXME in the import_assets.rs for more details
|
||||||
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub struct TestStruct {}
|
pub struct TestStruct {}
|
||||||
impl TestStruct {
|
impl TestStruct {
|
||||||
|
@ -551,19 +548,7 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
TEST_CONST$0
|
TEST_CONST$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
|
||||||
mod test_mod {
|
|
||||||
pub struct TestStruct {}
|
|
||||||
impl TestStruct {
|
|
||||||
const TEST_CONST: u8 = 42;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
test_mod::TestStruct::TEST_CONST
|
|
||||||
}
|
|
||||||
",
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +556,7 @@ fn main() {
|
||||||
fn associated_trait_function() {
|
fn associated_trait_function() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_function();
|
fn test_function();
|
||||||
|
@ -585,8 +570,8 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
test_mod::TestStruct::test_function$0
|
test_mod::TestStruct::test_function$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_function();
|
fn test_function();
|
||||||
|
@ -600,7 +585,7 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
<test_mod::TestStruct as test_mod::TestTrait>::test_function
|
<test_mod::TestStruct as test_mod::TestTrait>::test_function
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,7 +593,7 @@ fn main() {
|
||||||
fn not_applicable_for_imported_trait_for_function() {
|
fn not_applicable_for_imported_trait_for_function() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_function();
|
fn test_function();
|
||||||
|
@ -632,7 +617,7 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
test_mod::TestEnum::test_function$0;
|
test_mod::TestEnum::test_function$0;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,7 +626,7 @@ fn main() {
|
||||||
cov_mark::check!(qualify_path_trait_assoc_item);
|
cov_mark::check!(qualify_path_trait_assoc_item);
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
const TEST_CONST: u8;
|
const TEST_CONST: u8;
|
||||||
|
@ -655,8 +640,8 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
test_mod::TestStruct::TEST_CONST$0
|
test_mod::TestStruct::TEST_CONST$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
const TEST_CONST: u8;
|
const TEST_CONST: u8;
|
||||||
|
@ -670,7 +655,7 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
<test_mod::TestStruct as test_mod::TestTrait>::TEST_CONST
|
<test_mod::TestStruct as test_mod::TestTrait>::TEST_CONST
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,7 +663,7 @@ fn main() {
|
||||||
fn not_applicable_for_imported_trait_for_const() {
|
fn not_applicable_for_imported_trait_for_const() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
const TEST_CONST: u8;
|
const TEST_CONST: u8;
|
||||||
|
@ -702,7 +687,7 @@ fn main() {
|
||||||
fn main() {
|
fn main() {
|
||||||
test_mod::TestEnum::TEST_CONST$0;
|
test_mod::TestEnum::TEST_CONST$0;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,7 +696,7 @@ fn main() {
|
||||||
cov_mark::check!(qualify_path_trait_method);
|
cov_mark::check!(qualify_path_trait_method);
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_method(&self);
|
fn test_method(&self);
|
||||||
|
@ -726,8 +711,8 @@ fn main() {
|
||||||
let test_struct = test_mod::TestStruct {};
|
let test_struct = test_mod::TestStruct {};
|
||||||
test_struct.test_meth$0od()
|
test_struct.test_meth$0od()
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_method(&self);
|
fn test_method(&self);
|
||||||
|
@ -742,7 +727,7 @@ fn main() {
|
||||||
let test_struct = test_mod::TestStruct {};
|
let test_struct = test_mod::TestStruct {};
|
||||||
test_mod::TestTrait::test_method(&test_struct)
|
test_mod::TestTrait::test_method(&test_struct)
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,7 +735,7 @@ fn main() {
|
||||||
fn trait_method_multi_params() {
|
fn trait_method_multi_params() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_method(&self, test: i32);
|
fn test_method(&self, test: i32);
|
||||||
|
@ -765,8 +750,8 @@ fn main() {
|
||||||
let test_struct = test_mod::TestStruct {};
|
let test_struct = test_mod::TestStruct {};
|
||||||
test_struct.test_meth$0od(42)
|
test_struct.test_meth$0od(42)
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_method(&self, test: i32);
|
fn test_method(&self, test: i32);
|
||||||
|
@ -781,7 +766,7 @@ fn main() {
|
||||||
let test_struct = test_mod::TestStruct {};
|
let test_struct = test_mod::TestStruct {};
|
||||||
test_mod::TestTrait::test_method(&test_struct, 42)
|
test_mod::TestTrait::test_method(&test_struct, 42)
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -789,7 +774,7 @@ fn main() {
|
||||||
fn trait_method_consume() {
|
fn trait_method_consume() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_method(self);
|
fn test_method(self);
|
||||||
|
@ -804,8 +789,8 @@ fn main() {
|
||||||
let test_struct = test_mod::TestStruct {};
|
let test_struct = test_mod::TestStruct {};
|
||||||
test_struct.test_meth$0od()
|
test_struct.test_meth$0od()
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_method(self);
|
fn test_method(self);
|
||||||
|
@ -820,7 +805,7 @@ fn main() {
|
||||||
let test_struct = test_mod::TestStruct {};
|
let test_struct = test_mod::TestStruct {};
|
||||||
test_mod::TestTrait::test_method(test_struct)
|
test_mod::TestTrait::test_method(test_struct)
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,7 +813,7 @@ fn main() {
|
||||||
fn trait_method_cross_crate() {
|
fn trait_method_cross_crate() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
//- /main.rs crate:main deps:dep
|
//- /main.rs crate:main deps:dep
|
||||||
fn main() {
|
fn main() {
|
||||||
let test_struct = dep::test_mod::TestStruct {};
|
let test_struct = dep::test_mod::TestStruct {};
|
||||||
|
@ -844,13 +829,13 @@ fn main() {
|
||||||
fn test_method(&self) {}
|
fn test_method(&self) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
let test_struct = dep::test_mod::TestStruct {};
|
let test_struct = dep::test_mod::TestStruct {};
|
||||||
dep::test_mod::TestTrait::test_method(&test_struct)
|
dep::test_mod::TestTrait::test_method(&test_struct)
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -858,7 +843,7 @@ fn main() {
|
||||||
fn assoc_fn_cross_crate() {
|
fn assoc_fn_cross_crate() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
//- /main.rs crate:main deps:dep
|
//- /main.rs crate:main deps:dep
|
||||||
fn main() {
|
fn main() {
|
||||||
dep::test_mod::TestStruct::test_func$0tion
|
dep::test_mod::TestStruct::test_func$0tion
|
||||||
|
@ -873,12 +858,12 @@ fn main() {
|
||||||
fn test_function() {}
|
fn test_function() {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
<dep::test_mod::TestStruct as dep::test_mod::TestTrait>::test_function
|
<dep::test_mod::TestStruct as dep::test_mod::TestTrait>::test_function
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,7 +871,7 @@ fn main() {
|
||||||
fn assoc_const_cross_crate() {
|
fn assoc_const_cross_crate() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
//- /main.rs crate:main deps:dep
|
//- /main.rs crate:main deps:dep
|
||||||
fn main() {
|
fn main() {
|
||||||
dep::test_mod::TestStruct::CONST$0
|
dep::test_mod::TestStruct::CONST$0
|
||||||
|
@ -901,12 +886,12 @@ fn main() {
|
||||||
const CONST: bool = true;
|
const CONST: bool = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
<dep::test_mod::TestStruct as dep::test_mod::TestTrait>::CONST
|
<dep::test_mod::TestStruct as dep::test_mod::TestTrait>::CONST
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -914,7 +899,7 @@ fn main() {
|
||||||
fn assoc_fn_as_method_cross_crate() {
|
fn assoc_fn_as_method_cross_crate() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
//- /main.rs crate:main deps:dep
|
//- /main.rs crate:main deps:dep
|
||||||
fn main() {
|
fn main() {
|
||||||
let test_struct = dep::test_mod::TestStruct {};
|
let test_struct = dep::test_mod::TestStruct {};
|
||||||
|
@ -930,7 +915,7 @@ fn main() {
|
||||||
fn test_function() {}
|
fn test_function() {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -938,7 +923,7 @@ fn main() {
|
||||||
fn private_trait_cross_crate() {
|
fn private_trait_cross_crate() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
//- /main.rs crate:main deps:dep
|
//- /main.rs crate:main deps:dep
|
||||||
fn main() {
|
fn main() {
|
||||||
let test_struct = dep::test_mod::TestStruct {};
|
let test_struct = dep::test_mod::TestStruct {};
|
||||||
|
@ -954,7 +939,7 @@ fn main() {
|
||||||
fn test_method(&self) {}
|
fn test_method(&self) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,7 +947,7 @@ fn main() {
|
||||||
fn not_applicable_for_imported_trait_for_method() {
|
fn not_applicable_for_imported_trait_for_method() {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_method(&self);
|
fn test_method(&self);
|
||||||
|
@ -987,7 +972,7 @@ fn main() {
|
||||||
let one = test_mod::TestEnum::One;
|
let one = test_mod::TestEnum::One;
|
||||||
one.test$0_method();
|
one.test$0_method();
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1114,7 +1099,7 @@ fn main() {}
|
||||||
fn keep_generic_annotations_leading_colon() {
|
fn keep_generic_annotations_leading_colon() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
//- /lib.rs crate:dep
|
//- /lib.rs crate:dep
|
||||||
pub mod generic { pub struct Thing<'a, T>(&'a T); }
|
pub mod generic { pub struct Thing<'a, T>(&'a T); }
|
||||||
|
|
||||||
|
@ -1122,7 +1107,7 @@ pub mod generic { pub struct Thing<'a, T>(&'a T); }
|
||||||
fn foo() -> Thin$0g::<'static, ()> {}
|
fn foo() -> Thin$0g::<'static, ()> {}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
",
|
"#,
|
||||||
r"
|
r"
|
||||||
fn foo() -> dep::generic::Thing::<'static, ()> {}
|
fn foo() -> dep::generic::Thing::<'static, ()> {}
|
||||||
|
|
||||||
|
@ -1135,7 +1120,7 @@ fn main() {}
|
||||||
fn associated_struct_const_generic() {
|
fn associated_struct_const_generic() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub struct TestStruct<T> {}
|
pub struct TestStruct<T> {}
|
||||||
impl<T> TestStruct<T> {
|
impl<T> TestStruct<T> {
|
||||||
|
@ -1146,8 +1131,8 @@ fn main() {}
|
||||||
fn main() {
|
fn main() {
|
||||||
TestStruct::<()>::TEST_CONST$0
|
TestStruct::<()>::TEST_CONST$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub struct TestStruct<T> {}
|
pub struct TestStruct<T> {}
|
||||||
impl<T> TestStruct<T> {
|
impl<T> TestStruct<T> {
|
||||||
|
@ -1158,7 +1143,7 @@ fn main() {}
|
||||||
fn main() {
|
fn main() {
|
||||||
test_mod::TestStruct::<()>::TEST_CONST
|
test_mod::TestStruct::<()>::TEST_CONST
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1166,7 +1151,7 @@ fn main() {}
|
||||||
fn associated_trait_const_generic() {
|
fn associated_trait_const_generic() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
const TEST_CONST: u8;
|
const TEST_CONST: u8;
|
||||||
|
@ -1180,8 +1165,8 @@ fn main() {}
|
||||||
fn main() {
|
fn main() {
|
||||||
test_mod::TestStruct::<()>::TEST_CONST$0
|
test_mod::TestStruct::<()>::TEST_CONST$0
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
const TEST_CONST: u8;
|
const TEST_CONST: u8;
|
||||||
|
@ -1195,7 +1180,7 @@ fn main() {}
|
||||||
fn main() {
|
fn main() {
|
||||||
<test_mod::TestStruct::<()> as test_mod::TestTrait>::TEST_CONST
|
<test_mod::TestStruct::<()> as test_mod::TestTrait>::TEST_CONST
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1203,7 +1188,7 @@ fn main() {}
|
||||||
fn trait_method_generic() {
|
fn trait_method_generic() {
|
||||||
check_assist(
|
check_assist(
|
||||||
qualify_path,
|
qualify_path,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_method<T>(&self);
|
fn test_method<T>(&self);
|
||||||
|
@ -1218,8 +1203,8 @@ fn main() {}
|
||||||
let test_struct = test_mod::TestStruct {};
|
let test_struct = test_mod::TestStruct {};
|
||||||
test_struct.test_meth$0od::<()>()
|
test_struct.test_meth$0od::<()>()
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
r"
|
r#"
|
||||||
mod test_mod {
|
mod test_mod {
|
||||||
pub trait TestTrait {
|
pub trait TestTrait {
|
||||||
fn test_method<T>(&self);
|
fn test_method<T>(&self);
|
||||||
|
@ -1234,7 +1219,7 @@ fn main() {}
|
||||||
let test_struct = test_mod::TestStruct {};
|
let test_struct = test_mod::TestStruct {};
|
||||||
test_mod::TestTrait::test_method::<()>(&test_struct)
|
test_mod::TestTrait::test_method::<()>(&test_struct)
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,12 +105,13 @@ fn foo<B: Bar
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore = "This case is very rare but there is no simple solutions to fix it."]
|
|
||||||
fn replace_impl_trait_with_exist_generic_letter() {
|
fn replace_impl_trait_with_exist_generic_letter() {
|
||||||
|
// FIXME: This is wrong, we should pick a different name if the one we
|
||||||
|
// want is already bound.
|
||||||
check_assist(
|
check_assist(
|
||||||
replace_impl_trait_with_generic,
|
replace_impl_trait_with_generic,
|
||||||
r#"fn foo<B>(bar: $0impl Bar) {}"#,
|
r#"fn foo<B>(bar: $0impl Bar) {}"#,
|
||||||
r#"fn foo<B, C: Bar>(bar: C) {}"#,
|
r#"fn foo<B, B: Bar>(bar: B) {}"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -511,13 +511,14 @@ use std::io;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore] // FIXME: Support this
|
|
||||||
fn split_out_merge() {
|
fn split_out_merge() {
|
||||||
|
// FIXME: This is suboptimal, we want to get `use std::fmt::{self, Result}`
|
||||||
|
// instead.
|
||||||
check_module(
|
check_module(
|
||||||
"std::fmt::Result",
|
"std::fmt::Result",
|
||||||
r"use std::{fmt, io};",
|
r"use std::{fmt, io};",
|
||||||
r"use std::fmt::{self, Result};
|
r"use std::fmt::Result;
|
||||||
use std::io;",
|
use std::{fmt, io};",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue