Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a2dc9b5

Browse filesBrowse files
authored
Rollup merge of rust-lang#126929 - nnethercote:rm-__rust_force_expr, r=oli-obk
Remove `__rust_force_expr`. This was added (with a different name) to improve an error message. It is no longer needed -- removing it changes the error message, but overall I think the new message is no worse: - the mention of `#` in the first line is a little worse, - but the extra context makes it very clear what the problem is, perhaps even clearer than the old message, - and the removal of the note about the `expr` fragment (an internal detail of `__rust_force_expr`) is an improvement. Overall I think the error is quite clear and still far better than the old message that prompted rust-lang#61933, which didn't even mention patterns. The motivation for this is rust-lang#124141, which will cause pasted metavariables to be tokenized and reparsed instead of the AST node being cached. This change in behaviour occasionally has a non-zero perf cost, and `__rust_force_expr` causes the tokenize/reparse step to occur twice. Removing `__rust_force_expr` greatly reduces the extra overhead for the `deep-vector` benchmark. r? ```@oli-obk```
2 parents a8b311e + 028026b commit a2dc9b5
Copy full SHA for a2dc9b5

File tree

Expand file treeCollapse file tree

1 file changed

+4
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-14
lines changed

‎alloc/src/macros.rs

Copy file name to clipboardExpand all lines: alloc/src/macros.rs
+4-14Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@
4141
#[allow_internal_unstable(rustc_attrs, liballoc_internals)]
4242
macro_rules! vec {
4343
() => (
44-
$crate::__rust_force_expr!($crate::vec::Vec::new())
44+
$crate::vec::Vec::new()
4545
);
4646
($elem:expr; $n:expr) => (
47-
$crate::__rust_force_expr!($crate::vec::from_elem($elem, $n))
47+
$crate::vec::from_elem($elem, $n)
4848
);
4949
($($x:expr),+ $(,)?) => (
50-
$crate::__rust_force_expr!(<[_]>::into_vec(
50+
<[_]>::into_vec(
5151
// This rustc_box is not required, but it produces a dramatic improvement in compile
5252
// time when constructing arrays with many elements.
5353
#[rustc_box]
5454
$crate::boxed::Box::new([$($x),+])
55-
))
55+
)
5656
);
5757
}
5858

@@ -126,13 +126,3 @@ macro_rules! format {
126126
res
127127
}}
128128
}
129-
130-
/// Force AST node to an expression to improve diagnostics in pattern position.
131-
#[doc(hidden)]
132-
#[macro_export]
133-
#[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")]
134-
macro_rules! __rust_force_expr {
135-
($e:expr) => {
136-
$e
137-
};
138-
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.