File tree 3 files changed +23
-10
lines changed
hir-def/src/macro_expansion_tests
3 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ fn main() { option_env!("TEST_ENV_VAR"); }
97
97
#[rustc_builtin_macro]
98
98
macro_rules! option_env {() => {}}
99
99
100
- fn main() { $crate ::option::Option::None:: < &str>; }
100
+ fn main() { ::core ::option::Option::None:: < &str>; }
101
101
"# ] ] ,
102
102
) ;
103
103
}
Original file line number Diff line number Diff line change @@ -820,10 +820,10 @@ fn option_env_expand(
820
820
)
821
821
}
822
822
} ;
823
-
823
+ // FIXME: Use `DOLLAR_CRATE` when that works in eager macros.
824
824
let expanded = match get_env_inner ( db, arg_id, & key) {
825
- None => quote ! { # DOLLAR_CRATE :: option:: Option :: None :: <& str > } ,
826
- Some ( s) => quote ! { # DOLLAR_CRATE :: option:: Option :: Some ( #s) } ,
825
+ None => quote ! { :: core :: option:: Option :: None :: <& str > } ,
826
+ Some ( s) => quote ! { :: core :: option:: Option :: Some ( #s) } ,
827
827
} ;
828
828
829
829
ExpandResult :: ok ( ExpandedEager :: new ( expanded) )
Original file line number Diff line number Diff line change @@ -947,21 +947,34 @@ fn infer_builtin_macros_concat_with_lazy() {
947
947
948
948
#[ test]
949
949
fn infer_builtin_macros_env ( ) {
950
- check_infer (
950
+ check_types (
951
951
r#"
952
952
//- /main.rs env:foo=bar
953
953
#[rustc_builtin_macro]
954
954
macro_rules! env {() => {}}
955
955
956
956
fn main() {
957
957
let x = env!("foo");
958
+ //^ &str
959
+ }
960
+ "# ,
961
+ ) ;
962
+ }
963
+
964
+ #[ test]
965
+ fn infer_builtin_macros_option_env ( ) {
966
+ check_types (
967
+ r#"
968
+ //- minicore: option
969
+ //- /main.rs env:foo=bar
970
+ #[rustc_builtin_macro]
971
+ macro_rules! option_env {() => {}}
972
+
973
+ fn main() {
974
+ let x = option_env!("foo");
975
+ //^ Option<&str>
958
976
}
959
977
"# ,
960
- expect ! [ [ r#"
961
- !0..22 '"__RA_...TED__"': &str
962
- 62..90 '{ ...o"); }': ()
963
- 72..73 'x': &str
964
- "# ] ] ,
965
978
) ;
966
979
}
967
980
You can’t perform that action at this time.
0 commit comments