File tree 2 files changed +40
-34
lines changed
ide-completion/src/completions
2 files changed +40
-34
lines changed Original file line number Diff line number Diff line change @@ -3046,14 +3046,23 @@ impl Macro {
3046
3046
MacroId :: Macro2Id ( it) => {
3047
3047
matches ! ( it. lookup( db. upcast( ) ) . expander, MacroExpander :: BuiltInEager ( eager) if eager. is_env_or_option_env( ) )
3048
3048
}
3049
- MacroId :: MacroRulesId ( _) | MacroId :: ProcMacroId ( _) => false ,
3049
+ MacroId :: MacroRulesId ( it) => {
3050
+ matches ! ( it. lookup( db. upcast( ) ) . expander, MacroExpander :: BuiltInEager ( eager) if eager. is_env_or_option_env( ) )
3051
+ }
3052
+ MacroId :: ProcMacroId ( _) => false ,
3050
3053
}
3051
3054
}
3052
3055
3053
3056
pub fn is_asm_or_global_asm ( & self , db : & dyn HirDatabase ) -> bool {
3054
- matches ! ( self . id, MacroId :: Macro2Id ( it) if {
3055
- matches!( it. lookup( db. upcast( ) ) . expander, MacroExpander :: BuiltIn ( m) if m. is_asm( ) )
3056
- } )
3057
+ match self . id {
3058
+ MacroId :: Macro2Id ( it) => {
3059
+ matches ! ( it. lookup( db. upcast( ) ) . expander, MacroExpander :: BuiltIn ( m) if m. is_asm( ) )
3060
+ }
3061
+ MacroId :: MacroRulesId ( it) => {
3062
+ matches ! ( it. lookup( db. upcast( ) ) . expander, MacroExpander :: BuiltIn ( m) if m. is_asm( ) )
3063
+ }
3064
+ MacroId :: ProcMacroId ( _) => false ,
3065
+ }
3057
3066
}
3058
3067
3059
3068
pub fn is_attr ( & self , db : & dyn HirDatabase ) -> bool {
Original file line number Diff line number Diff line change @@ -68,43 +68,40 @@ pub(crate) fn complete_cargo_env_vars(
68
68
mod tests {
69
69
use crate :: tests:: { check_edit, completion_list} ;
70
70
71
- fn check ( macro_name : & str ) {
71
+ #[ test]
72
+ fn completes_env_variable_in_env ( ) {
72
73
check_edit (
73
74
"CARGO_BIN_NAME" ,
74
- & format ! (
75
- r#"
76
- #[rustc_builtin_macro]
77
- macro {macro_name} {{
78
- ($var:literal) => {{ 0 }}
79
- }}
80
-
81
- fn main() {{
82
- let foo = {macro_name}!("CAR$0");
83
- }}
84
- "#
85
- ) ,
86
- & format ! (
87
- r#"
88
- #[rustc_builtin_macro]
89
- macro {macro_name} {{
90
- ($var:literal) => {{ 0 }}
91
- }}
92
-
93
- fn main() {{
94
- let foo = {macro_name}!("CARGO_BIN_NAME");
95
- }}
96
- "#
97
- ) ,
75
+ r#"
76
+ //- minicore: env
77
+ fn main() {
78
+ let foo = env!("CAR$0");
79
+ }
80
+ "# ,
81
+ r#"
82
+ fn main() {
83
+ let foo = env!("CARGO_BIN_NAME");
84
+ }
85
+ "# ,
98
86
) ;
99
87
}
100
- #[ test]
101
- fn completes_env_variable_in_env ( ) {
102
- check ( "env" )
103
- }
104
88
105
89
#[ test]
106
90
fn completes_env_variable_in_option_env ( ) {
107
- check ( "option_env" ) ;
91
+ check_edit (
92
+ "CARGO_BIN_NAME" ,
93
+ r#"
94
+ //- minicore: env
95
+ fn main() {
96
+ let foo = option_env!("CAR$0");
97
+ }
98
+ "# ,
99
+ r#"
100
+ fn main() {
101
+ let foo = option_env!("CARGO_BIN_NAME");
102
+ }
103
+ "# ,
104
+ ) ;
108
105
}
109
106
110
107
#[ test]
You can’t perform that action at this time.
0 commit comments