From 8f28a3269e1e9299764f3881880524bf49afcde3 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Thu, 21 Jan 2021 17:12:14 +0100 Subject: [PATCH] Turn alloc's force_expr macro into a regular macro_rules!{}. Otherwise rust-analyzer doesn't understand vec![]. --- library/alloc/src/lib.rs | 7 ------- library/alloc/src/macros.rs | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 8d721ed7487..d7ae353282e 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -189,11 +189,4 @@ pub mod vec; #[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")] pub mod __export { pub use core::format_args; - - /// Force AST node to an expression to improve diagnostics in pattern position. - #[rustc_macro_transparency = "semitransparent"] - #[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")] - pub macro force_expr($e:expr) { - $e - } } diff --git a/library/alloc/src/macros.rs b/library/alloc/src/macros.rs index 3a46763c3f6..9e5e81595cf 100644 --- a/library/alloc/src/macros.rs +++ b/library/alloc/src/macros.rs @@ -40,13 +40,13 @@ #[allow_internal_unstable(box_syntax, liballoc_internals)] macro_rules! vec { () => ( - $crate::__export::force_expr!($crate::vec::Vec::new()) + $crate::force_expr!($crate::vec::Vec::new()) ); ($elem:expr; $n:expr) => ( - $crate::__export::force_expr!($crate::vec::from_elem($elem, $n)) + $crate::force_expr!($crate::vec::from_elem($elem, $n)) ); ($($x:expr),+ $(,)?) => ( - $crate::__export::force_expr!(<[_]>::into_vec(box [$($x),+])) + $crate::force_expr!(<[_]>::into_vec(box [$($x),+])) ); } @@ -111,3 +111,13 @@ macro_rules! format { res }} } + +/// Force AST node to an expression to improve diagnostics in pattern position. +#[doc(hidden)] +#[macro_export] +#[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")] +macro_rules! force_expr { + ($e:expr) => { + $e + }; +}