Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/tests/attribute.rs')
| -rw-r--r-- | crates/ide-completion/src/tests/attribute.rs | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/crates/ide-completion/src/tests/attribute.rs b/crates/ide-completion/src/tests/attribute.rs index 2a6238997b..3701416dfc 100644 --- a/crates/ide-completion/src/tests/attribute.rs +++ b/crates/ide-completion/src/tests/attribute.rs @@ -61,6 +61,7 @@ pub struct Foo(#[m$0] i32); at target_feature(enable = "…") at test at track_caller + at unsafe(…) at used at warn(…) md mac @@ -95,6 +96,7 @@ struct Foo; at no_mangle at non_exhaustive at repr(…) + at unsafe(…) at warn(…) md proc_macros kw crate:: @@ -173,6 +175,7 @@ fn attr_on_source_file() { at no_std at recursion_limit = "…" at type_length_limit = … + at unsafe(…) at warn(…) at windows_subsystem = "…" kw crate:: @@ -201,6 +204,7 @@ fn attr_on_module() { at must_use at no_mangle at path = "…" + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -224,6 +228,7 @@ fn attr_on_module() { at must_use at no_implicit_prelude at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -252,6 +257,7 @@ fn attr_on_macro_rules() { at macro_use at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -277,6 +283,7 @@ fn attr_on_macro_def() { at forbid(…) at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -303,6 +310,7 @@ fn attr_on_extern_crate() { at macro_use at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -328,6 +336,7 @@ fn attr_on_use() { at forbid(…) at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -353,6 +362,7 @@ fn attr_on_type_alias() { at forbid(…) at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -387,6 +397,7 @@ struct Foo; at no_mangle at non_exhaustive at repr(…) + at unsafe(…) at warn(…) md core kw crate:: @@ -416,6 +427,7 @@ fn attr_on_enum() { at no_mangle at non_exhaustive at repr(…) + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -441,6 +453,7 @@ fn attr_on_const() { at forbid(…) at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -470,6 +483,7 @@ fn attr_on_static() { at link_section = "…" at must_use at no_mangle + at unsafe(…) at used at warn(…) kw crate:: @@ -497,6 +511,7 @@ fn attr_on_trait() { at forbid(…) at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -524,6 +539,7 @@ fn attr_on_impl() { at forbid(…) at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -545,6 +561,7 @@ fn attr_on_impl() { at forbid(…) at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -572,6 +589,7 @@ fn attr_with_qualifier() { at forbid(…) at must_use at no_mangle + at unsafe(…) at warn(…) "#]], ); @@ -592,12 +610,44 @@ fn attr_with_qualifier() { at must_use at no_mangle at on_unimplemented + at unsafe(…) at warn(…) "#]], ); } #[test] +fn attr_on_unsafe_attr() { + check( + r#"#[unsafe($0)] static FOO: () = ()"#, + expect![[r#" + at allow(…) + at cfg(…) + at cfg_attr(…) + at deny(…) + at deprecated + at doc = "…" + at doc = include_str!("…") + at doc(alias = "…") + at doc(hidden) + at expect(…) + at export_name = "…" + at forbid(…) + at global_allocator + at link_name = "…" + at link_section = "…" + at must_use + at no_mangle + at unsafe(…) + at used + at warn(…) + kw crate:: + kw self:: + "#]], + ); +} + +#[test] fn attr_diagnostic_on_unimplemented() { check( r#"#[diagnostic::on_unimplemented($0)] trait Foo {}"#, @@ -643,6 +693,7 @@ fn attr_on_extern_block() { at link at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -665,6 +716,7 @@ fn attr_on_extern_block() { at link at must_use at no_mangle + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -723,6 +775,7 @@ fn attr_on_fn() { at target_feature(enable = "…") at test at track_caller + at unsafe(…) at warn(…) kw crate:: kw self:: @@ -773,6 +826,7 @@ fn attr_in_source_file_end() { at target_feature(enable = "…") at test at track_caller + at unsafe(…) at used at warn(…) kw crate:: @@ -929,6 +983,34 @@ mod cfg { } #[test] + fn complete_key_attr() { + check_edit( + "test", + r#" +//- /main.rs cfg:test,dbg=false,opt_level=2 +#[cfg($0)] +"#, + r#" +#[cfg(test)] +"#, + ); + } + + #[test] + fn complete_key_value_attr() { + check_edit( + "opt_level", + r#" +//- /main.rs cfg:test,dbg=false,opt_level=2 +#[cfg($0)] +"#, + r#" +#[cfg(opt_level = $0)] +"#, + ); + } + + #[test] fn cfg_target_endian() { check( r#"#[cfg(target_endian = $0"#, @@ -1426,3 +1508,55 @@ extern crate dep; ) } } + +#[test] +fn builtin_macro_completed_only_as_its_kind() { + check( + r#" +#[rustc_builtin_macro] +pub macro define_opaque($($tt:tt)*) { + /* compiler built-in */ +} + +fn foo() { + def$0 +} + "#, + expect![[r#" + fn foo() fn() + bt u32 u32 + kw async + kw const + kw crate:: + kw enum + kw extern + kw false + kw fn + kw for + kw if + kw if let + kw impl + kw impl for + kw let + kw letm + kw loop + kw match + kw mod + kw return + kw self:: + kw static + kw struct + kw trait + kw true + kw type + kw union + kw unsafe + kw use + kw while + kw while let + sn macro_rules + sn pd + sn ppd + "#]], + ); +} |