mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
Add cfg_attr predicate completion
Example --- ```rust #[cfg_attr($0, must_use)] struct Foo; ```
This commit is contained in:
parent
1f4e5e82ff
commit
b7a2f21d58
2 changed files with 53 additions and 1 deletions
|
|
@ -70,7 +70,7 @@ pub(crate) fn complete_known_attribute_input(
|
|||
|
||||
lint::complete_lint(acc, ctx, colon_prefix, &existing_lints, &lints);
|
||||
}
|
||||
["cfg"] => cfg::complete_cfg(acc, ctx),
|
||||
["cfg"] | ["cfg_attr"] => cfg::complete_cfg(acc, ctx),
|
||||
["macro_use"] => macro_use::complete_macro_use(
|
||||
acc,
|
||||
ctx,
|
||||
|
|
|
|||
|
|
@ -835,6 +835,58 @@ mod cfg {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inside_cfg_attr() {
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs cfg:test,dbg=false,opt_level=2
|
||||
#[cfg_attr($0)]
|
||||
"#,
|
||||
expect![[r#"
|
||||
ba dbg
|
||||
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 dbg
|
||||
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 dbg
|
||||
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 dbg
|
||||
ba opt_level
|
||||
ba test
|
||||
ba true
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cfg_target_endian() {
|
||||
check(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue