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.rs189
1 files changed, 189 insertions, 0 deletions
diff --git a/crates/ide-completion/src/tests/attribute.rs b/crates/ide-completion/src/tests/attribute.rs
index 46a3630045..9ff490f904 100644
--- a/crates/ide-completion/src/tests/attribute.rs
+++ b/crates/ide-completion/src/tests/attribute.rs
@@ -33,6 +33,7 @@ pub struct Foo(#[m$0] i32);
at diagnostic::do_not_recommend
at diagnostic::on_unimplemented
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -60,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
@@ -85,6 +87,7 @@ struct Foo;
at deprecated
at derive(…)
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -93,6 +96,7 @@ struct Foo;
at no_mangle
at non_exhaustive
at repr(…)
+ at unsafe(…)
at warn(…)
md proc_macros
kw crate::
@@ -158,6 +162,7 @@ fn attr_on_source_file() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -170,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::
@@ -189,6 +195,7 @@ fn attr_on_module() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -197,6 +204,7 @@ fn attr_on_module() {
at must_use
at no_mangle
at path = "…"
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -212,6 +220,7 @@ fn attr_on_module() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -219,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::
@@ -238,6 +248,7 @@ fn attr_on_macro_rules() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -246,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::
@@ -264,12 +276,14 @@ fn attr_on_macro_def() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
at forbid(…)
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -288,6 +302,7 @@ fn attr_on_extern_crate() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -295,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::
@@ -313,12 +329,14 @@ fn attr_on_use() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
at forbid(…)
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -337,12 +355,14 @@ fn attr_on_type_alias() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
at forbid(…)
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -368,6 +388,7 @@ struct Foo;
at derive(…)
at derive_const macro derive_const
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -376,6 +397,7 @@ struct Foo;
at no_mangle
at non_exhaustive
at repr(…)
+ at unsafe(…)
at warn(…)
md core
kw crate::
@@ -396,6 +418,7 @@ fn attr_on_enum() {
at deprecated
at derive(…)
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -404,6 +427,7 @@ fn attr_on_enum() {
at no_mangle
at non_exhaustive
at repr(…)
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -422,12 +446,14 @@ fn attr_on_const() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
at forbid(…)
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -446,6 +472,7 @@ fn attr_on_static() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -456,6 +483,7 @@ fn attr_on_static() {
at link_section = "…"
at must_use
at no_mangle
+ at unsafe(…)
at used
at warn(…)
kw crate::
@@ -476,12 +504,14 @@ fn attr_on_trait() {
at deprecated
at diagnostic::on_unimplemented
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
at forbid(…)
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -502,12 +532,14 @@ fn attr_on_impl() {
at deprecated
at diagnostic::do_not_recommend
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
at forbid(…)
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -522,12 +554,14 @@ fn attr_on_impl() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
at forbid(…)
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -548,12 +582,14 @@ fn attr_with_qualifier() {
at deprecated
at do_not_recommend
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
at forbid(…)
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
"#]],
);
@@ -566,6 +602,7 @@ fn attr_with_qualifier() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -573,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 {}"#,
@@ -616,6 +685,7 @@ fn attr_on_extern_block() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -623,6 +693,7 @@ fn attr_on_extern_block() {
at link
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -637,6 +708,7 @@ fn attr_on_extern_block() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -644,6 +716,7 @@ fn attr_on_extern_block() {
at link
at must_use
at no_mangle
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -682,6 +755,7 @@ fn attr_on_fn() {
at deny(…)
at deprecated
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -701,6 +775,7 @@ fn attr_on_fn() {
at target_feature(enable = "…")
at test
at track_caller
+ at unsafe(…)
at warn(…)
kw crate::
kw self::
@@ -724,6 +799,7 @@ fn attr_in_source_file_end() {
at diagnostic::do_not_recommend
at diagnostic::on_unimplemented
at doc = "…"
+ at doc = include_str!("…")
at doc(alias = "…")
at doc(hidden)
at expect(…)
@@ -750,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::
@@ -815,7 +892,10 @@ mod cfg {
#[cfg($0)]
"#,
expect![[r#"
+ ba all
+ ba any
ba dbg
+ ba not
ba opt_level
ba test
ba true
@@ -827,7 +907,10 @@ mod cfg {
#[cfg(b$0)]
"#,
expect![[r#"
+ ba all
+ ba any
ba dbg
+ ba not
ba opt_level
ba test
ba true
@@ -836,6 +919,98 @@ mod cfg {
}
#[test]
+ fn inside_cfg_attr() {
+ check(
+ r#"
+//- /main.rs cfg:test,dbg=false,opt_level=2
+#[cfg_attr($0)]
+"#,
+ expect![[r#"
+ ba all
+ ba any
+ ba dbg
+ ba not
+ ba opt_level
+ ba test
+ ba true
+ "#]],
+ );
+ check(
+ r#"
+//- /main.rs cfg:test,dbg=false,opt_level=2
+#[cfg_attr(b$0)]
+"#,
+ expect![[r#"
+ ba all
+ ba any
+ ba dbg
+ ba not
+ ba opt_level
+ ba test
+ ba true
+ "#]],
+ );
+ check(
+ r#"
+//- /main.rs cfg:test,dbg=false,opt_level=2
+#[cfg_attr($0, allow(deprecated))]
+"#,
+ expect![[r#"
+ ba all
+ ba any
+ ba dbg
+ ba not
+ ba opt_level
+ ba test
+ ba true
+ "#]],
+ );
+ check(
+ r#"
+//- /main.rs cfg:test,dbg=false,opt_level=2
+#[cfg_attr(b$0, allow(deprecated))]
+"#,
+ expect![[r#"
+ ba all
+ ba any
+ ba dbg
+ ba not
+ ba opt_level
+ ba test
+ ba true
+ "#]],
+ );
+ }
+
+ #[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"#,
@@ -852,6 +1027,20 @@ mod cfg {
"#]],
);
}
+
+ #[test]
+ fn inside_conditional() {
+ check_edit(
+ "all",
+ r#"
+//- /main.rs cfg:test,dbg=false,opt_level=2
+#[cfg($0)]
+"#,
+ r#"
+#[cfg(all($0))]
+"#,
+ );
+ }
}
mod derive {