Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
652f34d
Add [T]::as_chunks_mut (as unstable)
scottmcm Sep 12, 2020
66fa42a
allow using the system-wide llvm-libunwind as the unwinder
Keruspe Oct 8, 2020
6fdd53b
Prefer to use `print_def_path`
JohnTitor Oct 22, 2020
5923218
Add test for bad NLL higher-ranked subtype
Aaron1011 Oct 23, 2020
cc468c0
Use check-pass in single-use-lifetime ui test suite
oliviacrain Oct 25, 2020
e218380
Make some functions private that don't have to be public
jyn514 Oct 25, 2020
88d3967
Use its own `TypeckResults` to avoid ICE
JohnTitor Oct 25, 2020
4f34537
Fix small typos
JohnTitor Oct 25, 2020
666afba
Update description for error E0308
PoignardAzur Oct 24, 2020
9de1518
Fix typo in debug statement
LeSeulArtichaut Oct 25, 2020
04c0018
Use ? in core/std macros
taiki-e Oct 25, 2020
a4ba179
fix(docs): typo in BufWriter documentation
rubik Oct 26, 2020
ad552bc
Add compiler support for LLVM's x86 ERMSB feature
josephlr Oct 26, 2020
42844ed
Add lexicographical comparison doc
0xPoe Oct 25, 2020
74a9891
Fix typo in lint description
notriddle Oct 26, 2020
94ed945
Add some regression tests
camelid Oct 26, 2020
4641d2e
Add FIXME note to const generics test
camelid Oct 26, 2020
59f1088
Improve formatting of hash collections docs
camelid Oct 26, 2020
13e88d6
Rollup merge of #76635 - scottmcm:slice-as-chunks, r=LukasKalbertodt
JohnTitor Oct 26, 2020
2c307fa
Rollup merge of #77703 - Keruspe:system-libunwind, r=Mark-Simulacrum
JohnTitor Oct 26, 2020
f3c9437
Rollup merge of #78219 - JohnTitor:print-def-path, r=estebank
JohnTitor Oct 26, 2020
9d7db48
Rollup merge of #78298 - Aaron1011:fix/nll-ranked-test, r=Mark-Simula…
JohnTitor Oct 26, 2020
0b72ca6
Rollup merge of #78332 - PoignardAzur:doc_E0308, r=camelid
JohnTitor Oct 26, 2020
afdd148
Rollup merge of #78342 - oliviacrain:checkmate-pass, r=Mark-Simulacrum
JohnTitor Oct 26, 2020
727e93d
Rollup merge of #78347 - Rustin-Liu:rustin-patch-doc, r=kennytm
JohnTitor Oct 26, 2020
ae54425
Rollup merge of #78348 - jyn514:pub-crate, r=GuillaumeGomez
JohnTitor Oct 26, 2020
6abd2a5
Rollup merge of #78349 - JohnTitor:issue-75962, r=davidtwco
JohnTitor Oct 26, 2020
5a33fa5
Rollup merge of #78375 - taiki-e:question-in-macros, r=kennytm
JohnTitor Oct 26, 2020
b72d70e
Rollup merge of #78377 - LeSeulArtichaut:patch-docs, r=jonas-schievink
JohnTitor Oct 26, 2020
98e2a95
Rollup merge of #78388 - camelid:regression-tests, r=lcnr
JohnTitor Oct 26, 2020
f6f8764
Rollup merge of #78394 - rubik:master, r=m-ou-se
JohnTitor Oct 26, 2020
46b8e46
Rollup merge of #78396 - josephlr:ermsb, r=petrochenkov
JohnTitor Oct 26, 2020
7824d9a
Rollup merge of #78405 - notriddle:patch-3, r=lcnr
JohnTitor Oct 26, 2020
4236d27
Rollup merge of #78412 - camelid:cleanup-hash-docs, r=jonas-schievink
JohnTitor Oct 26, 2020
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
59 changes: 16 additions & 43 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ macro_rules! panic {
() => (
$crate::panic!("explicit panic")
);
($msg:literal) => (
($msg:literal $(,)?) => (
$crate::panicking::panic($msg)
);
($msg:expr) => (
($msg:expr $(,)?) => (
$crate::panicking::panic_str($msg)
);
($msg:expr,) => (
$crate::panic!($msg)
);
($fmt:expr, $($arg:tt)+) => (
$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+))
);
Expand All @@ -40,7 +37,7 @@ macro_rules! panic {
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! assert_eq {
($left:expr, $right:expr) => ({
($left:expr, $right:expr $(,)?) => ({
match (&$left, &$right) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
Expand All @@ -54,9 +51,6 @@ macro_rules! assert_eq {
}
}
});
($left:expr, $right:expr,) => ({
$crate::assert_eq!($left, $right)
});
($left:expr, $right:expr, $($arg:tt)+) => ({
match (&($left), &($right)) {
(left_val, right_val) => {
Expand Down Expand Up @@ -94,7 +88,7 @@ macro_rules! assert_eq {
#[macro_export]
#[stable(feature = "assert_ne", since = "1.13.0")]
macro_rules! assert_ne {
($left:expr, $right:expr) => ({
($left:expr, $right:expr $(,)?) => ({
match (&$left, &$right) {
(left_val, right_val) => {
if *left_val == *right_val {
Expand All @@ -108,9 +102,6 @@ macro_rules! assert_ne {
}
}
});
($left:expr, $right:expr,) => {
$crate::assert_ne!($left, $right)
};
($left:expr, $right:expr, $($arg:tt)+) => ({
match (&($left), &($right)) {
(left_val, right_val) => {
Expand Down Expand Up @@ -315,17 +306,14 @@ macro_rules! matches {
#[rustc_deprecated(since = "1.39.0", reason = "use the `?` operator instead")]
#[doc(alias = "?")]
macro_rules! r#try {
($expr:expr) => {
($expr:expr $(,)?) => {
match $expr {
$crate::result::Result::Ok(val) => val,
$crate::result::Result::Err(err) => {
return $crate::result::Result::Err($crate::convert::From::from(err));
}
}
};
($expr:expr,) => {
$crate::r#try!($expr)
};
}

/// Writes formatted data into a buffer.
Expand Down Expand Up @@ -451,12 +439,9 @@ macro_rules! write {
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable(format_args_nl)]
macro_rules! writeln {
($dst:expr) => (
($dst:expr $(,)?) => (
$crate::write!($dst, "\n")
);
($dst:expr,) => (
$crate::writeln!($dst)
);
($dst:expr, $($arg:tt)*) => (
$dst.write_fmt($crate::format_args_nl!($($arg)*))
);
Expand Down Expand Up @@ -517,12 +502,9 @@ macro_rules! unreachable {
() => ({
panic!("internal error: entered unreachable code")
});
($msg:expr) => ({
($msg:expr $(,)?) => ({
$crate::unreachable!("{}", $msg)
});
($msg:expr,) => ({
$crate::unreachable!($msg)
});
($fmt:expr, $($arg:tt)*) => ({
panic!($crate::concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
});
Expand Down Expand Up @@ -711,8 +693,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
macro_rules! compile_error {
($msg:expr) => {{ /* compiler built-in */ }};
($msg:expr,) => {{ /* compiler built-in */ }};
($msg:expr $(,)?) => {{ /* compiler built-in */ }};
}

/// Constructs parameters for the other string-formatting macros.
Expand Down Expand Up @@ -816,8 +797,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
macro_rules! env {
($name:expr) => {{ /* compiler built-in */ }};
($name:expr,) => {{ /* compiler built-in */ }};
($name:expr $(,)?) => {{ /* compiler built-in */ }};
}

/// Optionally inspects an environment variable at compile time.
Expand All @@ -841,8 +821,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
macro_rules! option_env {
($name:expr) => {{ /* compiler built-in */ }};
($name:expr,) => {{ /* compiler built-in */ }};
($name:expr $(,)?) => {{ /* compiler built-in */ }};
}

/// Concatenates identifiers into one identifier.
Expand Down Expand Up @@ -877,8 +856,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
macro_rules! concat_idents {
($($e:ident),+) => {{ /* compiler built-in */ }};
($($e:ident,)+) => {{ /* compiler built-in */ }};
($($e:ident),+ $(,)?) => {{ /* compiler built-in */ }};
}

/// Concatenates literals into a static string slice.
Expand All @@ -900,8 +878,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
macro_rules! concat {
($($e:expr),*) => {{ /* compiler built-in */ }};
($($e:expr,)*) => {{ /* compiler built-in */ }};
($($e:expr),* $(,)?) => {{ /* compiler built-in */ }};
}

/// Expands to the line number on which it was invoked.
Expand Down Expand Up @@ -1043,8 +1020,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
macro_rules! include_str {
($file:expr) => {{ /* compiler built-in */ }};
($file:expr,) => {{ /* compiler built-in */ }};
($file:expr $(,)?) => {{ /* compiler built-in */ }};
}

/// Includes a file as a reference to a byte array.
Expand Down Expand Up @@ -1083,8 +1059,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
macro_rules! include_bytes {
($file:expr) => {{ /* compiler built-in */ }};
($file:expr,) => {{ /* compiler built-in */ }};
($file:expr $(,)?) => {{ /* compiler built-in */ }};
}

/// Expands to a string that represents the current module path.
Expand Down Expand Up @@ -1191,8 +1166,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
macro_rules! include {
($file:expr) => {{ /* compiler built-in */ }};
($file:expr,) => {{ /* compiler built-in */ }};
($file:expr $(,)?) => {{ /* compiler built-in */ }};
}

/// Asserts that a boolean expression is `true` at runtime.
Expand Down Expand Up @@ -1242,8 +1216,7 @@ pub(crate) mod builtin {
#[rustc_builtin_macro]
#[macro_export]
macro_rules! assert {
($cond:expr) => {{ /* compiler built-in */ }};
($cond:expr,) => {{ /* compiler built-in */ }};
($cond:expr $(,)?) => {{ /* compiler built-in */ }};
($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};
}

Expand Down
7 changes: 2 additions & 5 deletions library/std/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#[allow_internal_unstable(libstd_sys_internals)]
macro_rules! panic {
() => ({ $crate::panic!("explicit panic") });
($msg:expr) => ({ $crate::rt::begin_panic($msg) });
($msg:expr,) => ({ $crate::panic!($msg) });
($msg:expr $(,)?) => ({ $crate::rt::begin_panic($msg) });
($fmt:expr, $($arg:tt)+) => ({
$crate::rt::begin_panic_fmt(&$crate::format_args!($fmt, $($arg)+))
});
Expand Down Expand Up @@ -285,7 +284,7 @@ macro_rules! dbg {
() => {
$crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!());
};
($val:expr) => {
($val:expr $(,)?) => {
// Use of `match` here is intentional because it affects the lifetimes
// of temporaries - https://stackoverflow.com/a/48732525/1063961
match $val {
Expand All @@ -296,8 +295,6 @@ macro_rules! dbg {
}
}
};
// Trailing comma with single argument is ignored
($val:expr,) => { $crate::dbg!($val) };
($($val:expr),+ $(,)?) => {
($($crate::dbg!($val)),+,)
};
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/issue-62894.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ LL | fn main() {}
|
::: $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
LL | ($left:expr, $right:expr) => ({
LL | ($left:expr, $right:expr $(,)?) => ({
| ---------- while parsing argument for this `expr` macro fragment

error: aborting due to 4 previous errors
Expand Down