From 85c1a4b1ba09dae786b3554e0ab596814efabe0e Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Mon, 22 Dec 2014 10:57:09 +1300 Subject: Rename include_bin! to include_bytes! According to [RFC 344][], methods that return `&[u8]` should have names ending in `bytes`. Though `include_bin!` is a macro not a method, it seems reasonable to follow the convention anyway. We keep the old name around for now, but trigger a deprecation warning when it is used. [RFC 344]: https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md [breaking-change] --- src/libsyntax/ext/base.rs | 3 +++ src/libsyntax/ext/source_util.rs | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index d45871708dc..8e69076a2c5 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -442,6 +442,9 @@ fn initial_syntax_expander_table(ecfg: &expand::ExpansionConfig) -> SyntaxEnv { syntax_expanders.insert(intern("include_bin"), builtin_normal_expander( ext::source_util::expand_include_bin)); + syntax_expanders.insert(intern("include_bytes"), + builtin_normal_expander( + ext::source_util::expand_include_bytes)); syntax_expanders.insert(intern("module_path"), builtin_normal_expander( ext::source_util::expand_mod)); diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 7c2c5c1530c..a49df457cb3 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -163,7 +163,13 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Box { - let file = match get_single_str_from_tts(cx, sp, tts, "include_bin!") { + cx.span_warn(sp, "include_bin! is deprecated; use include_bytes! instead"); + expand_include_bytes(cx, sp, tts) +} + +pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) + -> Box { + let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") { Some(f) => f, None => return DummyResult::expr(sp) }; -- cgit 1.4.1-3-g733a5