From 108b8b6dc707775bd54aeea7820e0d473f556718 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 18 Jun 2014 20:25:36 +0200 Subject: Deprecate the bytes!() macro. Replace its usage with byte string literals, except in `bytes!()` tests. Also add a new snapshot, to be able to use the new b"foo" syntax. The src/etc/2014-06-rewrite-bytes-macros.py script automatically rewrites `bytes!()` invocations into byte string literals. Pass it filenames as arguments to generate a diff that you can inspect, or `--apply` followed by filenames to apply the changes in place. Diffs can be piped into `tip` or `pygmentize -l diff` for coloring. --- src/libsyntax/ext/bytes.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index b87a25d4a44..658c28f8202 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -19,6 +19,14 @@ use ext::build::AstBuilder; pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Box { + cx.span_warn(sp, "`bytes!` is deprecated, use `b\"foo\"` literals instead"); + cx.parse_sess.span_diagnostic.span_note(sp, + "see http://doc.rust-lang.org/rust.html#byte-and-byte-string-literals \ + for documentation"); + cx.parse_sess.span_diagnostic.span_note(sp, + "see https://github.com/rust-lang/rust/blob/master/src/etc/2014-06-rewrite-bytes-macros.py \ + for a automated migration"); + // Gather all argument expressions let exprs = match get_exprs_from_tts(cx, sp, tts) { None => return DummyResult::expr(sp), -- cgit 1.4.1-3-g733a5 From 72f0d4535715505c1cc429ef277a954ba26366bd Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 19 Jun 2014 00:59:40 +0200 Subject: Revert bytes!() docstring change, and fix a typo. --- src/libstd/macros.rs | 2 +- src/libsyntax/ext/bytes.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index dad162d82ad..58f65c90b3b 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -463,7 +463,7 @@ pub mod builtin { /// # Example /// /// ``` - /// let rust = b"rust\xFF"; + /// let rust = bytes!("r", 'u', "st", 255); /// assert_eq!(rust[1], 'u' as u8); /// assert_eq!(rust[4], 255); /// ``` diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index 658c28f8202..ce13fa2a7c6 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -25,7 +25,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) for documentation"); cx.parse_sess.span_diagnostic.span_note(sp, "see https://github.com/rust-lang/rust/blob/master/src/etc/2014-06-rewrite-bytes-macros.py \ - for a automated migration"); + for an automated migration"); // Gather all argument expressions let exprs = match get_exprs_from_tts(cx, sp, tts) { -- cgit 1.4.1-3-g733a5