Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn alloc's force_expr macro into a regular macro_rules. #81241

Merged
merged 2 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
16 changes: 13 additions & 3 deletions library/alloc/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),+]))
);
}

Expand Down Expand Up @@ -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
};
}