about summary refs log tree commit diff
path: root/src/libcore/macros.rs
AgeCommit message (Collapse)AuthorLines
2018-05-03update concat_idents doc stubsMichael Lamparski-2/+2
2018-04-24Rollup merge of #49906 - kennytm:stable-unreachable, r=sfacklerkennytm-4/+4
Stabilize `std::hint::unreachable_unchecked`. Closes #43751.
2018-04-21add more aliasesGuillaume Gomez-0/+1
2018-04-16Stabilize core::hint::unreachable_unchecked.kennytm-4/+4
Closes #43751.
2018-04-05Bump the bootstrap compiler to 1.26.0 betaAlex Crichton-65/+0
Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language features!
2018-03-07Make `assert` macro a built-in procedural macroShotaro Yamada-0/+15
2018-02-28Auto merge of #48056 - ExpHP:macro-commas, r=dtolnaybors-7/+35
Comprehensively support trailing commas in std/core macros I carefully organized the changes into four commits: * Test cases * Fixes for `macro_rules!` macros * Fixes for builtin macros * Docs for builtins **I can easily scale this back to just the first two commits for now if such is desired.** ### Breaking (?) changes * This fixes #48042, which is a breaking change that I hope people can agree is just a bugfix for an extremely dark corner case. * To fix five of the builtins, this changes `syntax::ext::base::get_single_str_from_tts` to accept a trailing comma, and revises the documentation so that this aspect is not surprising. **I made this change under the (hopefully correct) understanding that `libsyntax` is private rustc implementation detail.** After reviewing all call sites (which were, you guessed it, *precisely those five macros*), I believe the revised semantics are closer to the intended spirit of the function. ### Changes which may require concensus Up until now, it could be argued that some or all the following macros did not conceptually take a comma-separated list, because they only took one argument: * **`cfg(unix,)`** (most notable since cfg! is unique in taking a meta tag) * **`include{,_bytes,_str}("file.rs",)`** (in item form this might be written as "`include!{"file.rs",}`" which is even slightly more odd) * **`compile_error("message",);`** * **`option_env!("PATH",)`** * **`try!(Ok(()),)`** So I think these particular changes may require some sort of consensus. **All of the fixes for builtins are included this list, so if we want to defer these decisions to later then I can scale this PR back to just the first two commits.** ### Other notes/general requests for comment * Do we have a big checklist somewhere of "things to do when adding macros?" My hope is for `run-pass/macro-comma-support.rs` to remain comprehensive. * Originally I wanted the tests to also comprehensively forbid double trailing commas. However, this didn't work out too well: [see this gist and the giant FIXME in it](https://gist.github.com/ExpHP/6fc40e82f3d73267c4e590a9a94966f1#file-compile-fail_macro-comma-support-rs-L33-L50) * I did not touch `select!`. It appears to me to be a complete mess, and its trailing comma mishaps are only the tip of the iceberg. * There are [some compile-fail test cases](https://github.com/ExpHP/rust/blob/5fa97c35da2f0ee/src/test/compile-fail/macro-comma-behavior.rs#L49-L52) that didn't seem to work (rustc emits errors, but compile-fail doesn't acknowledge them), so they are disabled. Any clues? (Possibly related: These happen to be precisely the set of errors which are tagged by rustc as "this error originates in a macro outside of the current crate".) --- Fixes #48042 Closes #46241
2018-02-10fix typos in src/{bootstrap,ci,etc,lib{backtrace,core,fmt_macros}}Matthias Krüger-1/+1
2018-02-07update the builtin macro doc stubsMichael Lamparski-5/+20
2018-02-07libcore/libstd: fix commas in macro_rules! macrosMichael Lamparski-2/+15
BREAKING CHANGE: (or perhaps, *bugfix*) In #![no_std] applications, the following calls to `panic!` used to behave differently; they now behave the same. Old behavior: panic!("{{"); // panics with "{{" panic!("{{",); // panics with "{" New behavior: panic!("{{"); // panics with "{{" panic!("{{",); // panics with "{{" This only affects calls to `panic!` (and by proxy `assert` and `debug_assert`) with a single string literal followed by a trailing comma, and only in `#![no_std]` applications.
2018-01-04Make examples equivalentaheart-0/+1
The example with the ? operator was missing file.write_all
2017-12-07Rollup merge of #46416 - liigo:cfg-macro, r=steveklabnikGuillaume Gomez-1/+1
doc: macro `cfg!` evaluating at compile-time
2017-12-04Give compile_error macro examplesHavvy-2/+2
2017-12-01doc: macro `cfg!` evaluating at compile-timeLiigo Zhuang-1/+1
2017-11-26Update libcore macro stubs like libstdMichael Lamparski-6/+14
2017-11-20Fix some docs summary nitsMarco A L Barbosa-1/+1
2017-11-09Allow a trailing comma in assert_eq/ne macroKonrad Borowski-0/+6
2017-10-22fix stringify docsAlex Burka-2/+2
2017-09-10Use rvalue promotion to 'static instead of static items.Eduard-Mihai Burtescu-10/+3
2017-09-02Merge branch 'master' of git://github.com/rust-lang/rustMarkMcCaskey-10/+0
2017-08-31Merge branch 'master' into masterMark-12/+35
2017-08-31Update bootstrap compilerAlex Crichton-10/+0
This commit updates the bootstrap compiler and clears out a number of #[cfg(stage0)] annotations and related business
2017-08-30update unimplemented! docsMarkMcCaskey-2/+5
2017-08-29API docs: macros. Part of #29329 Standard Library Documentation Checklist.Andy Gauge-14/+42
2017-08-08Avoid calling the column!() macro in panicest31-2/+12
2017-07-25Stabilize the `compile_error_macro` featureAlex Crichton-1/+1
Stabilizes: * `compile_error!` as a macro defined by rustc Closes #40872
2017-07-12Rollup merge of #42670 - dns2utf8:panic_return_code, r=steveklabnikMark Simulacrum-1/+1
Add hint about the return code of panic! I hope the link works on all cases, since the `unreachable` doc is copied to `std::` as well.
2017-07-05Insert current implementation headerStefan Schindler-1/+1
2017-07-02Fix the test failure, add comment, and refactor a little bitest31-2/+2
2017-07-02Output line column info when panickingest31-4/+6
2017-06-24Auto merge of #42541 - gilescope:patch-1, r=alexcrichtonbors-8/+12
assert_eq failure message easier to read By having the left and right strings aligned with one another it helps spot the difference between the two far quicker than if they are on the same line. E.g. Before: ``` thread 'tests::test_safe_filename' panicked at 'assertion failed: `(left == right)` left: `"-aandb--S123.html"` right: `"-aandb-S123.html"`', ``` After: ``` thread 'tests::test_safe_filename' panicked at 'assertion failed: `(left == right)` left: `"-aandb--S123.html"` right: `"-aandb-S123.html"`', ``` When the strings are both on the same line it take a lot longer to spot the difference. It is a small change but the small time savings add up with repetition. This would help Rust be an excellent language to write tests in out of the box. Closes https://github.com/rust-lang/rust/issues/41615
2017-06-22Adding training commer to be more consistent with prior format.Giles Cope-4/+4
2017-06-20Whitespace changeGiles Cope-2/+2
2017-06-19Merge remote-tracking branch 'upstream/master'Giles Cope-2/+3
2017-06-19Add compile_error!Wesley Wiser-0/+11
Related to #40872
2017-06-15Add hint about the return code of panic!Stefan Schindler-1/+1
2017-06-15Update older URLs pointing to the first edition of the BookWonwoo Choi-1/+1
`compiler-plugins.html` is moved into the Unstable Book. Explanation is slightly modified to match the change.
2017-06-13Removing tabs. Sorry - have updated my .vimrcGiles Cope-2/+2
2017-06-13Updated tests and fixed inconsistent message on assert_eqGiles Cope-8/+10
2017-06-13updated assert_eq test, fixed incorrect assert_ne message and added test.Giles Cope-8/+12
2017-06-11Auto merge of #42155 - seanmonstar:unimplemented, r=sfacklerbors-1/+2
core: allow messages in unimplemented!() macro This makes `unimplemented!()` match `unreachable!()`, allowing a message and possible formatting to be provided to better explain what and/or why something is not implemented. I've used this myself in hyper for a while, include the type and method name, to better help while prototyping new modules, like `unimplemented!("Conn::poll_complete")`, or `unimplemented!("Conn::poll; state={:?}", state)`.
2017-06-08Assert failure message easier to readSquirrel-4/+6
By having the left and right strings above and below on the same line it helps spot the difference between the two. E.g. thread 'tests::test_safe_filename' panicked at 'assertion failed: `(left == right)` left: `"-aandb--S123.html"` right: `"-aandb-S123.html"`', When the strings are both on the same line it take a lot longer to spot the difference. It is a small change but the small time savings add up with repetition. This helps Rust be an excellent language to write tests in.
2017-06-07core: allow messages in unimplemented!() macroSean McArthur-1/+2
2017-06-05Doc changes for assert macrosMichael Kohl-5/+13
See #29381
2017-04-18Fix a few stability attributesOliver Middleton-5/+5
These show up in rustdoc so need to be correct.
2017-03-30Improve the docs for the write and writeln macrosSam Whited-38/+16
This change reduces duplication by linking the documentation for `writeln!` to `write!`. It also restructures the `write!` documentation to read in a more logical manner. Updates #29329, #29381
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-2/+2
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-07Add missing urls in some macros docGuillaume Gomez-7/+16
2017-02-06improve error message when two-arg assert_eq! receives a trailing commaZack M. Davis-6/+6
Previously, `assert_eq!(left, right,)` (respectively, `assert_ne!(left, right,)`; note the trailing comma) would result in a confusing "requires at least a format string argument" error. In reality, a format string is optional, but the trailing comma puts us into the "match a token tree of zero or more tokens" branch of the macro (in order to support the optional format string), and passing the empty token tree into `format_args!` results in the confusing error. If instead we match a token tree of one or more tokens, we get a much more sensible "unexpected end of macro invocation" error. While we're here, fix up a stray space before a comma in the match guards. Resolves #39369.
2017-01-11Document the optional extra arguments to assert_eq!() / assert_ne!()Federico Mena Quintero-1/+12
And clarify that those arguments in assert!() are in fact formattable.