diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-01-22 14:30:21 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-22 14:30:21 +0000 |
| commit | 70597f28f6a97015d3d02ee34a7fa076128f3f32 (patch) | |
| tree | 6090bb2b16e425582d088922699946897da94ff4 | |
| parent | 3682a06dcff54a6b9188fd4395e26b316c7652f7 (diff) | |
| parent | 1934eaf6d87df0eb557e80f9c6a63af8569c48bd (diff) | |
| download | rust-70597f28f6a97015d3d02ee34a7fa076128f3f32.tar.gz rust-70597f28f6a97015d3d02ee34a7fa076128f3f32.zip | |
Rollup merge of #81241 - m-ou-se:force-expr-macro-rules, r=oli-obk
Turn alloc's force_expr macro into a regular macro_rules. This turns `alloc`'s `force_expr` macro into a regular `macro_rules`. Otherwise rust-analyzer doesn't understand `vec![]`. See https://github.com/rust-analyzer/rust-analyzer/issues/7349 and https://github.com/rust-lang/rust/pull/81080#issuecomment-764741721 Edit: See https://github.com/rust-lang/rust/pull/81241#issuecomment-764812660 for a discussion of alternatives.
| -rw-r--r-- | library/alloc/src/lib.rs | 7 | ||||
| -rw-r--r-- | 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..f1e3ee97ccc 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::__rust_force_expr!($crate::vec::Vec::new()) ); ($elem:expr; $n:expr) => ( - $crate::__export::force_expr!($crate::vec::from_elem($elem, $n)) + $crate::__rust_force_expr!($crate::vec::from_elem($elem, $n)) ); ($($x:expr),+ $(,)?) => ( - $crate::__export::force_expr!(<[_]>::into_vec(box [$($x),+])) + $crate::__rust_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! __rust_force_expr { + ($e:expr) => { + $e + }; +} |
