mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
Auto merge of #14890 - HKalbasi:dev, r=HKalbasi
use `::core` instead of `$crate` in `option_env!` fix #14885
This commit is contained in:
commit
efd3094aba
3 changed files with 23 additions and 10 deletions
|
@ -97,7 +97,7 @@ fn main() { option_env!("TEST_ENV_VAR"); }
|
|||
#[rustc_builtin_macro]
|
||||
macro_rules! option_env {() => {}}
|
||||
|
||||
fn main() { $crate::option::Option::None:: < &str>; }
|
||||
fn main() { ::core::option::Option::None:: < &str>; }
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -820,10 +820,10 @@ fn option_env_expand(
|
|||
)
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME: Use `DOLLAR_CRATE` when that works in eager macros.
|
||||
let expanded = match get_env_inner(db, arg_id, &key) {
|
||||
None => quote! { #DOLLAR_CRATE::option::Option::None::<&str> },
|
||||
Some(s) => quote! { #DOLLAR_CRATE::option::Option::Some(#s) },
|
||||
None => quote! { ::core::option::Option::None::<&str> },
|
||||
Some(s) => quote! { ::core::option::Option::Some(#s) },
|
||||
};
|
||||
|
||||
ExpandResult::ok(ExpandedEager::new(expanded))
|
||||
|
|
|
@ -947,7 +947,7 @@ fn infer_builtin_macros_concat_with_lazy() {
|
|||
|
||||
#[test]
|
||||
fn infer_builtin_macros_env() {
|
||||
check_infer(
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs env:foo=bar
|
||||
#[rustc_builtin_macro]
|
||||
|
@ -955,13 +955,26 @@ fn infer_builtin_macros_env() {
|
|||
|
||||
fn main() {
|
||||
let x = env!("foo");
|
||||
//^ &str
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_builtin_macros_option_env() {
|
||||
check_types(
|
||||
r#"
|
||||
//- minicore: option
|
||||
//- /main.rs env:foo=bar
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! option_env {() => {}}
|
||||
|
||||
fn main() {
|
||||
let x = option_env!("foo");
|
||||
//^ Option<&str>
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
!0..22 '"__RA_...TED__"': &str
|
||||
62..90 '{ ...o"); }': ()
|
||||
72..73 'x': &str
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue